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
874 stars 206 forks source link

Temp and Humidity sensor unsupported in 2021.11 #712

Closed sagioto closed 2 years ago

sagioto commented 2 years ago

Describe the bug My temp & hum sensor function correctly using the tuya app and in IoT cloud project but appear as unsupported in ha integration revealing no entities.

Expected behavior Have sensor entities for temp and hum

Home Assistant Version

**Device info Device Information

Product Name 温湿度传感器 Device ID eb1e0a0***95gfid Product Category wsdcg Device Status Online Activated At 2021-11-19 19:04:14 Device Association

Project Association @gmail.com Data Center Western America Data Center Extension Information

Sub-Device or Not Yes IP Address

dragar commented 2 years ago

@sagioto

/usr/src/homeassistant/homeassistant/components/sensor/init.py

353:  if native_unit_of_measurement in (TEMP_CELSIUS, TEMP_FAHRENHEIT):
              if self.hass is not None: **<- add this line for fast fix**
                  return self.hass.config.units.temperature_unit
          return native_unit_of_measurement

and then works:

Screenshot 2021-12-14 at 14 45 26
sagioto commented 2 years ago

I applied the fix as a custom component, tried to both reload the plugin and delete and add it again, It didn't work for me, I still see the sensors as unsupported Is this scheduled to be in the next release?

pserranoa commented 2 years ago

this workarround works for me

magno-santos commented 2 years ago

I'm having difficulties applying this fix since I don't have that folder. Should I create it?

sagioto commented 2 years ago

@drager I’m running in docker and don’t have that folder as well that’s why I used custom_compoent The component is recognized when loading ha but the fix doesn’t work Shouldn’t I see a null pointer exception in the logs without the fix?

frenck commented 2 years ago

Yesterday, Home Assistant 2022.2 was released. Could you try upgrading to that version and see if the issue has been resolved?

If not, Home Assistant 2022.2 contains a new diagnostic tool. There is now a "Download Diagnostics" button on each Tuya device on the device page. Clicking that button will download diagnostics information for that specific device. Drag the downloaded file into this issue. It will help with finding out what the problem is.

magno-santos commented 2 years ago

Here you have the Diagnostics.

tuya-25a2a56d1ece699e4db447264a7be229- Sensor Escritório-34e883c233d345804a5088436e697ff1.json.txt

frenck commented 2 years ago

@magno-santos Looking at your data dump:

    "function": {},
    "status_range": {},
    "status": {},

☝️ Those are the functions and statuses the Tuya API provides to work with. As you can see, it provides nothing, thus Home Assistant won't be able to do anything either.

In you cause, I would recommend to submit an ticket with Tuya, asking if they can do anything about it (log in to your Tuya IoT account to do that).

Sorry! wish I had better news to share with you.

../Frenck

gemmaharton commented 2 years ago

So, playing with the api, the device itself doesn't provide the functions, but when querying the category it does. Is there some way to get ha to revert to querying the category if the device returns empty? GET "https://openapi.tuyaus.com/v1.0/iot-03/categories/wsdcg/functions"

{

  "result": {
    "category": "wsdcg",
    "functions": [
      {
        "code": "sampling_temperature",
        "desc": "sampling temperature",
        "name": "sampling temperature",
        "type": "Integer",
        "values": "{\"unit\":\"s\",\"min\":0,\"max\":3600,\"scale\":0,\"step\":1}"
      },
      {
        "code": "sampling_humidity",
        "desc": "sampling humidity",
        "name": "sampling humidity",
        "type": "Integer",
        "values": "{\"unit\":\"s\",\"min\":0,\"max\":3600,\"scale\":0,\"step\":1}"
      },
      {
        "code": "temp_unit_convert",
        "desc": "temp unit convert",
        "name": "temp unit convert",
        "type": "Enum",
        "values": "{\"range\":[\"c\",\"f\"]}"
      },
      {
        "code": "maxtemp_set",
        "desc": "maxtemp set",
        "name": "maxtemp set",
        "type": "Integer",
        "values": "{\"unit\":\"℃\",\"min\":-400,\"max\":2000,\"scale\":1,\"step\":1}"
      },
      {
        "code": "minitemp_set",
        "desc": "minitemp set",
        "name": "minitemp set",
        "type": "Integer",
        "values": "{\"unit\":\"℃\",\"min\":-400,\"max\":2000,\"scale\":1,\"step\":1}"
      },
      {
        "code": "maxhum_set",
        "desc": "maxhum set",
        "name": "maxhum set",
        "type": "Integer",
        "values": "{\"unit\":\"%\",\"min\":0,\"max\":100,\"scale\":0,\"step\":1}"
      },
      {
        "code": "minihum_set",
        "desc": "minihum set",
        "name": "minihum set",
        "type": "Integer",
        "values": "{\"unit\":\"%\",\"min\":0,\"max\":100,\"scale\":0,\"step\":1}"
      },
      {
        "code": "bright_value",
        "desc": "bright value",
        "name": "bright value",
        "type": "Integer",
        "values": "{\"unit\":\"lux\",\"min\":0,\"max\":1000,\"scale\":0,\"step\":1}"
      }
    ]
  },
  "success": true,
  "t": 1644183049559
}
frenck commented 2 years ago

@sagioto That has no use, as that isn't standardized, additional that only provides functional information, which without a state, is useless anyways 🤷

In these cases, there is only 1 thing that can be done: Contact Tuya about your device and hope they can adjust it (which they cannot in all cases, which is often to blame to the manufacturer).

marcusforsberg commented 2 years ago

I have the same model as @magno-santos (a Nedis sensor and a gateway) and this was Tuya's response:

I checked the functions of this product. They are all customized by the device manufacturer and do not conform to the standard instruction set of Tuya Cloud. Therefore, cloud API is not supported to control the device and obtain the status. Use the product on the APP (the device only supports the APP).

Looks like we're out of luck! 😅

frenck commented 2 years ago

Last possible source/route might be contacting the manufacturer, however, I haven't seen anybody having success with doing that :(

sagioto commented 2 years ago

I just moved to use ZHA with the sonoff usb zigbee dongle, the sensors work fine that way

frenck commented 2 years ago

Alright, as you are the reporter of this issue, I'll go ahead and close it.