core icon indicating copy to clipboard operation
core copied to clipboard

Support Tuya BAF-908 Smart Watering System

Open malwikl opened this issue 1 year ago • 21 comments

The problem

Hi all,

I acquired a Tuya BAF 908 Smart Watering System similar to this one: https://de.aliexpress.com/item/1005004188351618.html

It has two valves with a timer and can be programmed... In HA it is recognized as a thermostat, but as far I can figure out in the diagnostics data I can see the two valves, two timers (1..360 seconds each) and a mode switch (manual/auto).

Can you hint me how I can define/change the mapping to home assistant entities?

Thanks MAlWiKl

What version of Home Assistant Core has the issue?

core-2024.5.3

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant Container

Integration causing the issue

Tuya

Link to integration documentation on our website

https://www.home-assistant.io/integrations/tuya/

Diagnostics information

{ "home_assistant": { "installation_type": "Home Assistant Container", "version": "2024.5.3", "dev": false, "hassio": false, "virtualenv": false, "python_version": "3.12.2", "docker": true, "arch": "aarch64", "timezone": "Europe/Berlin", "os_name": "Linux", "os_version": "6.6.16-current-meson64", "run_as_root": true }, "custom_components": { "nuki_ng": { "documentation": "https://github.com/kvj/hass_nuki_ng", "version": "0.2.1", "requirements": [] }, "climate_group": { "documentation": "https://github.com/daenny/climate_group", "version": "0.4.2", "requirements": [] }, "browser_mod": { "documentation": "https://github.com/thomasloven/hass-browser_mod/blob/master/README.md", "version": "2.3.0", "requirements": [] }, "dwains_dashboard": { "documentation": "https://dwainscheeren.github.io/dwains-lovelace-dashboard/", "version": "3.1.1", "requirements": [] }, "ui_lovelace_minimalist": { "documentation": "https://ui-lovelace-minimalist.github.io/UI/", "version": "v1.3.9", "requirements": [ "aiofiles==0.8.0", "aiogithubapi>=22.2.4" ] }, "tapo_control": { "documentation": "https://github.com/JurajNyiri/HomeAssistant-Tapo-Control", "version": "5.4.13", "requirements": [ "pytapo==3.3.19" ] }, "hacs": { "documentation": "https://hacs.xyz/docs/configuration/start", "version": "1.34.0", "requirements": [ "aiogithubapi>=22.10.1" ] }, "webrtc": { "documentation": "https://github.com/AlexxIT/WebRTC", "version": "v3.5.2", "requirements": [] } }, "integration_manifest": { "domain": "tuya", "name": "Tuya", "codeowners": [ "@Tuya", "@zlinoliver", "@frenck" ], "config_flow": true, "dependencies": [ "ffmpeg" ], "dhcp": [ { "macaddress": "105A17*" }, { "macaddress": "10D561*" }, { "macaddress": "1869D8*" }, { "macaddress": "381F8D*" }, { "macaddress": "508A06*" }, { "macaddress": "68572D*" }, { "macaddress": "708976*" }, { "macaddress": "7CF666*" }, { "macaddress": "84E342*" }, { "macaddress": "D4A651*" }, { "macaddress": "D81F12*" } ], "documentation": "https://www.home-assistant.io/integrations/tuya", "integration_type": "hub", "iot_class": "cloud_push", "loggers": [ "tuya_iot" ], "requirements": [ "tuya-device-sharing-sdk==0.1.9" ], "is_built_in": true }, "data": { "endpoint": "https://apigw.tuyaeu.com", "terminal_id": "1715440815237CdepHJ", "mqtt_connected": true, "disabled_by": null, "disabled_polling": false, "id": "bfc24727a7c200067efocd", "name": "Balkonbew\u00e4sserung", "category": "wk", "product_id": "abzzvtulukkwzynv", "product_name": "smart watering device", "online": true, "sub": false, "time_zone": "+02:00", "active_time": "2024-05-11T15:12:51+00:00", "create_time": "2024-05-11T15:12:51+00:00", "update_time": "2024-05-11T15:12:51+00:00", "function": { "switch": { "type": "Boolean", "value": {} }, "mode": { "type": "Enum", "value": { "range": [ "auto", "manual" ] } }, "temp_set": { "type": "Integer", "value": { "unit": "s", "min": 0, "max": 360, "scale": 0, "step": 1 } } }, "status_range": { "switch": { "type": "Boolean", "value": {} }, "mode": { "type": "Enum", "value": { "range": [ "auto", "manual" ] } }, "temp_set": { "type": "Integer", "value": { "unit": "s", "min": 0, "max": 360, "scale": 0, "step": 1 } } }, "status": { "switch": false, "mode": "manual", "temp_set": 360 }, "home_assistant": { "name": "Balkonbew\u00e4sserung", "name_by_user": null, "disabled": false, "disabled_by": null, "entities": [ { "disabled": false, "disabled_by": null, "entity_category": null, "device_class": null, "original_device_class": null, "icon": null, "original_icon": null, "unit_of_measurement": null, "state": { "entity_id": "climate.balkonbewasserung", "state": "off", "attributes": { "hvac_modes": [ "off", "heat_cool", "heat_cool" ], "min_temp": 0.0, "max_temp": 360.0, "target_temp_step": 1.0, "current_temperature": null, "temperature": 360.0, "friendly_name": "Balkonbew\u00e4sserung", "supported_features": 385 }, "last_changed": "2024-05-11T15:38:24.013089+00:00", "last_reported": "2024-05-11T15:38:24.013089+00:00", "last_updated": "2024-05-11T15:38:24.013089+00:00" } } ] }, "set_up": true, "support_local": true } }

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

malwikl avatar May 12 '24 13:05 malwikl

Hey there @tuya, @zlinoliver, @frenck, mind taking a look at this issue as it has been labeled with an integration (tuya) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of tuya can trigger bot actions by commenting:

  • @home-assistant close Closes the issue.
  • @home-assistant rename Awesome new title Renames the issue.
  • @home-assistant reopen Reopen the issue.
  • @home-assistant unassign tuya Removes the current integration label and assignees on the issue, add the integration domain after the command.
  • @home-assistant add-label needs-more-information Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue.
  • @home-assistant remove-label needs-more-information Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.

(message by CodeOwnersMention)


tuya documentation tuya source (message by IssueLinks)

home-assistant[bot] avatar May 12 '24 13:05 home-assistant[bot]

I have the same Issue with that specific device. Its recognized as HVAC. And nothing is working, except a mode change to switch the device off. But as @malwikl mentioned the datapoints for the pump, duration, ... are shown in diagnostic data Screenshot_20240514-215101

Edit: I got it to run partially with the local_tuya integration, but you must add/map the datapoints by yourself. And it looks like local_tuya doesnt have any possible datapoint in its internal database, in the tuya iot api browser i see some more datapoints (in that specific case the datapoints for the timers, runtime, ...) which are missing in the local_tuya integration. What work so far is on/off, change pump combination (means A,B,A+B), setting of temp (whatever that is), and a sensor which shows the current "clockTime" which is the duration in seconds how long the pumps are pumping at the moment.

ninharp avatar May 14 '24 19:05 ninharp

I really appreciate if you can explain how you fixed the problem. Even the local_tuya for me is not known. Thank you in advance.

salemh avatar Jun 07 '24 13:06 salemh

up @tuya?

tgroszkowski avatar Jun 12 '24 16:06 tgroszkowski

I really appreciate if you can explain how you fixed the problem. Even the local_tuya for me is not known. Thank you in advance. @salemh Yes, sure. The local_tuya is the equivalent of the tuya integration but use only local connections to the device for communication to not be depending on an internet/cloud connection. If you create a simple developer account on the tuya developer portal you could easily add your tuya app account to the developer account at tuya to debug your devices which are connected to the cloud and your app account. If you have successfully linked your app account you can then use the tuya api explorer to examine the devices and find out the needed local key for the encryption of the communication to the device (most of that the local_tuya integration already does for you) its just you need to find out some datapoints which are not always labeled very good. So the api explorer is for that the correct tool to find out and fiddle around with the unknown datapoints. Dont hesitate to contact me if you encounter any problems in integrating tuya devices with the local_tuya integration.

ninharp avatar Jun 12 '24 17:06 ninharp

Thank you a lot. I just added HACS and will go ahead with local tuya. I have one issue with smart watering device that appears as thermostat and driving me crazy. Not sure if I can add pictures here but just in case here

Sent from Outlook for iOShttps://aka.ms/o0ukef


From: ninharp @.> Sent: Wednesday, June 12, 2024 9:02:32 PM To: home-assistant/core @.> Cc: salemh @.>; Mention @.> Subject: Re: [home-assistant/core] Support Tuya BAF-908 Smart Watering System (Issue #117304)

I really appreciate if you can explain how you fixed the problem. Even the local_tuya for me is not known. Thank you in advance. @salemhhttps://github.com/salemh Yes, sure. The local_tuya is the equivalent of the tuya integration but use only local connections to the device for communication to not be depending on an internet/cloud connection. If you create a simple developer account on the tuya developer portal you could easily add your tuya app account to the developer account at tuya to debug your devices which are connected to the cloud and your app account. If you have successfully linked your app account you can then use the tuya api explorer to examine the devices and find out the needed local key for the encryption of the communication to the device (most of that the local_tuya integration already does for you) its just you need to find out some datapoints which are not always labeled very good. So the api explorer is for that the correct tool to find out and fiddle around with the unknown datapoints. Dont hesitate to contact me if you encounter any problems in integrating tuya devices with the local_tuya integration.

— Reply to this email directly, view it on GitHubhttps://github.com/home-assistant/core/issues/117304#issuecomment-2163517055, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ABMRDSRDAQ4FYSXEVIJHOU3ZHB5KRAVCNFSM6AAAAABHS2CHGOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCNRTGUYTOMBVGU. You are receiving this because you were mentioned.Message ID: @.***>

salemh avatar Jun 14 '24 06:06 salemh

I also own such a BAF-908 watering can. Can wait Home Assistant to fully support this device? Thank You...

GitHubHAuser avatar Jun 22 '24 13:06 GitHubHAuser

Hello, I also have such a Watering Device and it would be great if it could work perfectly in Home Assistant. Thanks!

GitHubHAuser avatar Jul 13 '24 20:07 GitHubHAuser

Signing up for any future update :)

MD0005 avatar Jul 25 '24 22:07 MD0005

I just replaced the Tuya module in this pump to esp8266 and migrated to ESPHome)

ESP4Ever avatar Aug 01 '24 09:08 ESP4Ever

@ESP4Ever can you share details? wiring, esp home configuration, a guide :)

I have several devices on ESPhome, but was a bit reluctant on going that route...

malwikl avatar Aug 01 '24 10:08 malwikl

@ESP4Ever can you share details? wiring, esp home configuration, a guide :)

Please check my repository for details

ESP4Ever avatar Aug 01 '24 13:08 ESP4Ever

For anyone finding their way here, here is more info about the device and how I mapped everything:

Warning: the device will be identified as an thermostat because thats the category it reports to the Tuya integration (wk). This could be intentional or not, but it is a pain to deal with.

Code Type Values Information
switch Boolean "{true,false}" Controls wherever the device is on or off (not really turned off, but on a sleep state? the screen turns off, but the device receive commands from the app/cloud.)
mode Enum { "range": [ "auto", "manual" ] } This is the "Mode" attribute on the app. You can define if the device will be controlled by scheduled (automatic) actions or manual mode.
temp_set Integer { "unit": "s", "min": 0, "max": 360, "scale": 0, "step": 1 } ** Did not find information about it or a way to test it **
level Enum { "range": [ "PumpA", "PumpB", "PumpAB" ] } This is the "Pumps" attribute on the app. You can define which pumps will be activated when using the manual mode.
week_program4 Raw {} This is the "Program" attribute on the app. Here the original description for it: Each segment of timing can set the 1st and 2nd byte time, the 3rd and 4th byte temperature; 6 segments of timing; the default time is 06:00 20°C; 08:00 15°C; 11:30 15°C; 13: 30 15°C; 17:00 22°C; 22:00 15°C; each segment occupies 4 bytes. If the temperature contains decimal data, it must be expanded 10 times and transmitted. If it does not contain decimal data, it will be transmitted normally. 06:00 35.0 Then Pass 06 00 01 5e; 6*4*3=72 bytes
runtime Integer { "unit": "s", "min": 0, "max": 360, "scale": 0, "step": 1 } This is the "Runtime" attribute on the app. You can define manually for how much time the pump will work at any time.
sampling_time Integer { "unit": "h", "min": 0, "max": 60, "scale": 0, "step": 1 } This is the "Manual timing interval" attribute on the app.
ClockTime Integer { "unit": "s", "min": 0, "max": 360, "scale": 0, "step": 1 } This is the remaining seconds after the pump has started. This attribute is read-only.

This is how I configured it on HAOS

image

Filipe-Souza avatar Aug 14 '24 03:08 Filipe-Souza

@ESP4Ever can you share details? wiring, esp home configuration, a guide :)

Please check my repository for details

@ESP4Ever I cannot find the ESP code needed to drive the pumps in your repositories

efferre79 avatar Aug 22 '24 21:08 efferre79

Englisch: The device broke on me within two days, but perhaps you (the one who found the topic via Google) would like to test it further here. Personally, I would not recommend using this device as it is nothing more than a pump on a SmartPlug. It is easier to integrate a pump and a SmartPlug than this "complete solution".

To integrate the system:

  • Tuya developer account
  • An Android device near the pump -Internet connection

How to use With a developer account you can create virtual devices in tuya. These can be controlled in the app and via the Home Assistant just like real devices. These are placed in the tuya app in scenes with the corresponding switches on the irrigation system. It worked for 2 days before the device itself stopped working. I switched to the SmartPlug+Pump solution. Sometimes you have to cut out unnecessary technology to keep the system stable.

Deutsch: Das Gerät ist bei mir innerhalb von zwei Tagen kaputt gegangen, aber vielleicht möchtest du (derjenige, der das Thema über Google gefunden hat) hier weiter testen. Ich persönlich würde davon abraten, dieses Gerät zu verwenden, da es nichts anderes als eine Pumpe an einem SmartPlug ist. Es ist einfacher eine Pumpe und einen Smartplug zu integrieren als diese "Komplettlösung".

Um das System zu integrieren:

  • Tuya Entwickleraccount
  • Ein Android-Gerät in der Nähe der Pumpe -Internet

Wie Mit einem developer account kann man virtuelle Geräte in tuya erstellen. Diese sind wie echte Geräte in der App und über den Home Assistant steuerbar. Diese hinterlegt man in der tuya App in Szenen mit den entsprechenden Schaltern an der Bewässerung. Es hat zwei Tage gedauert, bis das Gerät seinen Dienst eingestellt hat. Ich bin auf die SmartPlug+Pumpe-Lösung umgestiegen. Manchmal muss man auf unnötige Technik verzichten, um das System stabil zu halten.

Sayashem avatar Aug 23 '24 12:08 Sayashem

If you have no concerns using Chinese cloud services you can follow the way above. My target is to rid off from any cloud services and do everything in an isolated network with VPN access. ;) For me this pump is not just a smart plug but of course everyone decides himself)

ESP4Ever avatar Aug 23 '24 12:08 ESP4Ever

@ESP4Ever I cannot find the ESP code needed to drive the pumps in your repositories

@efferre79 YAML configuration file for ESPhome is in this repo

ESP4Ever avatar Aug 23 '24 12:08 ESP4Ever

If you have no concerns using Chinese cloud services you can follow the way above. My target is to rid off from any cloud services and do everything in an isolated network with VPN access. ;) For me this pump is not just a smart plug but of course everyone decides himself)

If you have no concern paying 50 bucks for something and than paying again to get it working properly you are free to grab your soldering iron.

Everyone else should send it back and buy something else.

Sayashem avatar Aug 23 '24 12:08 Sayashem

For anyone finding their way here, here is more info about the device and how I mapped everything:

Warning: the device will be identified as an thermostat because thats the category it reports to the Tuya integration (wk). This could be intentional or not, but it is a pain to deal with. Code Type Values Information switch Boolean "{true,false}" Controls wherever the device is on or off (not really turned off, but on a sleep state? the screen turns off, but the device receive commands from the app/cloud.) mode Enum { "range": [ "auto", "manual" ] } This is the "Mode" attribute on the app. You can define if the device will be controlled by scheduled (automatic) actions or manual mode. temp_set Integer { "unit": "s", "min": 0, "max": 360, "scale": 0, "step": 1 } ** Did not find information about it or a way to test it ** level Enum { "range": [ "PumpA", "PumpB", "PumpAB" ] } This is the "Pumps" attribute on the app. You can define which pumps will be activated when using the manual mode. week_program4 Raw {} This is the "Program" attribute on the app. Here the original description for it: Each segment of timing can set the 1st and 2nd byte time, the 3rd and 4th byte temperature; 6 segments of timing; the default time is 06:00 20°C; 08:00 15°C; 11:30 15°C; 13: 30 15°C; 17:00 22°C; 22:00 15°C; each segment occupies 4 bytes. If the temperature contains decimal data, it must be expanded 10 times and transmitted. If it does not contain decimal data, it will be transmitted normally. 06:00 35.0 Then Pass 06 00 01 5e; 6*4*3=72 bytes runtime Integer { "unit": "s", "min": 0, "max": 360, "scale": 0, "step": 1 } This is the "Runtime" attribute on the app. You can define manually for how much time the pump will work at any time. sampling_time Integer { "unit": "h", "min": 0, "max": 60, "scale": 0, "step": 1 } This is the "Manual timing interval" attribute on the app. ClockTime Integer { "unit": "s", "min": 0, "max": 360, "scale": 0, "step": 1 } This is the remaining seconds after the pump has started. This attribute is read-only.

This is how I configured it on HAOS

image

Hi @Filipe-Souza the data point are correct but how is possible to use with the official Tuya integration in HomeAssistant ?

eneagiuseppe avatar Sep 16 '24 21:09 eneagiuseppe

@eneagiuseppe I did not use the official Tuya integration on this one, the real problems is the device itself. It reports as a 'wk' device category, and the Tuya official integration already mapped that to a thermostat (thats why @ninharp sees that screen).

So the options remaining are:

  • Use rospogrigio/localtuya and create a custom device as I did;
  • Find a way to identify and correct categorize this device even if it reports itself incorrectly on the Tuya official integration and convince the team that it should be implemented on the main source code;
  • Find a way to dump the firmware of the device (or ask the manufacturer for the firmware file), modify the firmware, flash that back to the device with the device category that corresponds with a "watering device" on Tuya API;

The second and third are valid but very unlikely to happen and required a lot of work and third party involvement

Filipe-Souza avatar Sep 18 '24 21:09 Filipe-Souza

I made meanwhile the same rework on the device like @ESP4Ever and replaced the wifi chip against a esp8266. Works like a charm now and i have finally my watering schedule in homeassistant

ninharp avatar Sep 18 '24 22:09 ninharp

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

definitely not stale, just forgotten, as anything from Tuya, I guess

igorsantos07 avatar Dec 20 '24 01:12 igorsantos07

Just to chime in that I've run into this as well. I tried building a custom integration that matches the "wk" tuya device category to the watering system controls, but it seems it's not quite as simple as doing that on the HA integration side. It looks like the Tuya API itself maps the device controls incorrectly due to the wrong device category, and returns only an on/off switch, mode selector and temp_set number entity by default. I also see this in the Tuya developer console. In the console, there is a way to switch the device from "standard instructions" to "DP instructions", which exposes the raw DPs from the device and allows full control. But from a quick look I don't see an obvious way to do that in the tuya-device-sharing-sdk python package that the HA Tuya integration uses. If anyone knows how to do that let me know, and I think we could have a custom integration for this pretty easily.

mgerstgrasser avatar Mar 09 '25 21:03 mgerstgrasser

I tried adding the device using localtuya. The connection succeeds, but adding the DPS values 1,56,101,28,2,102 manually, they all just come up as unavailable. Could someone be arsed to give an ELI5 of the process?

NCLI avatar Apr 07 '25 08:04 NCLI

I was planning to pick this up today and integrate it into tuya-local, but after testing again with version 2025.5.1, everything seems to be working now. I can start the pumps, set a timer, switch between pumps, configure intervals, change the mode, and receive the remaining pumping time as expected.

fabiang avatar Jun 01 '25 09:06 fabiang

can anyone provide a good quality picture of the tuyaMCU (the central chip on the top face of the PCB)? My hardware (2024 batch) doesn't have any part number written on it.

efferre79 avatar Jun 14 '25 14:06 efferre79

Try this integration instead of tuya, localtuya or localtuya fork: https://github.com/make-all/tuya-local/ This watering device is discovered correctly and working good. Without manually defining all the metrics/switches whatnot. Only problem is to get local key, which can be obtained either with api or through tinytuya

librarian avatar Jul 11 '25 17:07 librarian

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.