Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ultrasonic level sensor #946

Open
Daz42 opened this issue Aug 25, 2023 · 76 comments · May be fixed by home-assistant/core#114481
Open

Ultrasonic level sensor #946

Daz42 opened this issue Aug 25, 2023 · 76 comments · May be fixed by home-assistant/core#114481

Comments

@Daz42
Copy link

Daz42 commented Aug 25, 2023

Hello, I have two Ultrasonic level sensor by Tuya, they are not in the supported list but would love to see this integrated with Home Assistant and will do whatever I need to help this. Can anyone help?

@formiification
Copy link

I also would be more then happy if it could be integrated to HA

@superarturo15
Copy link

I have just the same problem, I would like to integrate Tuya sensor level into HA, but it seems not to be possible yet.

@Kevin4999
Copy link

Same here. Any way to get it working?

@Daz42
Copy link
Author

Daz42 commented Oct 19, 2023

Hello. I recently resolved this. Happy to share my solution and give back to the community.

Note: I am using the Tuya Smart TLS-2206 UltraSonic Wireless Sensor. This was sourced from Alibaba and is being used in an IBC water tank for rainwater harvesting.

Firstly you need to use the Tuya Local HACs integration. Follow the guide to integrate your devices using the Cloud API method to find the Tuya device's Key and ID.

https://github.com/codetheweb/tuyapi/blob/master/docs/SETUP.md

You will need to reserve IP addresses for your devices on your router (or whatever DHCP service you are using).

Once you have the device's Key and ID, add them into the Local Tuya integration where you will be asked for the device's IP address and local key. The default protocol is 3.3 which is correct.

The trick to getting the sensors needed to show the water level percentage:

Configure the integration and you will be offered an option to edit the device. Choose edit the device and select the device you want to add the sensors to.

The goal is to add the sensor that reports on the water level percentage. When editing the device, scroll down and select 'Add more entities in edit device mode'. Select sensor as the entity type then select '22' and give it a friendly name. This will add the required sensor.

This has worked well for me and now I can use the percentage to use in a Gauge card and also to read the percentage to turn the pump off when the level goes below 10% to prevent running the pump dry. Works very well. The readings get jumpy below 10% and above 95% but you can adjust your automations to get a reliable reading by using a time condition (must be below 10% for an hour for example).

I hope this helps someone.

@Daz42
Copy link
Author

Daz42 commented Oct 19, 2023

image

@nisu66
Copy link

nisu66 commented Nov 1, 2023

Hello. I recently resolved this. Happy to share my solution and give back to the community.

Note: I am using the Tuya Smart TLS-2206 UltraSonic Wireless Sensor. This was sourced from Alibaba and is being used in an IBC water tank for rainwater harvesting.

Firstly you need to use the Tuya Local HACs integration. Follow the guide to integrate your devices using the Cloud API method to find the Tuya device's Key and ID.

https://github.com/codetheweb/tuyapi/blob/master/docs/SETUP.md

You will need to reserve IP addresses for your devices on your router (or whatever DHCP service you are using).

Once you have the device's Key and ID, add them into the Local Tuya integration where you will be asked for the device's IP address and local key. The default protocol is 3.3 which is correct.

The trick to getting the sensors needed to show the water level percentage:

Configure the integration and you will be offered an option to edit the device. Choose edit the device and select the device you want to add the sensors to.

The goal is to add the sensor that reports on the water level percentage. When editing the device, scroll down and select 'Add more entities in edit device mode'. Select sensor as the entity type then select '22' and give it a friendly name. This will add the required sensor.

This has worked well for me and now I can use the percentage to use in a Gauge card and also to read the percentage to turn the pump off when the level goes below 10% to prevent running the pump dry. Works very well. The readings get jumpy below 10% and above 95% but you can adjust your automations to get a reliable reading by using a time condition (must be below 10% for an hour for example).

I hope this helps someone.

Hi, I'm following the guide through the link you posted. I've done everything but I'm stuck on points 6 and 7!!!! What do you mean by "Put your devices into linking mode"? and in point 7 "on the command line....." where exactly? Sorry for my ignorance

@Daz42
Copy link
Author

Daz42 commented Nov 1, 2023

Hello nisu66 - the documentation under https://github.com/codetheweb/tuyapi/blob/master/docs/SETUP.md is not mine but my advice assumes you could follow it.

In terms of linking, once you have your developer account setup and have created your project you then need to link it with your devices (make sure that you have already set them up in your Tuya Smart Life App).

TuyaLink

@Daz42
Copy link
Author

Daz42 commented Nov 1, 2023

I don't know about linking mode or the command line as I think all I had to do here was create the developer account, link my account and the devices showed up that I had added in the IOS Tuya Smart Life app. Once this was done, add the Tuya Local Integration through HACs - when you add your developer account the devices will import.

@nisu66
Copy link

nisu66 commented Nov 1, 2023

I don't know about linking mode or the command line as I think all I had to do here was create the developer account, link my account and the devices showed up that I had added in the IOS Tuya Smart Life app. Once this was done, add the Tuya Local Integration through HACs - when you add your developer account the devices will import.

thanks, in the end I searched a bit here and there I managed to integrate the level sector. Thanks to you who gave me the correct inspiration

@Daz42
Copy link
Author

Daz42 commented Nov 1, 2023

No problem. Are you getting your level readings now?

@nisu66
Copy link

nisu66 commented Nov 1, 2023 via email

@Daz42
Copy link
Author

Daz42 commented Nov 1, 2023

Excellent, well done!

@Pante90
Copy link

Pante90 commented Dec 11, 2023

Hello, i want to ask something about this. I follow this instruction but i can't see anything about this sensor. The integration say me that the sensor is unsupported, but when i downloaded a diagnostik file, compare a value and a voice about the sensor. and also i can see a value on denvelopment site about tuja. what i can do for see a value on my home assitant?

@nisu66
Copy link

nisu66 commented Dec 11, 2023 via email

@Zwoet
Copy link

Zwoet commented Jan 3, 2024

Hi there, I wanted to add the tank level into Home Assistant too. When I add the device it is found by Local Tuya integration.
However when adding I got an error: "An unknown error occurred. See log for details."

But I can't find anylog file for more info.

When I add it manually and put in the IP/deviceID/secret key it give the following error:
"Connection to device succeeded but no datapoints found, please try again. Create a new issue and include debug logs if problem persists."

Does anyone got this error and found a solution ?

Thanks in advance.

Waterlevelmeter3

@nisu66
Copy link

nisu66 commented Jan 3, 2024 via email

@Zwoet
Copy link

Zwoet commented Jan 3, 2024

I got it working. I added the 22 and then it added a sensor but no data. Then I thought let's see what happens a few numbers more.

image
Added 22,21,23 (just added these to see what happened)

image

The data I get to HA is the same I see in the Tuya app.
The device is just laying on my desk so the numbers are not real. But they match the app so should be good to go.

@nisu66
Copy link

nisu66 commented Jan 3, 2024 via email

@Zwoet
Copy link

Zwoet commented Jan 4, 2024

okay that's strange, but HA adds the meter with the right local IP address etc ? Just no data ?

@nisu66
Copy link

nisu66 commented Jan 4, 2024 via email

@Zwoet
Copy link

Zwoet commented Jan 5, 2024

okay so it stopped working... :( I got fluctuating data dat matched the Tuya app, checked and tested a few times to be sure it was okay, and since yesterday i just get constant "100cm" data feed.
Resetted the device, nothing changes. No idea why I got data and why it suddenly stopped without changing anything.

image

@rvdlinden
Copy link

I order the same 2206 but it's zigbee. Would that be working at all with HA?

@Zwoet
Copy link

Zwoet commented Jan 7, 2024

Is there a Zigbee version ? I searched for a ZB version before buying the WiFi version but I couldn't find it anywhere.
Please let me know where you bought it and if the data is shown in HA once you recieved it. I will change mine for a ZB version if that works.

@rvdlinden
Copy link

Just found this amazing item on AliExpress. Check it out! €57,93 | EPTTECH TLC2206-ZB ZigBee APP Tank level Monitor WiFi Real-time Reminder Contactless Waterproof IP67 Household Industrial Alarm
https://a.aliexpress.com/_EQUPBKV

@rvdlinden
Copy link

I canceled the ZB version and replaced it with the Wifi version so I can add it directly into Smart Life. My whole network is zigbee based so maybe when its supported by HA, I will replace the wifi one with Zigbee.

@Zwoet
Copy link

Zwoet commented Jan 9, 2024

You canceled the wifi version you mean ? Please let me know how it adds. If it works in HA I will get one too. The data never got back in HA after working for a few days.

@rvdlinden
Copy link

Noop, I canceled the ZB one as wifi seems to be widely in use. I'd love to play with the newest tools but for this sensor I just need it to work.

Maybe I'll buy both of them but first have to see if this sensor fits my use case (monitor of the water in my crawl space under the house)

@Zwoet
Copy link

Zwoet commented Jan 9, 2024

Using it for exactly that reason at this very moment. I just can't get the data in HA anymore. The first days it was working, than out of nowhere just gives me 100 as static data feed. Resetted the meter but no luck, also removed the device from HA. Re-added it, but still nothing.

I think zigbee directly connected to HA cuts out the Tuya as the data provider.

With the WiFi version must be added through an integration.
The official Tuya integration says the device is not supported.

image

And the localTuya hacs integration doesn't seem to work at all. :(

@rvdlinden
Copy link

I got the wifi based device and connected it to the Smart Life app and also configured local tuya in Home Assistant. For now it works fine, so I hope it will not stop later.

FYI, I also ordered the Zigbee device as I'm curious if this works better :) Maybe I can play with it in a week or two.

@Zwoet
Copy link

Zwoet commented Jan 16, 2024

okay with adding the 22 manually as described above ? Wonder if it keeps working for you, i got data for about 3-4 days and then it just keeps giving "100" Can you perhaps screenshot your settings in the Tuya local device ? (not the keys off course but how you added the sensor)

I removed and re-added the device with different settings, but without any luck.
Thought of buying the zigbee version, just hoped to find a solution for the WiFi version so I don't need to replace the device down in the crawl space whaha.

@nisu66
Copy link

nisu66 commented Jan 22, 2024

ok, Zwoet, thanks for the info. As I see, there are many people waiting for the integration.

but with localtuya it's integrated :-)
Screenshot 2024-01-22 152124

@superarturo15
Copy link

but with localtuya it's integrated :-)

I couldn't because it asks me for a *Name and *Local Key, and I am not able to find any of these.

@Zwoet
Copy link

Zwoet commented Jan 23, 2024

ok, Zwoet, thanks for the info. As I see, there are many people waiting for the integration.

but with localtuya it's integrated :-) Screenshot 2024-01-22 152124

Yeah well not with the version I got. :( I just got it in a few weeks ago, maybe it's a newer version since the MCU version is different that mine doesn't work !? No idea, for now I gave up on the WiFi version and will buy Zigbee version if rvdlinden got it working.

Good for you that you got data from the device now! Did you add the sensors by manually defining them with the numberd ?

@rvdlinden
Copy link

Just received the ZB version and by default it's absolutely unsupported and doesn't expose anything.

const definition = {
zigbeeModel: ['TS0601'],
model: 'TS0601',
vendor: '_TZE200_lvkk0hdg',
description: 'Automatically generated definition',
extend: [],
};

module.exports = definition;

I have never had an unsupported device, but I think I have to build a external definition as described on https://www.zigbee2mqtt.io/advanced/support-new-devices/01_support_new_devices.html?

@Zwoet
Copy link

Zwoet commented Jan 24, 2024

That's a bummer. Doesn't seem like something that is done easy. I used MQTT over eBus to connect to my WTW installation and that was a lot of work to get it working.

But if HA doesn't support it, then what app is it supposed to connect to over zigbee?

@rvdlinden
Copy link

Any zigbee or multi mode hub should work says the tiny doc. I'll connect it to a tuya hub to see what that would provide. I should have a Moes ble/zigbee somewhere

@rvdlinden
Copy link

Due to the wifi based tlc2206 I already have, I just assumed the config of the wifi device isn't any different from the zigbee version.

So currently I'm adding the same data points as the ones that were exposed on the localtuya, and there seems to be some progress here.

Screenshot_20240124_235504_Home Assistant

I will continue with it and see how far I get as the current values are the read only ones, but I would also like to see how I can actually set threshold via HA

@rvdlinden
Copy link

Screenshot_20240125_001736_Home Assistant

not sure how it is possible, but the data points I lost on the wifi device do also not seem to be present on the zigbee device (7,8, 19 and 21) either.

Any ideas on how to discover all data points, especially the ones that could be set, are welcome

@Zwoet
Copy link

Zwoet commented Jan 25, 2024

You got the a few working ? Can you share how you did this ?
Pretty wierd the other sensors aren't giving any data.

@rvdlinden
Copy link

rvdlinden commented Jan 25, 2024

I have tried to get the device working with all 7 sensors, but the Wifi as well as the Zigbee device report all the DP ID's but I'm not able to do anything with 4 of them. Due to this, the Zigbee device can't be configured while the Wifi device via LocalTuya is usable as the config is done via the Smart Life app

To get is semi working, I did this ...

For the Zigbee device, I created a local file config/zigbee2mqtt/TLC2206ZB.js which is in the same directory as the configuration.yaml. The attached .txt is the file and just needs to be renamed from .txt to .js before usage.

TLC2206ZB.txt

In HA within Zigbee2MQTT under Settings => External Converters, the filename TLC2206ZB.js needs to be added and than restart the service. This will make the discovered TS0601 unsupported device change to TS0601_tlc2206zb and should reveal the 3 exposed and working data points.

In the .js file I documented all the DP ID's I found using the Tuya IOT website when the device was connected via a BLE/Zigbee hub. Also the ones that fail are in there as comments for reference.

The reported data points were:
{"1":"Liquid level status","2":"Liquid level depth","7":"Set Max","8":"Set Mini","19":"Installation height","21":"Sensor to full line","22":"Liquid level ratio"}

I did see also something weird with the 'Sensor to full line' on the Zigbee. This value doesn't seem to be used at all as there was no affect on the percentage (DPID 22) when it was changed. This same field does work on the Wifi device and does affect the percentage when the liquid level reaches the threshold.

I lack the experience to take this to the next level, and neither do a see a reason to request this new device to be added to Zigbee2MQTT. Without the fields to define the Installation Height and the Sensor to full line, it just reports default depth and percentage based on the hardware default height (1m).

Just for reference, I used these docs to get this .js file as far as could get it

  1. https://www.zigbee2mqtt.io/advanced/support-new-devices/02_support_new_tuya_devices.html
  2. https://www.zigbee2mqtt.io/advanced/support-new-devices/03_find_tuya_data_points.html

@rvdlinden
Copy link

Reported the Zigbee device as in issue here Koenkk/zigbee2mqtt#21015

@Zwoet
Copy link

Zwoet commented Jan 26, 2024

Thanks for all the info. I think you have done a great job coming this far. The data I care most about is the water height to monitor and log. So it seems like you got that working. My WiFi version still doesn't work so I will order the Zigbee version.

@rvdlinden
Copy link

Maybe I found a solution for the Wifi based device when some or all data points are gone or provide no data.

I cleaned HA by removing the wifi tank sensor and also localtuya. Rebooted HA to have a clean slate.

On the Tuya IOT website I changed the device from the Standard to the DP instruction set.

Screenshot_20240126_131922_Chrome

Went back to configure localtuya and the auto discovered wifi sensor. This time all 7 data points were presented again and I added 1,2,22 as a sensor and 7,8,19,21 as number.

Screenshot_20240126_131435_Home Assistant

I do not just see the data points and their value, but I can change them to configure the device too. All changes in HA are reflected on Tuya IOT website too.

Not sure if the DP instruction made the diff, but I have started over from scratch before and never had a positive result.

@rvdlinden
Copy link

Hover over the device box on the Tuya website and it will show a blue button. That will present you the Standard/DP page as shown in the previous post

Screenshot_20240126_134818_Chrome

@rvdlinden
Copy link

The zigbee based device is not fully working via Zigbee2mqtt but when the zigbee device is connected to a tuya zigbee gateway, it can be identically configured as the wifi based device via the Local Tuya integration (there is a fork that supports zigbee hubs and zigbee sub devices)

Screenshot_20240127_012736_Home Assistant

@Zwoet
Copy link

Zwoet commented Jan 28, 2024

Thanks for all the details on how you accomplished to get the data to HA.

I removed devices and Tuyalocal integration, changed the settings from device to DP instructed.
image

Installed the LocalTuya again but still no luck. No auto discovery of the data points. And added 2 for waterheigt to test manually but just says "Unavailable".

@rvdlinden
Copy link

Maybe it's a different hardware version you have

My wifi device shows as
EPT- Ultrasonic sensor 3m

and the zigbee device as
EPT- Ultrasonic sensor Z

@Zwoet
Copy link

Zwoet commented Jan 28, 2024

Only "Ultrasonic level sensor" mine says in Tuya IoT environment.
It also shows data in the logs.

image

Also tried adding sensors with these names, but that wasn't possible. Thought it was worth a shot whaha

image

@superarturo15
Copy link

As far as I know, in the coming days, it will be an update of HA that contains a new way to connect tuya to homeassistant, easier and without the necessity of dealing with a developers tuya account. Maybe the problem with the ultrasonic sensor is mended.

@nisu66
Copy link

nisu66 commented Feb 7, 2024

As far as I know, in the coming days, it will be an update of HA that contains a new way to connect tuya to homeassistant, easier and without the necessity of dealing with a developers tuya account. Maybe the problem with the ultrasonic sensor is mended.

I don't dislike it. At least not in the beta version of HA (2024.2b9) which I already have and has the new tuya configuration system, much more streamlined and less complicated. The problem remains the device, which is not compatible. With localtuya however it works perfectly. At the beginning I also had problems, which I discovered were due to the mesh repeater I had in the garden to be able to reach the tank sensor. It basically combined the two channels at 2.4 and 5 with the usual name, and evidently created conflicts. I separated the 2 lines and activated only channel 2.4 for that repeater and I solved the problem

@Zwoet
Copy link

Zwoet commented Feb 12, 2024

I have tried to get the device working with all 7 sensors, but the Wifi as well as the Zigbee device report all the DP ID's but I'm not able to do anything with 4 of them. Due to this, the Zigbee device can't be configured while the Wifi device via LocalTuya is usable as the config is done via the Smart Life app

To get is semi working, I did this ...

For the Zigbee device, I created a local file config/zigbee2mqtt/TLC2206ZB.js which is in the same directory as the configuration.yaml. The attached .txt is the file and just needs to be renamed from .txt to .js before usage.

TLC2206ZB.txt

In HA within Zigbee2MQTT under Settings => External Converters, the filename TLC2206ZB.js needs to be added and than restart the service. This will make the discovered TS0601 unsupported device change to TS0601_tlc2206zb and should reveal the 3 exposed and working data points.

In the .js file I documented all the DP ID's I found using the Tuya IOT website when the device was connected via a BLE/Zigbee hub. Also the ones that fail are in there as comments for reference.

The reported data points were: {"1":"Liquid level status","2":"Liquid level depth","7":"Set Max","8":"Set Mini","19":"Installation height","21":"Sensor to full line","22":"Liquid level ratio"}

I did see also something weird with the 'Sensor to full line' on the Zigbee. This value doesn't seem to be used at all as there was no affect on the percentage (DPID 22) when it was changed. This same field does work on the Wifi device and does affect the percentage when the liquid level reaches the threshold.

I lack the experience to take this to the next level, and neither do a see a reason to request this new device to be added to Zigbee2MQTT. Without the fields to define the Installation Height and the Sensor to full line, it just reports default depth and percentage based on the hardware default height (1m).

Just for reference, I used these docs to get this .js file as far as could get it

  1. https://www.zigbee2mqtt.io/advanced/support-new-devices/02_support_new_tuya_devices.html
  2. https://www.zigbee2mqtt.io/advanced/support-new-devices/03_find_tuya_data_points.html

Was wondering if the zigbee version still working stable ?

@rvdlinden
Copy link

In HA the Wifi lost again the configurable items, but so far Zigbee still works (via local tuya fork and tuya zigbee gateway)

@nisu66
Copy link

nisu66 commented Feb 18, 2024

make-all/tuya-local#1653
localtuya has been updated and now also includes Ept water tank level 3 Mt.

@Zwoet
Copy link

Zwoet commented Feb 21, 2024

Still no luck with the version I got. Removed and reinstalled the Tuya integration but still the same result.

@Pro
Copy link

Pro commented Mar 30, 2024

The MR here should add support for the tank level sensor:
home-assistant/core#114481

@Zwoet
Copy link

Zwoet commented Apr 2, 2024

Thanks for all the work and message, I checked but I see no update for the integration ? Still no luck when trying to add the sensor. Or do I need to take some additionals steps ? I checked the link you send but I can't seem to find anything.

image

@ocigam69
Copy link

Hello, any new for zigbee version?

@hanselv874
Copy link

image

Thanks @Daz42, this method worked for me! I extrapolated to other 2 valve actuators (https://www.amazon.com/Automatic-Control-Electric-Shutoff-Compatible/dp/B0CB3NZH19) which I could only manage through the tuya app and it worked as well:
image

Thanks again!!

@Daz42
Copy link
Author

Daz42 commented Apr 24, 2024

image

Thanks @Daz42, this method worked for me! I extrapolated to other 2 valve actuators (https://www.amazon.com/Automatic-Control-Electric-Shutoff-Compatible/dp/B0CB3NZH19) which I could only manage through the tuya app and it worked as well: image

Thanks again!!

No problem, glad my solution has worked for you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.