make-all / tuya-local

Local support for Tuya devices in Home Assistant
MIT License
1.26k stars 500 forks source link

Request support for Smoke Detector [VisorTech ZX-3150 ] #393

Closed boekerolli closed 1 year ago

boekerolli commented 1 year ago

Hi All, can you please add support for the Smoke Detector VisorTech ZX-3150? Device link: https://amzn.eu/cyc26pv Thanks a lot and best regards, Olli

Tuya IoT API Explorer Info: { "result": { "active_time": 1675671337, "biz_type": 0, "category": "ywbj", "create_time": 1675528362, "icon": "smart/icon/ay1525342462043yjwZs/96630747373f376153371c65e74dbd1f.png", "id": "xxxxxxxxxxxxxxxxxxxxxxxxxxxx", "ip": "XX.XXX.XX.XXX", "lat": "", "local_key": "xxxxxxxxxxxxx", "lon": "", "model": "Komptaker Design Rauchmelder", "name": "RM Nele", "online": true, "owner_id": "80613663", "product_id": "mfslve3lrhjyglaw", "product_name": "ZX-3150 ", "status": [ { "code": "smoke_sensor_state", "value": "normal" }, { "code": "fault", "value": 0 }, { "code": "battery_state", "value": "high" } ], "sub": false, "time_zone": "+01:00", "uid": "xxxxxxxxxxxxxxxxxxxxx", "update_time": 1675671337, "uuid": "xxxxxxxxxxxxxxxxxxxxxxxx" }, "success": true, "t": 1676210309809, "tid": "544aa189aadd11eda120e66c285aff6b" }

make-all commented 1 year ago

Please provide the Log messages, and if possible the iot.tuya.com information that contains dp_id indexes.

boekerolli commented 1 year ago

Hi All, Im not sure, if this are the right dp_id information.... If not please advise, how to get the information. What do you mean with the Log messages? HA or Tuya?

Thanks a lot and best regards Olli

{ "result": { "category": "ywbj", "functions": [], "status": [ { "code": "smoke_sensor_state", "lang_config": { "alarm": "Smoke Alarm", "detecting": "Checking", "normal": "Normal", "unknown": "Unknown" }, "name": "Smoke detection status", "type": "Enum", "values": "{\"range\":[\"alarm\",\"normal\",\"detecting\",\"unknown\"]}" }, { "code": "fault", "lang_config": { "fault": "Fault" }, "name": "False Alarm", "type": "Bitmap", "values": "{\"label\":[\"fault\"],\"maxlen\":1}" }, { "code": "battery_state", "lang_config": { "high": "High", "low": "Low", "middle": "Medium" }, "name": "Battery charge status", "type": "Enum", "values": "{\"range\":[\"low\",\"middle\",\"high\"]}" } ] }, "success": true, "t": 1676276177138, "tid": "b04e3d08ab7611eda120e66c285aff6b" }

make-all commented 1 year ago

I mean the HA logs. After attempting to add the device, and you get offered just a simple switch or some other mismatching devices, there should be a warning in the log which contains the DPS that were available from the device in the raw format they are sent by the local tuya protocol (which can differ slightly from the cloud format above, and may contain additional values).

In particular the "code" in the values listed above is replaced by a numeric code in the local protocol. There is only one function in the API Explorer that returns it as "dp_id", so read the section on finding additional info in README.md carefully. It is also available through the browser developer tools on their device debugger page, but that is more difficult to extract the information from, so only needed for the attributes that are not listed by API Explorer.

But with the log messages, maybe we can guess which matches, since they are usually in the same order and we can match the types.

boekerolli commented 1 year ago

Ah, just found the dp_ids: { "result": { "category": "ywbj", "functions": [], "status": [ { "code": "smoke_sensor_state", "dp_id": 1, "type": "Enum", "values": "{\"range\":[\"alarm\",\"normal\",\"detecting\",\"unknown\"]}" }, { "code": "fault", "dp_id": 11, "type": "Bitmap", "values": "{\"label\":[\"fault\"],\"maxlen\":1}" }, { "code": "battery_state", "dp_id": 14, "type": "Enum", "values": "{\"range\":[\"low\",\"middle\",\"high\"]}" } ] }, "success": true, "t": 1676281374282, "tid": "ca0e1e89ab8211ed9a310aeeb3bc8fba" }

boekerolli commented 1 year ago

Unfortunately I didn´t get the smoke detectors into HA integrated.. Please find the logs from HA below: Thanks and best regards


Dieser Fehler wurde von einer benutzerdefinierten Integration verursacht

Logger: custom_components.tuya_local.device Source: custom_components/tuya_local/device.py:291 Integration: Tuya Local (documentation, issues) First occurred: 17:08:31 (5 occurrences) Last logged: 18:05:31

Failed to refresh device state for Test.



Dieser Fehler wurde von einer benutzerdefinierten Integration verursacht

Logger: aiohttp.server Source: custom_components/tuya_local/device.py:69 Integration: Tuya Local (documentation, issues) First occurred: 17:06:26 (6 occurrences) Last logged: 17:54:08

Error handling request Traceback (most recent call last): File "/usr/local/lib/python3.10/site-packages/aiohttp/web_protocol.py", line 435, in _handle_request resp = await request_handler(request) File "/usr/local/lib/python3.10/site-packages/aiohttp/web_app.py", line 504, in _handle resp = await handler(request) File "/usr/local/lib/python3.10/site-packages/aiohttp/web_middlewares.py", line 117, in impl return await handler(request) File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 60, in security_filter_middleware return await handler(request) File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 100, in forwarded_middleware return await handler(request) File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 28, in request_context_middleware return await handler(request) File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 80, in ban_middleware return await handler(request) File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 236, in auth_middleware return await handler(request) File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 145, in handle result = await result File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 180, in post return await super().post(request, flow_id) File "/usr/src/homeassistant/homeassistant/components/http/data_validator.py", line 72, in wrapper result = await method(view, request, data, *args, **kwargs) File "/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py", line 110, in post result = await self._flow_mgr.async_configure(flow_id, data) File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 253, in async_configure result = await self._async_handle_step( File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 335, in _async_handle_step result: FlowResult = await getattr(flow, method)(user_input) File "/config/custom_components/tuya_local/config_flow.py", line 41, in async_step_user self.device = await async_test_connection(user_input, self.hass) File "/config/custom_components/tuya_local/config_flow.py", line 175, in async_test_connection device = TuyaLocalDevice( File "/config/custom_components/tuya_local/device.py", line 69, in init self._api = tinytuya.Device(dev_id, address, local_key) File "/usr/local/lib/python3.10/site-packages/tinytuya/core.py", line 729, in init bcast_data = find_device(dev_id) File "/usr/local/lib/python3.10/site-packages/tinytuya/core.py", line 524, in find_device client.bind(("", UDPPORT)) OSError: [Errno 98] Address in use


make-all commented 1 year ago

Is this a battery powered device? If so, it will be offline for most of the time and will be virtually impossible to connect to locally. You will have to use it via the cloud.

make-all commented 1 year ago

Actually reading the full trace, the problem is that tinytuya is unable to open the discovery port to resolve the "Auto" IP address. Most likely this will be because localtuya has already claimed it. If you set the IP_ address explicitly, the discovery port will not be needed, and it should get past this.

boekerolli commented 1 year ago

Hmmmm, setting the IP-adress got from my router isn´t successful as well....

make-all commented 1 year ago

From the Amazon page:

Power Source Battery Powered

So I would guess this is only going to work with the cloud, since the local connection will be too intermittent as it goes offline for long periods to conserve battery.

boekerolli commented 1 year ago

I will try it tomorrow again, by deleting the old integrations and new make registration of the device and come back to you...

make-all commented 1 year ago

I think this is out of scope for Tuya local. I will remove the mention of it from the devices file to avoid confusion.