tuya / tuya-home-assistant

Home Assistant integration for controlling Powered by Tuya (PBT) devices using Tuya Open API, maintained by the Home Assistant Community and Tuya Developer Team.
MIT License
875 stars 206 forks source link

Ultrasonic level sensor #946

Open Daz42 opened 1 year ago

Daz42 commented 1 year ago

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 commented 1 year ago

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

superarturo15 commented 1 year ago

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 commented 11 months ago

Same here. Any way to get it working?

Daz42 commented 11 months ago

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 commented 11 months ago

image

nisu66 commented 11 months ago

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 commented 11 months ago

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 commented 11 months ago

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 commented 11 months ago

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 commented 11 months ago

No problem. Are you getting your level readings now?

nisu66 commented 11 months ago

Yessssss

Inviato da Yahoo Mail su Android

Il mer, 1 nov, 2023 alle 17:39, @.***> ha scritto:

No problem. Are you getting your level readings now?

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.Message ID: @.***>

Daz42 commented 11 months ago

Excellent, well done!

Pante90 commented 9 months ago

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 commented 9 months ago

@pante90 use localtuya.

Inviato da Yahoo Mail su Android

Il lun, 11 dic, 2023 alle 20:21, @.***> ha scritto:

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?

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.Message ID: @.***>

Zwoet commented 9 months ago

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 commented 9 months ago

Up until a month ago everything was working fine.  Then suddenly the sensors disappeared and I have the usual errors.  I tried both localtuya and tuyalocal.  I don't know what could have happened.  Anyone in your situation?

Inviato da Yahoo Mail su Android

Il Mer, 3 Gen, 2024 alle 16:25, @.***> ha scritto:

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.PNG (view on web)

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.Message ID: @.***>

Zwoet commented 9 months ago

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 commented 9 months ago

no way. I followed your directions but it doesn't work for me. I also tried changing the values because I don't have dip 20, but the result doesn't change.

Inviato da Yahoo Mail su Android

Il Mer, 3 Gen, 2024 alle 19:20, @.***> ha scritto:

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.png (view on web) Added 22,21,23 (just added these to see what happened)

image.png (view on web)

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.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.Message ID: @.***>

Zwoet commented 9 months ago

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

nisu66 commented 9 months ago

Yes. The ip address Is static and correct. In the app (smart life) it s all right.And other device it s ok in local tuya

Inviato da Yahoo Mail su Android

Il Gio, 4 Gen, 2024 alle 9:22, @.***> ha scritto:

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

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.Message ID: @.***>

Zwoet commented 9 months ago

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 commented 9 months ago

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

Zwoet commented 9 months ago

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 commented 9 months ago

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 commented 9 months ago

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 commented 9 months ago

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 commented 9 months ago

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 commented 9 months ago

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 commented 8 months ago

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 commented 8 months ago

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 commented 8 months ago

but do you think it would be possible to program it with esphome?

rvdlinden commented 8 months ago

I just added my device to my router with a static ip-address and localtuya found it right away.

I added all the id's (not just 22) as sensors. For 22 I added it as follows

FriendlyName : kruipruimte percentage UnitOfMeasurement : % DeviceClass : Enum ScalingFactor :

So far it works, but only I'm on day 1 ;)

Screenshot_20240116_145405_Home Assistant

Screenshot_20240116_150111_Home Assistant

Zwoet commented 8 months ago

Yes I did the same, the Local Tuya App finds the device, so don't thank there is an issue. But that looks pretty promising, and by all you mean 1 to 22 ? Or how did you now what to add in order to get the right info ? Tried finding this info in the log files from iot.tuya.

Zwoet commented 8 months ago

Whatever number I use I just get: Not all required fields are filled in.

image

rvdlinden commented 8 months ago

Local Tuya presented me automatically the other options when editing a device.

Screenshot_20240116_185031_Home Assistant

I did read on the website that never versions of the hardware would go up to 3.0m instead of 2.5m. Maybe there is a version diff ?

I can't find a hardware version anywhere, but on the tuya iot site the device is called EPT- Ultrasonic sensor 3m

Zwoet commented 8 months ago

okay no I don't got these options. I found out I just can't change device, but another, then give in a new numer. Like 19 and then add it as a sensor. Buttt... no data. But this does accept the entry.

Also checked the Tuya app if there is a firmware update, but nothing.

rvdlinden commented 8 months ago

Screenshot_20240116_185503_Smart Life

nisu66 commented 8 months ago

HI I don't know if this can help anyone. After it stopped working in local tuya I restored as follows. Since my level tank and other devices in the garden were far from the main router to get the wifi signal I had installed a repeater. I realized that this repeater created a single network of both 2.4 and 5 with the same SSDI name. I therefore thought that the problem was this, that is, that the device was not reachable due to the presence of the 2 networks. I then divided the 2 networks 2.4 and 5 with 2 different names. I configured the level tank again. removed localtuya restarted installed localtuya again. I configured localtuya again. At this point I searched for the device and added it again (be careful that both the device ID and local key change). And magic magic I have all the sensors again :-)

nisu66 commented 8 months ago

Screenshot_20240116_185503_Smart Life

i have main module V2.0.2 MCU module V2.3.0

Zwoet commented 8 months ago

Thanks for sharing your solution. I already got an IoT-wifi SSID with only 2.4ghz since most only work on that range. Main module seems the same, only has a different MCU module...

image

Wel mooi dat we allemaal in het engels praten met elkaar.

rvdlinden commented 8 months ago

Just lost half of my devices ;(

Screenshot_20240119_133242_Home Assistant

The 3 most important ones are still working, but I can't get the others back.

I haven't completely wiped local tuya to see if that would help, but even if it would, it's not a real solution either

Zwoet commented 8 months ago

mmmh at least you got the water level in cm height. I think I will order the zigbee version to see if that works any better.

rvdlinden commented 8 months ago

I hope to get the ZB version in 2 weeks :)

Zwoet commented 8 months ago

Maybe I will wait for your experience before the ZB version is somehow also not supported by HA. Whaha. Hope that will just show up as any other ZB device. Please let me know.

superarturo15 commented 8 months ago

Is there any possibility of being integrated into the official site of HA this kind of sensor ?, sorry for my ignorance, I am just starting with this magnificent central smart home controller.

Zwoet commented 8 months ago

Devices that aren't zigbee, but WiFi or Bluetooth usually go through an integration. But the official Tuya integration does not support this WiFi water level meter. Don't know why or if it will become supported in the future.

The official Tuya just says "not supported" and no entities available. :(

image

superarturo15 commented 8 months ago

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

nisu66 commented 8 months ago

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 commented 8 months ago

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 commented 8 months ago

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 ?