Closed leto78 closed 1 month ago
Same issue, love to see this solved.
I am going to set this issue as closed. The battery is not integrated, but at least you can get the temperature and humidity data working.
I added the following entries to the sensors.yaml
.
- platform: template
mytemperature:
unit_of_measurement: "\u00b0C"
device_class: temperature
friendly_name: MyTemperature
unique_id: add280c3-d8bf-437d-93b5-b1b689c115de
icon_template: >
mdi:thermometer
value_template: >
{% set sensorstatus = states('sensor.temperature', 'raw_state') %}
{% if sensorstatus != 'unavailable' %}
{% set valuetokeep = sensorstatus %}
{{ states('sensor.temperature', 'raw_state') | float }}
{% else %}
valuetokeep
{% endif %}
myhumidity:
unit_of_measurement: "%"
device_class: humidity
friendly_name: MyHumidity
unique_id: a88ac767-1881-42c5-bd6d-4c239361f933
icon_template: >
mdi:water-percent
value_template: >
{% set sensorstatus = states('sensor.humidity', 'raw_state') %}
{% if sensorstatus != 'unavailable' %}
{% set valuetokeep = sensorstatus %}
{{ states('sensor.humidity', 'raw_state') | float }}
{% else %}
valuetokeep
{% endif %}
The unique_id is required to be able to manage the entity in HomeAssistant. I just generated random ones. Do not use tabs when adding the code to sensors. Always use two spaces. Once you added the code, make sure it works properly before restarting, but going to Developer Tools > YAML > Check and Restart > Check Configuration.
Once you restarted, you need to get a data point before it has a valid value. You can remove and reinsert the battery to trigger an update. After that, it will keep the last value and track the history of the temperature and humidity.
The problem
I have this unbranded WIFI only temperature and humidity sensor (no bluetooth). It is working fine with the Tuya cloud integration. I used the trick of removing the battery for 1 second so that the device would not go into deep sleep. With LocalTuya, I tried first to configure it without using the Tuya API but it was not detecting all the DPS when I tried to add the device. With the Tuya API configured, the LocalTuya was able to detect only 2 DPS, namely the temperature and humidity, but the secondary DPS were not detected. Adding the missing DPS to the configuration dialog did not work.
I added the temperature as a "sensor.temperature" with a scaling factor of 0.1, and I added humidity as "sensor.humidity" with a scaling factor of 1. The issue is that these sensors are only updated once in a while and for most of the time their status is "unavailable".
Environment
Steps to reproduce
History graph of temperature from LocalTuya
History graph from Tuya
Sensors in LocalTuya device
Sensors in Tuya device
DP dump
Only a few DP were detected.
Provide Home Assistant traceback/logs
LocalTuya json (personal data has been removed)
What is interesting from this debug information is that LocalTuya is able to obtain all the DP using the information provided by the Tuya API. This suggests that this device could have a full integration with LocalTuya.
Additional information
Official Tuya json (personal data has been removed)
This is the information regarding the DPS in the Tuya API: