xZetsubou / hass-localtuya

🔹 A Home Assistant integration to handle Tuya devices locally "fork from localtuya"
https://xzetsubou.github.io/hass-localtuya/
GNU General Public License v3.0
297 stars 30 forks source link

Low-power temperature and humidity sensors providing iffy values #183

Closed infinitytec closed 1 month ago

infinitytec commented 3 months ago

The problem

I have several cheap WiFi temperature and humidity sensors. I have looked at the details in #139 which has been somewhat helpful.

I configured the devices in the Tuya app and grabbed their IDs and keys.

Curiously, the devices seem to report best when: 1) The subnet is allowed Internet access 2) The Tuya app is also in use

All of my sensors connect to the wireless network and report values to the app, and I have been able to get data from two of the three into HA.

But, it seems that when I block the Internet from the VLAN I get some rather... interesting values: image

Some of these readings are clearly good, but others make me worry I am living on the surface of the sun!

I am trying to tune the sleep time, but I see that it might not work as the integration is not discovering the entities so I have to provide them manually.

Environment

DP dump

"properties": [ { "code": "temp_current", "custom_name": "", "dp_id": 1, "time": 1711239247107, "value": 265 }, { "code": "humidity_value", "custom_name": "", "dp_id": 2, "time": 1711239247107, "value": 42 }, { "code": "battery_percentage", "custom_name": "", "dp_id": 4, "time": 1711239149706, "value": 82 }, { "code": "temp_unit_convert", "custom_name": "", "dp_id": 9, "time": 1711233828963, "value": "f" }, { "code": "maxtemp_set", "custom_name": "", "dp_id": 10, "time": 1711233828963, "value": 600 }, { "code": "minitemp_set", "custom_name": "", "dp_id": 11, "time": 1711233828963, "value": -200 }, { "code": "maxhum_set", "custom_name": "", "dp_id": 12, "time": 1711233828963, "value": 100 }, { "code": "minihum_set", "custom_name": "", "dp_id": 13, "time": 1711233828963, "value": 0 }, { "code": "temp_alarm", "custom_name": "", "dp_id": 14, "time": 1711233828963, "value": "cancel" }, { "code": "hum_alarm", "custom_name": "", "dp_id": 15, "time": 1711233828963, "value": "cancel" }, { "code": "temp_sensitivity", "custom_name": "", "dp_id": 19, "time": 1711233828963, "value": 4 }, { "code": "hum_sensitivity", "custom_name": "", "dp_id": 20, "time": 1711239244812, "value": 3 } ] },

Additional information

It almost works!

xZetsubou commented 3 months ago

If you have "cloud" setup integration will shows all the DPS as cloud pull if the device is sleep however you will need to insert "0" in manual DPS

0 In manual dps means ignore the handshake we do with device which is "waiting for return states from devices." so if you are sure you inserted the correct protocol_version and local_key then go ahead with this method other than that there is no way to get the status from a sleep device, sometime low-power devices disconnect from your network when it goes into sleep so not sure. for me even tho my low-power device has a config timer of when to report I always set the sleep time +900secs just in-case.

I really not sure what happen to your device you u block internet access from Tuya devices it started to do toxic behavior, at this point not sure if there's much to here I haven't tried this setup before but if your devices are taking the commands and works then this is good.

you can also monitor your device it may give us a hint using the events Developer tools -> Events -> Listen to one of these. localtuya_device_dp_triggered or localtuya_states_update

infinitytec commented 3 months ago

If you have "cloud" setup integration will shows all the DPS as cloud pull if the device is sleep however you will need to insert "0" in manual DPS

0 In manual dps means ignore the handshake we do with device which is "waiting for return states from devices." so if you are sure you inserted the correct protocol_version and local_key then go ahead with this method other than that there is no way to get the status from a sleep device, sometime low-power devices disconnect from your network when it goes into sleep so not sure. for me even tho my low-power device has a config timer of when to report I always set the sleep time +900secs just in-case.

I really not sure what happen to your device you u block internet access from Tuya devices it started to do toxic behavior, at this point not sure if there's much to here I haven't tried this setup before but if your devices are taking the commands and works then this is good.

you can also monitor your device it may give us a hint using the events Developer tools -> Events -> Listen to one of these. localtuya_device_dp_triggered or localtuya_states_update

I'll take a look at these. Busy week coming up so probably won't follow up for a few days.

infinitytec commented 3 months ago

Just wanted to give an update-- I updated to 3.2.5.1 and things are a lot better. Devices seem to be staying connected much more reliably and continuing to give values. However, the issue with the bad data continues.

Curiously, it seems that the bad data may be limited only to temperature, as humidity seems reliable: image

xZetsubou commented 3 months ago

Can you share the device diagnostic you can download it from the device page in HA

github-actions[bot] commented 2 months ago

This issue is stale because it has been open 14 days with no activity. Remove stale label or comment or this will be closed in 5 days.

infinitytec commented 2 months ago

Can you share the device diagnostic you can download it from the device page in HA

Apologies for the delay; see attached. localtuya-e78a9f4dbabc8041c15520fa17be3ae1-TH-03-56f187e402d8f75d8cf1cec2d9f4aa09(2).json

xZetsubou commented 2 months ago

The device cloud data is missing. however I would recommended you to re-add the device.

infinitytec commented 2 months ago

The device cloud data is missing. however I would recommended you to re-add the device.

* Don't set any scan interval.

* Manual DPS don't set values that may interrupt the device. just put `0` is enough.

* Device sleep time is good if it's for your needs. `it will wait 5 days with you're timer before it considered "offline" 😸 `

* Lastly update to the latest beta release. from HACS check on beta releases and use the latest as it has changes to low-power devices.

I got on the latest beta release.

On trying to re-add a device without specifying the entities I get this: image

xZetsubou commented 2 months ago

This is different issue, the device doesn't seems exists on your cloud data you can download your entry diagnostics and ensure the cloud data does exists inside it.

github-actions[bot] commented 2 months ago

This issue is stale because it has been open 14 days with no activity. Remove stale label or comment or this will be closed in 5 days.

Maxxxel commented 2 months ago

I also have a low power temperature/humidity WLAN sensor. It only provides data every few hours out of random or when I edit the device. What else can I do, I'm running v5.2.1

xZetsubou commented 2 months ago

@Maxxxel Assign device sleep time 1 day, 86400

Maxxxel commented 2 months ago

@Maxxxel Assign device sleep time 1 day, 86400

Where do I set that? And why do I get almost live values in Smart Life?

I can force updates every time when I edit the device, change nothing and save.Screenshot_20240509_012051_Home Assistant.jpg

This is how it looks

xZetsubou commented 2 months ago

This doesn't looks localtuya of this fork, try refreshing the page or remove page cookies cache or try computer browser the "sleep time" should be under DPIDs field.

And why do I get almost live values in Smart Life?

I have seen this before it probably the type of devices that it will update live only if you opened "the app" so technically it only update live if the app is opened even if you opened IoT you won't see it updating, it probably another toxic behavior from Tuya device on local.

edit: If there's any question or this confirmed as an issue feel free to comment or re-open this.