xZetsubou/hass-localtuya

[Bug]: unable to add PIR sensor

Closed this issue · 7 comments

LocalTuya Version

2024.7.0

Home Assistant Version

2024.7.4

Environment

  • Does the device work using the Home Assistant Tuya Cloud component?
  • Is this device connected to another local integration, including Home Assistant and any other tools?
  • The devices are within the same HA subnet, and they get discovered automatically when I add them

What happened?

A bug happened!

Steps to reproduce.

  1. Add new device
  2. Bedroom Motion Sensor (sub device)
    3.Info added automatically
    image
    image
  3. when click add it return
    Connection to device succeeded but no datapoints could be found. Please try set-up again. If problem persists, create a new issue (including debug logs).

when query properties at tuya platform
{
"result": {
"properties": [
{
"code": "pir_state",
"custom_name": "",
"dp_id": 1,
"time": 1722958052025,
"type": "enum",
"value": "pir"
},
{
"code": "battery_percentage",
"custom_name": "",
"dp_id": 4,
"time": 1722953009968,
"type": "value",
"value": 100
},
{
"code": "pir_sensitivity",
"custom_name": "",
"dp_id": 9,
"time": 1716165139518,
"type": "enum",
"value": "high"
},
{
"code": "pir_time",
"custom_name": "",
"dp_id": 10,
"time": 1716165138921,
"type": "enum",
"value": "10S"
},
{
"code": "illuminance_value",
"custom_name": "",
"dp_id": 12,
"time": 1722958052742,
"type": "value",
"value": 1843
},
{
"code": "interval_time",
"custom_name": "",
"dp_id": 102,
"time": 1716165138392,
"type": "value",
"value": 1
}
]
},
"success": true,
"t": 1722958053302,
"tid": "66c4b4b1540811ef8365dab0e6a9e06c"
}

when query things data model
{
"result": {
"model": "{"modelId":"000003xr4c","services":[{"actions":[],"code":"","description":"","events":[],"name":"默认服务","properties":[{"abilityId":1,"accessMode":"ro","code":"pir_state","description":"","extensions":{"iconName":"icon-yundong","attribute":"1024"},"name":"人体感应状态","typeSpec":{"type":"enum","range":["pir","none"]}},{"abilityId":4,"accessMode":"ro","code":"battery_percentage","description":"","extensions":{"iconName":"icon-dp_battery","attribute":"1024","trigger":"direct"},"name":"电池电量","typeSpec":{"type":"value","max":100,"min":0,"scale":0,"step":1,"unit":"%"}},{"abilityId":9,"accessMode":"rw","code":"pir_sensitivity","description":"","extensions":{"iconName":"icon-dp_mode","attribute":"1152"},"name":"PIR 灵敏度","typeSpec":{"type":"enum","range":["low","middle","high"]}},{"abilityId":10,"accessMode":"rw","code":"pir_time","description":"","extensions":{"iconName":"icon-dp_time","attribute":"1152"},"name":"有人保持时间","typeSpec":{"type":"enum","range":["10S","30S","60S","120S"]}},{"abilityId":12,"accessMode":"ro","code":"illuminance_value","description":"","extensions":{"iconName":"icon-dp_light"},"name":"照度值","typeSpec":{"type":"value","max":10000,"min":0,"scale":0,"step":1,"unit":"lux"}},{"abilityId":102,"accessMode":"rw","code":"interval_time","description":"","name":"光感采集间隔(仅2.0.1版本支持)","typeSpec":{"type":"value","max":720,"min":1,"scale":0,"step":1,"unit":"Min"}}]}]}"
},
"success": true,
"t": 1722958182268,
"tid": "b3a6b646540811efa3c1e231eb3295cd"

Relevant log output

"eb961d73b6e0bd7c50hpug": {
        "active_time": 1709977026,
        "biz_type": 0,
        "category": "pir",
        "create_time": 1709973112,
        "icon": "smart/icon/ay1531985537002uUUZI/b96be71b30ff1babff8b299ffbbeab07.png",
        "id": "eb961d73b6e0bd7c50hpug",
        "ip": "",
        "lat": "",
        "local_key": ")8_...@|{",
        "lon": "",
        "model": "ZG-204L",
        "name": "Bedroom motion sensor",
        "node_id": "a4c138d45e437271",
        "online": true,
        "owner_id": "185302161",
        "product_id": "3towulqd",
        "product_name": "Luminance Motion sensor ",
        "status": [
          {
            "code": "pir",
            "value": "none"
          },
          {
            "code": "battery_percentage",
            "value": 100
          },
          {
            "code": "pir_sensitivity",
            "value": "high"
          }
        ],
        "sub": true,
        "time_zone": "+08:00",
        "uid": "az1...F1X",
        "update_time": 1722888114,
        "uuid": "eb961d73b6e0bd7c50hpug",
        "dps_data": {
          "1": {
            "code": "pir_state",
            "custom_name": "",
            "dp_id": 1,
            "time": 1722905117406,
            "type": "enum",
            "value": "none",
            "id": 1,
            "accessMode": "ro",
            "values": "{\"type\": \"enum\", \"range\": [\"pir\", \"none\"]}"
          },
          "4": {
            "code": "battery_percentage",
            "custom_name": "",
            "dp_id": 4,
            "time": 1722948370034,
            "type": "value",
            "value": 100,
            "id": 4,
            "accessMode": "ro",
            "values": "{\"type\": \"value\", \"max\": 100, \"min\": 0, \"scale\": 0, \"step\": 1, \"unit\": \"%\"}"
          },
          "9": {
            "code": "pir_sensitivity",
            "custom_name": "",
            "dp_id": 9,
            "time": 1716165139518,
            "type": "Enum",
            "value": "high",
            "values": "{\"type\": \"enum\", \"range\": [\"low\", \"middle\", \"high\"]}",
            "id": 9,
            "accessMode": "rw"
          },
          "10": {
            "code": "pir_time",
            "custom_name": "",
            "dp_id": 10,
            "time": 1716165138921,
            "type": "enum",
            "value": "10S",
            "id": 10,
            "accessMode": "rw",
            "values": "{\"type\": \"enum\", \"range\": [\"10S\", \"30S\", \"60S\", \"120S\"]}"
          },
          "12": {
            "code": "illuminance_value",
            "custom_name": "",
            "dp_id": 12,
            "time": 1722949393948,
            "type": "value",
            "value": 465,
            "id": 12,
            "accessMode": "ro",
            "values": "{\"type\": \"value\", \"max\": 10000, \"min\": 0, \"scale\": 0, \"step\": 1, \"unit\": \"lux\"}"
          },
          "102": {
            "code": "interval_time",
            "custom_name": "",
            "dp_id": 102,
            "time": 1716165138392,
            "type": "value",
            "value": 1,
            "id": 102,
            "accessMode": "rw",
            "values": "{\"type\": \"value\", \"max\": 720, \"min\": 1, \"scale\": 0, \"step\": 1, \"unit\": \"Min\"}"
          }
        }
      },

Diagnostics information.

config_entry-localtuya-01J4KWN4V21D75FFMD9PGMNER0 (1).json

Have you tried to reboot the gateway? just power it off then on again. the issue isn't in the sub-device if the gateway aren't responding then it won't make connection.

If rebooting didn't fix it then enable the logs for both integration and device when connection and post the logs..

Power on and off solve the problem. Thanks a lot.
I was trying to use cloud api to get the value.

I tested it on my workbench and move the gateway to permenant location.
however the sensor show not avaliable again, power off and on does not fix this issue.

Is it hardware issue? and

i should walk way from tuya gateway ?

home-assistant_localtuya_2024-08-07T23-54-42.963Z.log

Does the device reports the same in Smart Life app as well? If yes, Double check the "signal" between sensor and gateway and also ensure the buttery is in good state.

NOTE: If the connection between localtuya and device fails then it probably gateway issue try different sub-device if you have otherwise if connection made but the sub-device has no status then it probably sub-device issue, from your logs it seems localtuya fails to made connection with the gateway before requesting sub-device status.

I also set up the official Tuya integration in Home Assistant. So far, it works without any issues. However, the official Tuya integration only includes the motion sensor and battery level; it's missing the luminance data I'm looking for.

Both the app and the Tuya integration are working without any issues. I have two luminance motion sensors, and both behave the same way—they show 100% battery.
Following are the date direct from Tuya Integration
image

The gateway uses a Wi-Fi connection. I tried assigning it a static IP address, and I used a PC to ping it without any connection loss.

image

I feel like something is wrong somewhere, but I don't have sufficient programming skills to find it.

Update from the log, it seem it start to lost connection
home-assistant_localtuya_2024-08-08T13-37-17.275Z.log

WhatsApp.Video.2024-08-08.at.21.45.59_f49c6aa0.mp4

WhatsApp Image 2024-08-08 at 21 48 43_849a1986

Can you install the master version and check if the issue still exists?

Install Master Version

Go HACS -> Local Tuya -> On top right corner click on the ⋮ and choose redownload and select master

image

And restart HA then re-add your device

Ops, HACS updated to 2.0.0 master version is which one
image