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

PIR WIFI sensor does not changing statuses in HA (motion/no motion) #144

Open alexreddy78 opened 2 years ago

alexreddy78 commented 2 years ago

{ "result": { "active_time": 1600712608, "biz_type": 18, "category": "pir", "create_time": 1600712608, "icon": "smart/icon/ay1524194438166Zg2hZ/c3db264e1bc8e6ab11cf88171e87dc39.jpg", "id": "", "ip": "", "lat": "", "local_key": "", "lon": "", "name": "Душ", "online": true, "owner_id": "16305239", "product_id": "XFD2nSDKxFlGV5sV", "product_name": "PIR Sensor", "status": [ { "code": "pir", "value": "pir" }, { "code": "battery_value", "value": 81 } ], "sub": false, "time_zone": "+03:00", "uid": "eu1600250372644kZmGd", "update_time": 1626249312, "uuid": "20372743500291bb1b9e" }, "success": true, "t": 1626254980444 } Device specifications (please complete the following information, which can be found in log): { "result": { "category": "pir", "functions": [], "status": [ { "code": "pir", "type": "Enum", "values": "{\"range\":[\"pir\",\"none\"]}" }, { "code": "battery_value", "type": "Integer", "values": "{\"unit\":\"\",\"min\":0,\"max\":10000,\"scale\":0,\"step\":1}" } ] }, "success": true, "t": 1626255049113 }

MickW69 commented 2 years ago

Me too, Arlec movement sensor and door sensor, neither send updates.

saharajesh880 commented 2 years ago

Same here, tuya and sonoff motion sensor and tuya door sensor are not updating the status on HA

schmurrie commented 2 years ago

Same here with the arlec units. Only updates when you restart HA

alexreddy78 commented 2 years ago

@tsutsuku after update to v 1.3.2 issue still exist. Status of PIR is not changing in HA. I am wondering: was the latest update related to PIR status or it was fix for something else?

Regards!

tsutsuku commented 2 years ago

https://github.com/tuya/tuya-home-assistant/discussions/113

alexreddy78 commented 2 years ago

@tsutsuku I have already subscription to Device status notification and my door sensor is OK, but PIR is not updating statuses... :( Any advise? May be it is the same issue as ticket "motion sensor not changing states #57"

alexreddy78 commented 2 years ago

Even in API Explorer -> Get Device status sensor always show state: PIR, however in Tuya Smart Life app IOS works normal { "result": [ { "code": "pir", "value": "pir" }, { "code": "battery_value", "value": 59 } ], "success": true, "t": 1626516376612 }

alexreddy78 commented 2 years ago

@tsutsuku Dear, Tsutsuku Kindly advise on above mentioned problem.

Regards

alexreddy78 commented 2 years ago

@saharajesh880 @schmurrie How is yours? Still no updates for PIR sensors?

schmurrie commented 2 years ago

Still no updates, still not working unfortunately

fredrikbuchanan commented 2 years ago

I have the same issue with , Device normal info

Brand: Nedis Model: WIFISM10CWT SmartLife Motion Sensor Device info (please complete the following information, which can be found in log): like this: { "active_time": 1620134241, "biz_type": 18, "category": "pir", "create_time": 1620080030, "icon": "smart/icon/1533129428eg81rzdqpg_0.png", "id": "08325122dc4f225c3a75", "ip": "85.229.11.195", "lat": "59.2357956", "local_key": "0402a6e0990a6952", "lon": "18.1016498", "model": " WIFISM10CWT ", "name": "Motion Sensor", "online": true, "owner_id": "28575566", "product_id": "saMa30bbTOq0nxUz", "product_name": "Motion Sensor", "status": [], "sub": false, "time_zone": "+01:00", "uid": "eu16173965733970jJ4t", "update_time": 1626771870, "uuid": "08325122dc4f225c3a75" }

2021-07-22 15:03:45 DEBUG (SyncWorker_7) [tuya iot] Request: method = GET, url = https://openapi.tuyaeu.com/v1.0/devices/08325122dc4f225c3a75/specifications, params = None, body = None, headers = {'client_id': '4c8ts7yyarsuyqlsz7e9', 'sign': '603E169B63663384CFB7409AD2F86EF4D960A217A48C6119D159F5056ADC2A68', 'sign_method': 'HMAC-SHA256', 'access_token': 'a617ab41e4a5d1022eca34c026fab79b', 't': '1626959025437', 'lang': 'en'} 2021-07-22 15:03:45 DEBUG (Thread-5) [tuya iot] _on_log: Received CONNACK (0, 0) 2021-07-22 15:03:45 DEBUG (Thread-5) [tuya iot] connect flags->{'session present': 0}, rc->0 2021-07-22 15:03:45 DEBUG (Thread-5) [tuya iot] _on_log: Sending SUBSCRIBE (d0, m1) [(b'cloud/token/in/5c946888fc26abbfbffa02c48eb6bc86', 0)] 2021-07-22 15:03:45 DEBUG (SyncWorker_7) [tuya iot] Response: { "code": 2009, "msg": "not support this device", "success": false, "t": 1626959025474 } 2021-07-22 15:03:45 DEBUG (Thread-5) [tuya iot] _on_log: Received SUBACK 2021-07-22 15:03:45 DEBUG (Thread-5) [tuya iot] _on_subscribe: 1

this is now added to the api and i can se it in ha but it does not update it's status

alexreddy78 commented 2 years ago

@tsutsuku Pls advise if any updates on that?

REGARDS

tsutsuku commented 2 years ago

@fredrikbuchanan You can create a ticket in the Tuya service console with your device specifications. https://service.console.tuya.com/8/2/create?step=3&id=01030503&source=content_feedback.

tsutsuku commented 2 years ago

@alexreddy78 Can you provide more logs with [tuya-openmq]?

fredrikbuchanan commented 2 years ago

@fredrikbuchanan You can create a ticket in the Tuya service console with your device specifications. https://service.console.tuya.com/8/2/create?step=3&id=01030503&source=content_feedback.

I have already done that, and it looks ok i think on that end. i can get updated status if i reload the integration. i can se if i can give you more logs

alexreddy78 commented 2 years ago

@alexreddy78 Can you provide more logs with [tuya-openmq]?

Dear @tsutsuku There is nothing in the HA LOGS except flw:

curl --request GET "https://openapi.tuyaeu.com/v1.0/devices/20372743500291d443e2/specifications" --header "sign_method: HMAC-SHA256" --header "client_id: mp9ctfjgaq07xr07ytc4" --header "t: 1627460652295" --header "mode: cors" --header "Content-Type: application/json" --header "sign: 5F9442D030934ACFE8BCEE51899EE757A6A2585C27D4ECCCF262C1F47677DD38" --header "access_token: " ResponseCopy { "result": { "category": "pir", "functions": [], "status": [ { "code": "pir", "type": "Enum", "values": "{\"range\":[\"pir\",\"none\"]}" }, { "code": "battery_value", "type": "Integer", "values": "{\"unit\":\"\",\"min\":0,\"max\":10000,\"scale\":0,\"step\":1}" } ] }, "success": true, "t": 1627460652526 }

And what is tuya-openmq? How to get to this?

Pls advise.

REGARDS

alexreddy78 commented 2 years ago

@tsutsuku Dear Tsutsuku,

More LOGS for you, pls:

2021-07-30 11:53:48 DEBUG (Thread-5) [tuya iot] _on_log: Received PUBLISH (d0, q0, r0, m0), 'cloud/token/in/2cfcb55b3ee5999bd082303589366df0', ... (265 bytes) 2021-07-30 11:53:48 DEBUG (Thread-5) [tuya iot] payload-> b'{"data":"P1/7OMAihGrtv15wcMEV3GGuWEtvVo3grB8Z3EdTdRmwND5ZjUQI+1qtUTekdTzylIGjRxUWp3Zs0nzc7ro10TpGW002j4kX48LSje3cuQbBOpC+rG/fsz1lfw27Cv5hAYoULBmZNJRvNKzZeDWNwh0R41ILSZyEQbBNNbYsxVI=","protocol":20,"pv":"2.0","sign":"0ec7639add23a34c60ca5334b991e0e1","t":1627635228}' 2021-07-30 11:53:48 DEBUG (Thread-5) [tuya iot] on_message: {'data': {'bizCode': 'online', 'bizData': {'time': 1627635228}, 'devId': '20372743500291d443e2', 'productKey': 'XFD2nSDKxFlGV5sV', 'ts': 0}, 'protocol': 20, 'pv': '2.0', 'sign': '0ec7639add23a34c60ca5334b991e0e1', 't': 1627635228} 2021-07-30 11:53:48 DEBUG (Thread-5) [tuya iot] mq receive-> {'data': {'bizCode': 'online', 'bizData': {'time': 1627635228}, 'devId': '20372743500291d443e2', 'productKey': 'XFD2nSDKxFlGV5sV', 'ts': 0}, 'protocol': 20, 'pv': '2.0', 'sign': '0ec7639add23a34c60ca5334b991e0e1', 't': 1627635228} 2021-07-30 11:53:48 DEBUG (Thread-5) [tuya iot] mq _on_device_other-> 20372743500291d443e2 -- online 2021-07-30 11:53:48 DEBUG (Thread-5) [custom_components.tuya_v2] _update--><custom_components.tuya_v2._init_tuya_sdk..DeviceListener object at 0xacc31f10>;->>{'pir': 'pir', 'battery_value': 100} 2021-07-30 11:53:49 DEBUG (Thread-5) [tuya iot] _on_log: Received PUBLISH (d0, q0, r0, m0), 'cloud/token/in/2cfcb55b3ee5999bd082303589366df0', ... (348 bytes) 2021-07-30 11:53:49 DEBUG (Thread-5) [tuya iot] payload-> b'{"data":"2pKHDPR2TVv0C5mj2EGcxflxUp/PotTb5EYsXnXepBsq/ooloDLyzgxP3vOvlgzJgWunHA8l2tp3Vnaq59TWzvEP2uej/ymoNHdWVozfQT3mJNft/DhjdVN4Z1s4B9FT6citjzFsjQGl0d00TATlHIYdO/0MUwJrkhzUXCeaeTZuyBI62+s0h2SeOyfolUiMPHrgCFnHEtahvDoEum+npNPzREIn7321gBkMCo0VXuTktO1+E64jkHwh9/px37T4","protocol":4,"pv":"2.0","sign":"97e20595e70ea57619b9bca14f495683","t":1627635228}' 2021-07-30 11:53:49 DEBUG (Thread-5) [tuya iot] on_message: {'data': {'dataId': '28a28ebc-cd16-4c52-85aa-fea43ed5ccc0', 'devId': '20372743500291d443e2', 'productKey': 'XFD2nSDKxFlGV5sV', 'status': [{'101': 'pir', 'code': 'pir', 't': '1627635228', 'value': 'pir'}]}, 'protocol': 4, 'pv': '2.0', 'sign': '97e20595e70ea57619b9bca14f495683', 't': 1627635228} 2021-07-30 11:53:49 DEBUG (Thread-5) [tuya iot] mq receive-> {'data': {'dataId': '28a28ebc-cd16-4c52-85aa-fea43ed5ccc0', 'devId': '20372743500291d443e2', 'productKey': 'XFD2nSDKxFlGV5sV', 'status': [{'101': 'pir', 'code': 'pir', 't': '1627635228', 'value': 'pir'}]}, 'protocol': 4, 'pv': '2.0', 'sign': '97e20595e70ea57619b9bca14f495683', 't': 1627635228} 2021-07-30 11:53:49 DEBUG (Thread-5) [tuya iot] mq _on_device_report-> [{'101': 'pir', 'code': 'pir', 't': '1627635228', 'value': 'pir'}] 2021-07-30 11:53:49 DEBUG (Thread-5) [custom_components.tuya_v2] _update--><custom_components.tuya_v2._init_tuya_sdk..DeviceListener object at 0xacc31f10>;->>{'pir': 'pir', 'battery_value': 100} 2021-07-30 11:53:49 DEBUG (Thread-5) [tuya iot] _on_log: Received PUBLISH (d0, q0, r0, m0), 'cloud/token/in/2cfcb55b3ee5999bd082303589366df0', ... (348 bytes) 2021-07-30 11:53:49 DEBUG (Thread-5) [tuya iot] payload-> b'{"data":"jX7kT2p+sev35mnB41ijkWZtHucJxcjurX7E6Yu15CKePfVDmYWP8SXymo+c5akegWunHA8l2tp3Vnaq59TWzvEP2uej/ymoNHdWVozfQT3mJNft/DhjdVN4Z1s4B9FT6citjzFsjQGl0d00TATlHP/WK40WNd0ed65rAexMvASUKBPZeQuEedA8Y5ZSoGbWoh6P2BmjTbxt4zmV0oM+pX6HdLTEXtBdwko21gFIEHmMawo8wajp4z8U2JZEUQhk","protocol":4,"pv":"2.0","sign":"9f6d85d2caaa9cf0784cb000cec67279","t":1627635228}' 2021-07-30 11:53:49 DEBUG (Thread-5) [tuya iot] on_message: {'data': {'dataId': 'bbfc5511-8f4a-4c4c-84db-2149aebfffd9', 'devId': '20372743500291d443e2', 'productKey': 'XFD2nSDKxFlGV5sV', 'status': [{'code': 'battery_value', '103': 100, 't': '1627635228', 'value': 100}]}, 'protocol': 4, 'pv': '2.0', 'sign': '9f6d85d2caaa9cf0784cb000cec67279', 't': 1627635228} 2021-07-30 11:53:49 DEBUG (Thread-5) [tuya iot] mq receive-> {'data': {'dataId': 'bbfc5511-8f4a-4c4c-84db-2149aebfffd9', 'devId': '20372743500291d443e2', 'productKey': 'XFD2nSDKxFlGV5sV', 'status': [{'code': 'battery_value', '103': 100, 't': '1627635228', 'value': 100}]}, 'protocol': 4, 'pv': '2.0', 'sign': '9f6d85d2caaa9cf0784cb000cec67279', 't': 1627635228} 2021-07-30 11:53:49 DEBUG (Thread-5) [tuya iot] mq _on_device_report-> [{'code': 'battery_value', '103': 100, 't': '1627635228', 'value': 100}] 2021-07-30 11:53:49 DEBUG (Thread-5) [custom_components.tuya_v2] _update--><custom_components.tuya_v2._init_tuya_sdk..DeviceListener object at 0xacc31f10>;->>{'pir': 'pir', 'battery_value': 100} 2021-07-30 11:54:19 DEBUG (Thread-5) [tuya iot] _on_log: Received PUBLISH (d0, q0, r0, m0), 'cloud/token/in/2cfcb55b3ee5999bd082303589366df0', ... (520 bytes)

Kindly advise

Regards

iotinkognito commented 2 years ago

Same Issues as #140 #57 #119 #57 #144 #271 #262

alexreddy78 commented 2 years ago

@tsutsuku Dear Tsutsuku,

Did you have a little chance and time to see LOGs above and advise if there’s any updates on issue?

REGARDS and hope hear you soon

balouken commented 2 years ago

@tsutsuku the PIR sensor is working! But the state is never reset to OFF. If you change state in Developer Tools to OFF, and then activated the PIR, the sensor state goes to ON... en never goes back to OFF. Maybe add auto return to off after x seconds would do the trick?

I did a test last night. inkom

alexreddy78 commented 2 years ago

@tsutsuku Dear Tsutsuku,

Any news regarding PIRs? Still not working after 1.5.0 update... :(

BRGDS

tsutsuku commented 2 years ago

@alexreddy78 PIR has two statuses normally, "pir" and "none", but some Pir only has "pir" status which is decided by the manufacturer. To these PIR sensors, the "none" status will be set by the client (like SmartLife App) after some seconds with no "pir" status received. v1.5.0 adds the same thing. But your PIR specification has an error as its pir range is ["pir", "none"], so v1.5.0 can't recognize it to the Pir only has "pir". We are handling these devices which will be fixed soon.

alexreddy78 commented 2 years ago

@tsutsuku Dear Tsutsuku,

Thanks for quick reply! Awesome, will wait fix from your side

Best Regards

alexreddy78 commented 2 years ago

@tsutsuku Dear Tsutsuku,

As from yesterday PIR sensors are changing statuses, but there is an issue with time of OFF event. As per PIR events in Home Assistant, sensor send OFF (no motion) after 10 sec and this is a problem as origin Tuya APP and firmware is sending OFF after 2 minutes. Senors stay active in Tuya APP but in HA is shown OFF. So it means that HA send OFF too earlier and can't send ON (motion detected) for another 1.50 sec. Pls advise.

Best Regards

tsutsuku commented 2 years ago

Normally the "send OFF" is decided by the manufacturer in Tuya APP Device Panel, so it's maybe 10s for A and 2 minutes for B. So I think it better to add a NumberEntity for the "send OFF time" setting in HA. We will add this in the future.

wongjunjin commented 2 years ago

Dear @tsutsuku

I'm having the same issue which my PIR cannot change status. It maintains as On or Off. I can manually set it in Developer Tools.

Can you explain your last message to Alex? I dont understand about the NumberEntity. How do I go about fixing this

wongjunjin commented 2 years ago

For everybody who has this issue, please go here: https://github.com/tuya/tuya-home-assistant/discussions/113

I made a mistake of not reading EVERYTHING on the main readme. Please go through ALL. Even though you think you have, please re-read. Took me so many readings to find the solution. Thanks Tuya team for being patient, (although not responding to me). :D

iotinkognito commented 2 years ago

o has this issue, please go here: #113

I made a mistake of not reading EVERYTHING on the main readme. Please go through ALL. Even though you think you have, please re-read. Took me so many readings to find the solution. Thanks Tuya team for being patient, (although not responding to me). :D

This is different issue. This is Bluetooth/Wifi/Zigbee PIR sensors.

PeterKawa commented 1 year ago

@alexreddy78 PIR has two statuses normally, "pir" and "none", but some Pir only has "pir" status which is decided by the manufacturer. To these PIR sensors, the "none" status will be set by the client (like SmartLife App) after some seconds with no "pir" status received. v1.5.0 adds the same thing. But your PIR specification has an error as its pir range is ["pir", "none"], so v1.5.0 can't recognize it to the Pir only has "pir". We are handling these devices which will be fixed soon.

That's exactly my PIR issue. Odd thing: they worked fine in the earlier Tuya V2 integration. Also they work fine in Athom's Homey, which uses exactly the same Tuya iot cloud project API (https://github.com/jurgenheine/com.tuya.cloud). I've tried several scripts, automations and stuff, to clear the status 'pir', but of no avail. Only in the developer changing the status to off, by adding 'value: ' to the state attributes works.Then the state is 'off'. Thanks in advance, All the best

igorsantos07 commented 1 year ago

Checking my PIR sensor's diagnostics JSON, I see it only has the "pir" status, but nonetheless it never goes back from "detected". Checking the device debugger in the Tuya web platform, I do see it's sending detection events when expected, so it seems it's just missing the auto-off which HA should be sending? Or am I missing something?

PeterKawa commented 1 year ago

" so it seems it's just missing the auto-off which HA should be sending? " Exactly!