Open kskalski opened 1 month ago
Hi, I have the same problem, and it's my first try with custom quirks, so I don't know if it's a config problem or the quirk file problem... I copied & pasted your code, deleted, reboot HA and re-add the device but doesn't work, do I have to modify a part of this code?
I use the exact same code, placed into
/home/homeassistant/.homeassistant/custom_zha_quirks/TZ3218_ya5d6wth.py
You can check that home assistant log has this line when loading:
WARNING (ImportExecutor_0) [zhaquirks] Loaded custom quirks. Please contribute them to https://github.com/zigpy/zha-device-handlers
and on Zigbee Home Automation integration you should be able to pair it as a new device
Thanks for the answer, I forgot the ".py" in file name..... Now the Quirk is working !!! I changed the device type to DeviceType.ON_OFF_SWITCH to control my floor heating valves. Winter is coming !!! and I'm ready thanks to you !
Problem description
I have a device (model the same as https://www.zigbee2mqtt.io/devices/TYZGTH4CH-D1RF.html) that connects over Zigbee and adds 4 control switches, but the temperature sensor attached to the device is missing from ZHA.
Solution description
Temperature sensor entity should be included.
Screenshots/Video
Screenshots/Video
![IMG20240831172649](https://github.com/user-attachments/assets/dd6994fe-cd1d-4db9-8b88-607beddebb51)Device signature
Device signature
```json { "node_descriptor": "NodeDescriptor(logical_type=Diagnostic information
Diagnostic information
```json { "home_assistant": { "installation_type": "Home Assistant Core", "version": "2024.7.2", "dev": false, "hassio": false, "virtualenv": true, "python_version": "3.12.3", "docker": false, "arch": "aarch64", "timezone": "Europe/Warsaw", "os_name": "Linux", "os_version": "6.8.0-1010-raspi", "run_as_root": false }, "custom_components": { }, "integration_manifest": { "domain": "zha", "name": "Zigbee Home Automation", "after_dependencies": [ "onboarding", "usb" ], "codeowners": [ "dmulcahey", "adminiuga", "puddly", "TheJulianJES" ], "config_flow": true, "dependencies": [ "file_upload" ], "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.39.1", "pyserial==3.5", "zha-quirks==0.0.117", "zigpy-deconz==0.23.2", "zigpy==0.64.1", "zigpy-xbee==0.20.1", "zigpy-zigate==0.12.1", "zigpy-znp==0.12.2", "universal-silabs-flasher==0.0.20", "pyserial-asyncio-fast==0.11" ], "usb": [ { "vid": "10C4", "pid": "EA60", "description": "*2652*", "known_devices": [ "slae.sh cc2652rb stick" ] }, { "vid": "10C4", "pid": "EA60", "description": "*slzb-07*", "known_devices": [ "smlight slzb-07" ] }, { "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": "0403", "pid": "6015", "description": "*conbee*", "known_devices": [ "Conbee III" ] }, { "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*" }, { "type": "_xzg._tcp.local.", "name": "xzg*" }, { "type": "_czc._tcp.local.", "name": "czc*" } ], "is_built_in": true }, "setup_times": { "null": { "setup": 0.00027031199999782984 }, "01J30QNW024QD4XFVS0Q9G76FD": { "wait_import_platforms": -0.0010390540000031478, "wait_base_component": -0.003204721000003019, "config_entry_setup": 18.935454093000004 } }, "data": { "ieee": "**REDACTED**", "nwk": 11187, "manufacturer": "_TZ3218_ya5d6wth", "model": "TS000F", "name": "_TZ3218_ya5d6wth TS000F", "quirk_applied": false, "quirk_class": "zigpy.device.Device", "quirk_id": null, "manufacturer_code": 4417, "power_source": "Mains", "lqi": 144, "rssi": -64, "last_seen": "2024-08-31T15:19:39", "available": true, "device_type": "Router", "signature": { "node_descriptor": "NodeDescriptor(logical_type=Logs
No response
Custom quirk
Custom quirk
Based on discussion from https://community.home-assistant.io/t/zigbee-temperature-sensor-switch-only-detected-as-light/748950/9 and code in https://github.com/klibro/zha-quirks/blob/e53ec83f044628f2f1eed239a0c0f7c4d7743056/TS000F_TZ3218_7fiyo3kv.py I managed to get it to work with: ```python """tuya TS000F _TZ3218_ya5d6wth On/Off In-line Switches with thermometer support.""" from zigpy.profiles import zgp, zha from zigpy.zcl.clusters.general import ( Basic, GreenPowerProxy, Groups, Identify, OnOff, Ota, Scenes, Time, ) from zigpy.zcl.clusters.lightlink import LightLink from zigpy.zcl.clusters.measurement import ( TemperatureMeasurement, ) from zhaquirks.const import ( DEVICE_TYPE, ENDPOINTS, INPUT_CLUSTERS, MODEL, OUTPUT_CLUSTERS, PROFILE_ID, ) from zhaquirks.tuya import ( EnchantedDevice, TuyaZBE000Cluster, TuyaZBOnOffAttributeCluster, TuyaLocalCluster, TuyaZBExternalSwitchTypeCluster, ) from zhaquirks.tuya.mcu import DPToAttributeMapping, TuyaMCUCluster class TuyaTemperatureMeasurement(TemperatureMeasurement, TuyaLocalCluster): """Tuya local TemperatureMeasurement cluster.""" class TemperatureHumidityManufCluster(TuyaMCUCluster): """Tuya Manufacturer Cluster with Temperature and Humidity data points.""" dp_to_attribute: dict[int, DPToAttributeMapping] = { 102: DPToAttributeMapping( TuyaTemperatureMeasurement.ep_attribute, "measured_value", converter=lambda x: x * 10, # decidegree to centidegree ), } data_point_handlers = { 102: "_dp_2_attr_update", } class Tuya_4G_Switch_Temperature(EnchantedDevice): """Tuya 4 gang switch with temperature measurement.""" signature = { MODEL: "TS000F", ENDPOINTS: { 1: { PROFILE_ID: zha.PROFILE_ID, DEVICE_TYPE: zha.DeviceType.ON_OFF_LIGHT, INPUT_CLUSTERS: [ Basic.cluster_id, Identify.cluster_id, Groups.cluster_id, Scenes.cluster_id, OnOff.cluster_id, TuyaZBE000Cluster.cluster_id, TuyaZBExternalSwitchTypeCluster.cluster_id, TemperatureHumidityManufCluster.cluster_id, ], OUTPUT_CLUSTERS: [Time.cluster_id, Ota.cluster_id], }, 2: { PROFILE_ID: zha.PROFILE_ID, DEVICE_TYPE: zha.DeviceType.ON_OFF_LIGHT, INPUT_CLUSTERS: [ Identify.cluster_id, Groups.cluster_id, Scenes.cluster_id, OnOff.cluster_id, TuyaZBExternalSwitchTypeCluster.cluster_id, ], OUTPUT_CLUSTERS: [], }, 3: { PROFILE_ID: zha.PROFILE_ID, DEVICE_TYPE: zha.DeviceType.ON_OFF_LIGHT, INPUT_CLUSTERS: [ Identify.cluster_id, Groups.cluster_id, Scenes.cluster_id, OnOff.cluster_id, TuyaZBExternalSwitchTypeCluster.cluster_id, ], OUTPUT_CLUSTERS: [], }, 4: { PROFILE_ID: zha.PROFILE_ID, DEVICE_TYPE: zha.DeviceType.ON_OFF_LIGHT, INPUT_CLUSTERS: [ Identify.cluster_id, Groups.cluster_id, Scenes.cluster_id, OnOff.cluster_id, TuyaZBExternalSwitchTypeCluster.cluster_id, ], OUTPUT_CLUSTERS: [], }, #Additional information
No response