zigpy / zha-device-handlers

ZHA device handlers bridge the functionality gap created when manufacturers deviate from the ZCL specification, handling deviations and exceptions by parsing custom messages to and from Zigbee devices.
Apache License 2.0
750 stars 686 forks source link

[BUG] TS0601 _TZE200_aoclfnxz reports incorrect temperature if below 0 celsius #2795

Closed boskar closed 4 months ago

boskar commented 11 months ago

Bug description

TS0601 _TZE200_aoclfnxz reports incorrect temperature (device probably report signed value)

Steps to reproduce

  1. Go to main site
  2. See that your attic is 6552,1 degrees Celsius
  3. Verify that Your house is not on fire - other sensors reports around 2 degrees Celsius positive (in other rooms)
  4. Must be a bug

Expected behavior

The sensor should report correct, negative temperature

Screenshots/Video

Screenshots/Video ![Screenshot 2023-12-03 at 01-56-21 Przegląd – Home Assistant](https://github.com/zigpy/zha-device-handlers/assets/3456185/da370b22-b29e-4178-998c-b72ed806a9cb) ![Przechwycenie obrazu ekranu_2023-12-03_02-36-38](https://github.com/zigpy/zha-device-handlers/assets/3456185/b9df5cb9-7c24-45e0-ae83-5de488553065)

Device signature

Device signature ```json TS0601 producent: _TZE200_aoclfnxz ```

Diagnostic information

Diagnostic information ```json { "home_assistant": { "installation_type": "Home Assistant Core", "version": "2023.11.3", "dev": false, "hassio": false, "virtualenv": true, "python_version": "3.11.2", "docker": false, "arch": "x86_64", "timezone": "Europe/Warsaw", "os_name": "Linux", "os_version": "6.1.0-13-amd64", "run_as_root": false }, "custom_components": {}, "integration_manifest": { "domain": "zha", "name": "Zigbee Home Automation", "after_dependencies": [ "onboarding", "usb" ], "codeowners": [ "@dmulcahey", "@adminiuga", "@puddly" ], "config_flow": true, "dependencies": [ "file_upload" ], 1111111111110001 0000000000001110 1111111111110001 "documentation": "https://www.home-assistant.io/integrations/zha", "iot_class": "local_polling", "loggers": [ "aiosqlite", "bellows", "crccheck", "pure_pcapy3", "zhaquirks", "zigpy", "zigpy_deconz", "zigpy_xbee", "zigpy_zigate", "zigpy_znp", "universal_silabs_flasher" ], "requirements": [ "bellows==0.36.8", "pyserial==3.5", "pyserial-asyncio==0.6", "zha-quirks==0.0.106", "zigpy-deconz==0.21.1", "zigpy==0.59.0", "zigpy-xbee==0.19.0", "zigpy-zigate==0.11.0", "zigpy-znp==0.11.6", "universal-silabs-flasher==0.0.14", "pyserial-asyncio-fast==0.11" ], "usb": [ { "vid": "10C4", "pid": "EA60", "description": "*2652*", "known_devices": [ "slae.sh cc2652rb stick" ] }, { "vid": "1A86", "pid": "55D4", "description": "*sonoff*plus*", "known_devices": [ "sonoff zigbee dongle plus v2" ] }, { "vid": "10C4", "pid": "EA60", "description": "*sonoff*plus*", "known_devices": [ "sonoff zigbee dongle plus" ] }, { "vid": "10C4", "pid": "EA60", "description": "*tubeszb*", "known_devices": [ "TubesZB Coordinator" ] }, { "vid": "1A86", "pid": "7523", "description": "*tubeszb*", "known_devices": [ "TubesZB Coordinator" ] }, { "vid": "1A86", "pid": "7523", "description": "*zigstar*", "known_devices": [ "ZigStar Coordinators" ] }, { "vid": "1CF1", "pid": "0030", "description": "*conbee*", "known_devices": [ "Conbee II" ] }, { "vid": "10C4", "pid": "8A2A", "description": "*zigbee*", "known_devices": [ "Nortek HUSBZB-1" ] }, { "vid": "0403", "pid": "6015", "description": "*zigate*", "known_devices": [ "ZiGate+" ] }, { "vid": "10C4", "pid": "EA60", "description": "*zigate*", "known_devices": [ "ZiGate" ] }, { "vid": "10C4", "pid": "8B34", "description": "*bv 2010/10*", "known_devices": [ "Bitron Video AV2010/10" ] } ], "zeroconf": [ { "type": "_esphomelib._tcp.local.", "name": "tube*" }, { "type": "_zigate-zigbee-gateway._tcp.local.", "name": "*zigate*" }, { "type": "_zigstar_gw._tcp.local.", "name": "*zigstar*" }, { "type": "_uzg-01._tcp.local.", "name": "uzg-01*" }, { "type": "_slzb-06._tcp.local.", "name": "slzb-06*" } ], "is_built_in": true }, "data": { "ieee": "**REDACTED**", "nwk": 47357, "manufacturer": "_TZE200_aoclfnxz", "model": "TS0601", "name": "_TZE200_aoclfnxz TS0601", "quirk_applied": true, "quirk_class": "zhaquirks.tuya.ts0601_electric_heating.MoesBHT", "quirk_id": null, "manufacturer_code": 4098, "power_source": "Mains", "lqi": 126, "rssi": null, "last_seen": "2023-12-03T02:16:41", "available": true, "device_type": "Router", "signature": { "node_descriptor": "NodeDescriptor(logical_type=, complex_descriptor_available=0, user_descriptor_available=0, reserved=0, aps_flags=0, frequency_band=, mac_capability_flags=, manufacturer_code=4098, maximum_buffer_size=82, maximum_incoming_transfer_size=82, server_mask=11264, maximum_outgoing_transfer_size=82, descriptor_capability_field=, *allocate_address=True, *is_alternate_pan_coordinator=False, *is_coordinator=False, *is_end_device=False, *is_full_function_device=True, *is_mains_powered=True, *is_receiver_on_when_idle=True, *is_router=True, *is_security_capable=False)", "endpoints": { "1": { "profile_id": "0x0104", "device_type": "0x0301", "input_clusters": [ "0x0000", "0x0004", "0x0005", "0x0201", "0x0204", "0xef00" ], "output_clusters": [ "0x000a", "0x0019" ] } }, "manufacturer": "_TZE200_aoclfnxz", "model": "TS0601" }, "active_coordinator": false, "entities": [ { "entity_id": "sensor.tze200_aoclfnxz_ts0601_hvac_action", "name": "_TZE200_aoclfnxz TS0601" }, { "entity_id": "climate.tze200_aoclfnxz_ts0601_thermostat", "name": "_TZE200_aoclfnxz TS0601" } ], "neighbors": [ { "device_type": "Coordinator", "rx_on_when_idle": "On", "relationship": "Parent", "extended_pan_id": "**REDACTED**", "ieee": "**REDACTED**", "nwk": "0x0000", "permit_joining": "Unknown", "depth": "0", "lqi": "180" }, { "device_type": "Router", "rx_on_when_idle": "On", "relationship": "Sibling", "extended_pan_id": "**REDACTED**", "ieee": "**REDACTED**", "nwk": "0x053B", "permit_joining": "Unknown", "depth": "15", "lqi": "151" } ], "routes": [ { "dest_nwk": "0x0000", "route_status": "Active", "memory_constrained": false, "many_to_one": true, "route_record_required": false, "next_hop": "0x0000" } ], "endpoint_names": [ { "name": "THERMOSTAT" } ], "user_given_name": null, "device_reg_id": "28e20c1968e67ad7b9498b74b76ca4e2", "area_id": "salon", "cluster_details": { "1": { "device_type": { "name": "THERMOSTAT", "id": 769 }, "profile_id": 260, "in_clusters": { "0x0000": { "endpoint_attribute": "basic", "attributes": { "0x0001": { "attribute_name": "app_version", "value": 72 }, "0x0004": { "attribute_name": "manufacturer", "value": "_TZE200_aoclfnxz" }, "0x0005": { "attribute_name": "model", "value": "TS0601" } }, "unsupported_attributes": {} }, "0x0004": { "endpoint_attribute": "groups", "attributes": {}, "unsupported_attributes": {} }, "0x0005": { "endpoint_attribute": "scenes", "attributes": {}, "unsupported_attributes": {} }, "0xef00": { "endpoint_attribute": "tuya_manufacturer", "attributes": { "0x0128": { "attribute_name": "child_lock", "value": 0 }, "0x0101": { "attribute_name": "enabled", "value": 0 }, "0x0402": { "attribute_name": "manual_mode", "value": 0 }, "0x0424": { "attribute_name": "running_mode", "value": 1 }, "0x0403": { "attribute_name": "schedule_mode", "value": 1 }, "0x0210": { "attribute_name": "target_temperature", "value": 8 }, "0x0218": { "attribute_name": "temperature", "value": 65521 } }, "unsupported_attributes": {} }, "0x0201": { "endpoint_attribute": "thermostat", "attributes": { "0x001b": { "attribute_name": "ctrl_sequence_of_oper", "value": 2 }, "0x0000": { "attribute_name": "local_temperature", "value": 655210 }, "0x0012": { "attribute_name": "occupied_heating_setpoint", "value": 800 }, "0x0025": { "attribute_name": "programing_oper_mode", "value": 0 }, "0x001e": { "attribute_name": "running_mode", "value": 0 }, "0x0029": { "attribute_name": "running_state", "value": 0 }, "0x001c": { "attribute_name": "system_mode", "value": 0 } }, "unsupported_attributes": { "0x0002": { "attribute_name": "occupancy" }, "0x0003": { "attribute_name": "abs_min_heat_setpoint_limit" }, "0x0004": { "attribute_name": "abs_max_heat_setpoint_limit" }, "0x0005": { "attribute_name": "abs_min_cool_setpoint_limit" }, "0x0006": { "attribute_name": "abs_max_cool_setpoint_limit" }, "0x0016": { "attribute_name": "max_heat_setpoint_limit" }, "0x0007": { "attribute_name": "pi_cooling_demand" }, "0x0008": { "attribute_name": "pi_heating_demand" }, "0x0010": { "attribute_name": "local_temperature_calibration" }, "0x0011": { "attribute_name": "occupied_cooling_setpoint" }, "0x0013": { "attribute_name": "unoccupied_cooling_setpoint" }, "0x0014": { "attribute_name": "unoccupied_heating_setpoint" }, "0x0015": { "attribute_name": "min_heat_setpoint_limit" }, "0x0017": { "attribute_name": "min_cool_setpoint_limit" }, "0x0018": { "attribute_name": "max_cool_setpoint_limit" }, "0x0040": { "attribute_name": "ac_type" } } }, "0x0204": { "endpoint_attribute": "thermostat_ui", "attributes": { "0x0001": { "attribute_name": "keypad_lockout", "value": 0 } }, "unsupported_attributes": {} } }, "out_clusters": { "0x000a": { "endpoint_attribute": "time", "attributes": {}, "unsupported_attributes": {} }, "0x0019": { "endpoint_attribute": "ota", "attributes": {}, "unsupported_attributes": {} } } } } } } ```

Logs

Logs ```python [Paste the logs here] ```

Additional information

655210 (dec) = 1111111111110001 (unsigned 16 bit bin) 1111111111110001 (signed 16 bit bin) = -15 (dec)

https://github.com/zigpy/zha-device-handlers/blob/aeca76da0ea81ecba5b17e0f7314620cd686faae/zhaquirks/tuya/ts0601_electric_heating.py#L39C69-L39C69 t.uint32_t is incorrect? t.int16_t should be used?

javicalle commented 11 months ago

t.uint32_t is incorrect? t.int16_t should be used?

I would suggest to try with a t.int32_t type.

boskar commented 10 months ago

Sorry guys, I need help. Do I need to "recompile" in any way? No matter what modification I make in ts0601_electric_heating.py, after

home-assistant@homeassistant stop 
home-assistant@homeassistant start

the reported temperature remains the same, basically nothing changes in the web panel. the pyc file gets built again, If I put incorrect type (like suggested ```t.int32_t````) the module reports an error, but otherwise I'm stuck with "65526" in temperature (id: 0x0218) - MoesBHTUserInterface (Endpoint id: 1, Id: 0x0204, Type: in)

boskar commented 10 months ago

OK, I still do not know what I was doing wrong in terms of testing my modification, but after full reboot It does take my modifications.

Currently:

gru 24 12:47:18 router hass[920]:   File "/srv/homeassistant/lib/python3.11/site-packages/zigpy/endpoint.py", line 235, in handle_message
gru 24 12:47:18 router hass[920]:     handler(hdr, args, dst_addressing=dst_addressing)
gru 24 12:47:18 router hass[920]:   File "/srv/homeassistant/lib/python3.11/site-packages/zigpy/zcl/__init__.py", line 426, in handle_message
gru 24 12:47:18 router hass[920]:     self.handle_cluster_request(hdr, args, dst_addressing=dst_addressing)
gru 24 12:47:18 router hass[920]:   File "/srv/homeassistant/lib/python3.11/site-packages/zhaquirks/tuya/__init__.py", line 495, in handle_cluster_request
gru 24 12:47:18 router hass[920]:     zvalue = ztype(tuya_data)
gru 24 12:47:18 router hass[920]:              ^^^^^^^^^^^^^^^^
gru 24 12:47:18 router hass[920]:   File "/srv/homeassistant/lib/python3.11/site-packages/zigpy/types/basic.py", line 94, in __new__
gru 24 12:47:18 router hass[920]:     raise ValueError(
gru 24 12:47:18 router hass[920]: ValueError: 65531 is not an signed 16 bit integer

with
MOESBHT_TEMPERATURE_ATTR: ("temperature", t.int16s, True),

I'm afraid it's more complex than that.

github-actions[bot] commented 4 months ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.