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
403 stars 50 forks source link

[Bug]: Device (wifi siren) recognized but entities are not added automatically. #361

Closed marceloncosta closed 2 days ago

marceloncosta commented 3 weeks ago

LocalTuya Version

2024.9.0

Home Assistant Version

2024.9.3

Environment

What happened?

I'm trying to add a wifi device (siren) but I'm having trouble with the entities. The siren is connected directly to the power source. Not the battery.

The device is normally discovered by the integration but the entities are not. So I have to add them manually. However, I can't get an entity that refers to the alarm type (melody) to work. Its type is Enum and its list of options goes from 1 to 12. I registered this entity as "Select" but I can't configure its list of options.

When I register the list of options, from 1 to 12, the registration seems to work, but every time I try to select an item from the list an error message is displayed. Example: [546523764848] Option Type 4 is not valid for entity select.sirene_1o_andar_tipo, valid options are:

And every time I perform an operation, be it turning on the siren or changing the AlarmPeriod (which are working) the registration of options that I performed regarding the Alarmtype is deleted in HA.

By the way, the device works. I can turn the siren on and off, I can change the AlarmPeriod, but I can't change the Alarmtype.

Since the siren will always be connected to a power source, the BatteryStatus entity doesn't interest me much, nor have I tried to register it, but since it is also of the Enum type, I believe I will have the same problem. The battery statuses go from 0 to 4. For me, when connected to the source, it shows 4. I imagine that the others from 0 to 3, refer to ??, low, medium, high.

Shouldn't this entity be of type "Select"? Am I not setting up the list correctly? select.sirene_1o_andar_tipo

options:

  • "1"
  • "2"
  • "3"
  • "4"
  • "5"
  • "6"
  • "7"
  • "8"
  • "9"
  • "10"
  • "11"
  • "12" raw_state: "9" friendly_name: Sirene 1º andar Tipo

I'm entering the device information according to the Tuya IoT Development website:

{ "result": { "category": "sgbj", "functions": [ { "code": "Alarmtype", "desc": "{\"range\":[\"1\",\"2\",\"3\",\"4\",\"5\",\"6\",\"7\",\"8\",\"9\",\"10\",\"11\",\"12\"]}", "name": "报警声类型", "type": "Enum", "values": "{\"range\":[\"1\",\"2\",\"3\",\"4\",\"5\",\"6\",\"7\",\"8\",\"9\",\"10\",\"11\",\"12\"]}" }, { "code": "AlarmPeriod", "desc": "{\"unit\":\"秒\",\"min\":0,\"max\":60,\"scale\":0,\"step\":1}", "name": "报警时长", "type": "Integer", "values": "{\"unit\":\"秒\",\"min\":0,\"max\":60,\"scale\":0,\"step\":1}" }, { "code": "AlarmSwitch", "desc": "{}", "name": "报警开关", "type": "Boolean", "values": "{}" } ], "status": [ { "code": "BatteryStatus", "name": "电池电量", "type": "Enum", "values": "{\"range\":[\"0\",\"1\",\"2\",\"3\",\"4\"]}" }, { "code": "Alarmtype", "name": "报警声类型", "type": "Enum", "values": "{\"range\":[\"1\",\"2\",\"3\",\"4\",\"5\",\"6\",\"7\",\"8\",\"9\",\"10\",\"11\",\"12\"]}" }, { "code": "AlarmPeriod", "name": "报警时长", "type": "Integer", "values": "{\"unit\":\"秒\",\"min\":0,\"max\":60,\"scale\":0,\"step\":1}" }, { "code": "AlarmSwitch", "name": "报警开关", "type": "Boolean", "values": "{}" } ] }, "success": true, "t": 1728124696268, "tid": "edf55959830511ef86b3722f08288c6c" }

03 05 11 14 15 16 23

Steps to reproduce.

Try to add a device Siren wifi. Device recognized but entities are not added automatically.

Relevant log output

Registrador: homeassistant.components.websocket_api.http.connection
Fonte: components/websocket_api/commands.py:287
integração: Home Assistant WebSocket API (documentação, problemas)
Ocorreu pela primeira vez: 14:02:33 (5 ocorrências)
Último registro: 14:09:21

[546523764848] Option Type 5 is not valid for entity select.sirene_1o_andar_tipo, valid options are:
[546523764848] Option Type 4 is not valid for entity select.sirene_1o_andar_tipo, valid options are:
[546523764848] Option Type 3 is not valid for entity select.sirene_1o_andar_tipo, valid options are:
[546557919872] Option Type 4 is not valid for entity select.sirene_1o_andar_tipo, valid options are:

Diagnostics information.

{ "home_assistant": { "installation_type": "Home Assistant OS", "version": "2024.10.3", "dev": false, "hassio": true, "virtualenv": false, "python_version": "3.12.4", "docker": true, "arch": "aarch64", "timezone": "America/Sao_Paulo", "os_name": "Linux", "os_version": "6.6.31-haos-raspi", "supervisor": "2024.10.3", "host_os": "Home Assistant OS 13.2", "docker_version": "27.2.0", "chassis": "embedded", "run_as_root": true },

"localtuya": {
  "documentation": "https://github.com/xZetsubou/hass-localtuya/",
  "version": "2024.9.0",
  "requirements": []
},

"integration_manifest": { "domain": "localtuya", "name": "Local Tuya", "codeowners": [], "config_flow": true, "dependencies": [], "documentation": "https://github.com/xZetsubou/hass-localtuya/", "integration_type": "hub", "iot_class": "local_push", "issue_tracker": "https://github.com/xZetsubou/hass-localtuya/issues", "requirements": [], "version": "2024.9.0", "is_built_in": false }, "setup_times": { "null": { "setup": 0.0023564489999898797 }, "01J8ZMFPE7X00VBYHDD38RXH8S": { "wait_import_platforms": -3.894558791999998, "wait_base_component": -0.003380242000005751, "config_entry_setup": 4.055360660000005 } }, "data": { "device_config": { "friendly_name": "Sirene 1\u00ba andar", "host": "192.168.3.186", "device_id": "526fhd......evf12c03e8c", "local_key": "{n3jh......sDF=Z}", "protocol_version": "3.3", "enable_debug": false, "node_id": null, "model": "Siren", "product_key": "SVjFdsfF......hsdzXnIAlq", "dps_strings": [ "101 ( code: BatteryStatus , value: 4 )", "102 ( code: Alarmtype , value: 9 )", "103 ( code: AlarmPeriod , value: 16 )", "104 ( code: AlarmSwitch , value: False )" ], "entities": [ { "id": "104", "friendly_name": "Sirene", "entity_category": "None", "state_on": "true", "platform": "siren" }, { "id": "103", "friendly_name": "Tempo", "entity_category": "config", "min_value": 0.0, "max_value": 60.0, "step_size": 1.0, "restore_on_reconnect": false, "is_passive_entity": false, "platform": "number" }, { "id": "102", "friendly_name": "Tipo", "entity_category": "config", "select_options": [ "1:Tipo 1", "2:Tipo 2", "3:Tipo 3", "4:Tipo 4", "5:Tipo 5", "6:Tipo 6", "7:Tipo 7", "8:Tipo 8", "9:Tipo 9", "10:Tipo 10", "11:Tipo 11", "12:Tipo 12" ], "restore_on_reconnect": false, "is_passive_entity": false, "platform": "select" } ] }, "device_cloud_info": { "active_time": 1710517326, "biz_type": 0, "category": "sgbj", "create_time": 1664393534, "icon": "smart/icon/1528364694thahb9sok2l_0.png", "id": "52618110a4cf12c03e8c", "ip": "1...9", "lat": "", "local_key": "{n3...=Z}", "lon": "", "model": "", "name": "Sirene 1\u00ba andar", "online": true, "owner_id": "78616734", "product_id": "SVjFPMicRzXnIAlq", "product_name": "Siren", "status": [ { "code": "BatteryStatus", "value": "4" }, { "code": "Alarmtype", "value": "9" }, { "code": "AlarmPeriod", "value": 10 }, { "code": "AlarmSwitch", "value": false } ], "sub": false, "time_zone": "-03:00", "uid": "az1...BeH", "update_time": 1729730746, "uuid": "52618110a4cf12c03e8c", "dps_data": { "101": { "code": "BatteryStatus", "custom_name": "", "dp_id": 101, "time": 1729196637488, "type": "enum", "value": "4", "id": 101, "accessMode": "ro", "values": "{\"type\": \"enum\", \"range\": [\"0\", \"1\", \"2\", \"3\", \"4\"]}" }, "102": { "code": "Alarmtype", "custom_name": "", "dp_id": 102, "time": 1729196637488, "type": "Enum", "value": "9", "values": "{\"type\": \"enum\", \"range\": [\"1\", \"2\", \"3\", \"4\", \"5\", \"6\", \"7\", \"8\", \"9\", \"10\", \"11\", \"12\"]}", "id": 102, "accessMode": "rw" }, "103": { "code": "AlarmPeriod", "custom_name": "", "dp_id": 103, "time": 1729196637488, "type": "Integer", "value": 10, "values": "{\"type\": \"value\", \"max\": 60, \"min\": 0, \"scale\": 0, \"step\": 1, \"unit\": \"\u79d2\"}", "id": 103, "accessMode": "rw" }, "104": { "code": "AlarmSwitch", "custom_name": "", "dp_id": 104, "time": 1729196637488, "type": "Boolean", "value": false, "values": "{\"type\": \"bool\"}", "id": 104, "accessMode": "rw" } } } } }

github-actions[bot] commented 1 week 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.

xZetsubou commented 1 day ago

Diagnostics information for the device may helped to check how did you configured the device however select options should be dict type e.g.:

1: Type 1
2: Type 2
3: Type 3
4: Type 4
5: Type 5
6: Type 6
7: Type 7
8: Type 8
9: Type 9
marceloncosta commented 1 day ago

{ "home_assistant": { "installation_type": "Home Assistant OS", "version": "2024.10.3", "dev": false, "hassio": true, "virtualenv": false, "python_version": "3.12.4", "docker": true, "arch": "aarch64", "timezone": "America/Sao_Paulo", "os_name": "Linux", "os_version": "6.6.31-haos-raspi", "supervisor": "2024.10.3", "host_os": "Home Assistant OS 13.2", "docker_version": "27.2.0", "chassis": "embedded", "run_as_root": true },

"localtuya": {
  "documentation": "https://github.com/xZetsubou/hass-localtuya/",
  "version": "2024.9.0",
  "requirements": []
},

"integration_manifest": { "domain": "localtuya", "name": "Local Tuya", "codeowners": [], "config_flow": true, "dependencies": [], "documentation": "https://github.com/xZetsubou/hass-localtuya/", "integration_type": "hub", "iot_class": "local_push", "issue_tracker": "https://github.com/xZetsubou/hass-localtuya/issues", "requirements": [], "version": "2024.9.0", "is_built_in": false }, "setup_times": { "null": { "setup": 0.0023564489999898797 }, "01J8ZMFPE7X00VBYHDD38RXH8S": { "wait_import_platforms": -3.894558791999998, "wait_base_component": -0.003380242000005751, "config_entry_setup": 4.055360660000005 } }, "data": { "device_config": { "friendly_name": "Sirene 1\u00ba andar", "host": "192.168.3.186", "device_id": "5261sdfs........sdsdc03e8c", "local_key": "{n3jsdj........Revv=Z}", "protocol_version": "3.3", "enable_debug": false, "node_id": null, "model": "Siren", "product_key": "SVjFPMicRzXnIAlq", "dps_strings": [ "101 ( code: BatteryStatus , value: 4 )", "102 ( code: Alarmtype , value: 9 )", "103 ( code: AlarmPeriod , value: 16 )", "104 ( code: AlarmSwitch , value: False )" ], "entities": [ { "id": "104", "friendly_name": "Sirene", "entity_category": "None", "state_on": "true", "platform": "siren" }, { "id": "103", "friendly_name": "Tempo", "entity_category": "config", "min_value": 0.0, "max_value": 60.0, "step_size": 1.0, "restore_on_reconnect": false, "is_passive_entity": false, "platform": "number" }, { "id": "102", "friendly_name": "Tipo", "entity_category": "config", "select_options": [ "1:Tipo 1", "2:Tipo 2", "3:Tipo 3", "4:Tipo 4", "5:Tipo 5", "6:Tipo 6", "7:Tipo 7", "8:Tipo 8", "9:Tipo 9", "10:Tipo 10", "11:Tipo 11", "12:Tipo 12" ], "restore_on_reconnect": false, "is_passive_entity": false, "platform": "select" } ] }, "device_cloud_info": { "active_time": 1710517326, "biz_type": 0, "category": "sgbj", "create_time": 1664393534, "icon": "smart/icon/1528364694thahb9sok2l_0.png", "id": "52618110a4cf12c03e8c", "ip": "1...9", "lat": "", "local_key": "{n3...=Z}", "lon": "", "model": "", "name": "Sirene 1\u00ba andar", "online": true, "owner_id": "78616734", "product_id": "SVjFPMicRzXnIAlq", "product_name": "Siren", "status": [ { "code": "BatteryStatus", "value": "4" }, { "code": "Alarmtype", "value": "9" }, { "code": "AlarmPeriod", "value": 10 }, { "code": "AlarmSwitch", "value": false } ], "sub": false, "time_zone": "-03:00", "uid": "az1...BeH", "update_time": 1729730746, "uuid": "52618110a4cf12c03e8c", "dps_data": { "101": { "code": "BatteryStatus", "custom_name": "", "dp_id": 101, "time": 1729196637488, "type": "enum", "value": "4", "id": 101, "accessMode": "ro", "values": "{\"type\": \"enum\", \"range\": [\"0\", \"1\", \"2\", \"3\", \"4\"]}" }, "102": { "code": "Alarmtype", "custom_name": "", "dp_id": 102, "time": 1729196637488, "type": "Enum", "value": "9", "values": "{\"type\": \"enum\", \"range\": [\"1\", \"2\", \"3\", \"4\", \"5\", \"6\", \"7\", \"8\", \"9\", \"10\", \"11\", \"12\"]}", "id": 102, "accessMode": "rw" }, "103": { "code": "AlarmPeriod", "custom_name": "", "dp_id": 103, "time": 1729196637488, "type": "Integer", "value": 10, "values": "{\"type\": \"value\", \"max\": 60, \"min\": 0, \"scale\": 0, \"step\": 1, \"unit\": \"\u79d2\"}", "id": 103, "accessMode": "rw" }, "104": { "code": "AlarmSwitch", "custom_name": "", "dp_id": 104, "time": 1729196637488, "type": "Boolean", "value": false, "values": "{\"type\": \"bool\"}", "id": 104, "accessMode": "rw" } } } } }