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
743 stars 679 forks source link

[BUG] Siren TS0216 exposed entities doesn't work #1824

Closed Charisketi closed 1 year ago

Charisketi commented 2 years ago

I have a siren that looks like this:

https://zigbee.blakadder.com/Tuya_TS0216.html

The siren was recognized by zha. The on / off switch works as well as the tamper switch. In the home assistant, I have some entities with functions such as the alarm type, the volume, the strobe function, but they do not work. The only way to change the volume is from the device itself. How can I activate these features in my device management?

siren

Device signature:

{
  "node_descriptor": "NodeDescriptor(logical_type=<LogicalType.Router: 1>, complex_descriptor_available=0, user_descriptor_available=0, reserved=0, aps_flags=0, frequency_band=<FrequencyBand.Freq2400MHz: 8>, mac_capability_flags=<MACCapabilityFlags.AllocateAddress|RxOnWhenIdle|MainsPowered|FullFunctionDevice: 142>, manufacturer_code=4098, maximum_buffer_size=82, maximum_incoming_transfer_size=512, server_mask=11264, maximum_outgoing_transfer_size=512, descriptor_capability_field=<DescriptorCapability.NONE: 0>, *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": 260,
      "device_type": "0x0403",
      "in_clusters": [
        "0x0000",
        "0x000a",
        "0x0500",
        "0x0502",
        "0xef01"
      ],
      "out_clusters": [
        "0x0019"
      ]
    }
  },
  "manufacturer": "_TYZB01_0wcfvptl",
  "model": "TS0216",
  "class": "zigpy.device.Device"
}
javicalle commented 1 year ago

Can you enable the debug logs and attach the relevant info when you interact with the physical device?

It will be hepfull if you can correlate the logs with your actions. For example: "these are the logs when pushing the + button", "these are the logs when volume is max", etc

Logs when you select options in HA are welcomed too.

Charisketi commented 1 year ago

I enable logger with these settings:

logger:
  default: info
  logs:
#    homeassistant.core: debug
#    homeassistant.components.zha: debug
#    bellows.zigbee.application: debug
#    bellows.ezsp: debug
    zigpy: debug
    zigpy_deconz.zigbee.application: debug
    zigpy_deconz.api: debug
#    zigpy_xbee.zigbee.application: debug
#    zigpy_xbee.api: debug
#    zigpy_zigate: debug
#    zigpy_znp: debug
    zhaquirks: debug

I pressed + and - physical siren buttons , also tamber, and then i change siren entities from home assistant dashboard.These are only relative lines with siren TS0216:

2022-10-20 12:43:44.994 DEBUG (MainThread) [zigpy.appdb] [0xf228:1:0x0000] Attribute id: 5 value: TS0216
2022-10-20 12:43:45.271 DEBUG (MainThread) [zigpy.quirks.registry] Checking quirks for _TYZB01_0wcfvptl TS0216 (.....)
2022-10-20 12:43:45.595 DEBUG (MainThread) [zigpy.appdb] [0xf228:1:0x0000] Attribute id: 5 value: TS0216
2022-10-20 12:43:46.063 DEBUG (MainThread) [zigpy_deconz.zigbee.application] device: 0xf228 - _TYZB01_0wcfvptl TS0216, FFD=True, Rx_on_when_idle=True
2022-10-20 12:43:46.381 DEBUG (MainThread) [homeassistant.components.zha.core.gateway] [0xF228](_TYZB01_0wcfvptl TS0216) restored as 'available', last seen: 0:01:07 ago, consider_unavailable_time: 7200 seconds
2022-10-20 12:43:46.392 DEBUG (MainThread) [homeassistant.components.zha.core.device] [0xF228](TS0216): started initialization
2022-10-20 12:43:46.392 DEBUG (MainThread) [homeassistant.components.zha.core.channels.base] [0xF228:ZDO](TS0216): 'async_initialize' stage succeeded
2022-10-20 12:43:46.483 DEBUG (MainThread) [homeassistant.components.zha.core.device] [0xF228](TS0216): power source: Mains
2022-10-20 12:43:46.483 DEBUG (MainThread) [homeassistant.components.zha.core.device] [0xF228](TS0216): completed initialization
2022-10-20 12:43:46.495 DEBUG (MainThread) [homeassistant.components.zha.core.device] [0xF228](TS0216): started initialization
2022-10-20 12:43:46.495 DEBUG (MainThread) [homeassistant.components.zha.core.channels.base] [0xF228:ZDO](TS0216): 'async_initialize' stage succeeded
2022-10-20 12:43:50.978 DEBUG (MainThread) [homeassistant.components.zha.core.device] [0xF228](TS0216): power source: Mains
2022-10-20 12:43:50.978 DEBUG (MainThread) [homeassistant.components.zha.core.device] [0xF228](TS0216): completed initialization
2022-10-20 12:44:53.381 DEBUG (MainThread) [homeassistant.components.zha.core.device] [0xF228](TS0216): Device seen - marking the device available and resetting counter
2022-10-20 12:44:53.381 DEBUG (MainThread) [homeassistant.components.zha.core.device] [0xF228](TS0216): Update device availability -  device available: True - new availability: True - changed: False
2022-10-20 12:46:00.382 DEBUG (MainThread) [homeassistant.components.zha.core.device] [0xF228](TS0216): Device seen - marking the device available and resetting counter
2022-10-20 12:46:00.383 DEBUG (MainThread) [homeassistant.components.zha.core.device] [0xF228](TS0216): Update device availability -  device available: True - new availability: True - changed: False
2022-10-20 12:47:07.383 DEBUG (MainThread) [homeassistant.components.zha.core.device] [0xF228](TS0216): Device seen - marking the device available and resetting counter
2022-10-20 12:47:07.383 DEBUG (MainThread) [homeassistant.components.zha.core.device] [0xF228](TS0216): Update device availability -  device available: True - new availability: True - changed: False
2022-10-20 12:48:14.384 DEBUG (MainThread) [homeassistant.components.zha.core.device] [0xF228](TS0216): Device seen - marking the device available and resetting counter
2022-10-20 12:48:14.384 DEBUG (MainThread) [homeassistant.components.zha.core.device] [0xF228](TS0216): Update device availability -  device available: True - new availability: True - changed: False
2022-10-20 12:49:21.384 DEBUG (MainThread) [homeassistant.components.zha.core.device] [0xF228](TS0216): Device seen - marking the device available and resetting counter
2022-10-20 12:49:21.384 DEBUG (MainThread) [homeassistant.components.zha.core.device] [0xF228](TS0216): Update device availability -  device available: True - new availability: True - changed: False
2022-10-20 12:50:28.384 DEBUG (MainThread) [homeassistant.components.zha.core.device] [0xF228](TS0216): Device seen - marking the device available and resetting counter
2022-10-20 12:50:28.384 DEBUG (MainThread) [homeassistant.components.zha.core.device] [0xF228](TS0216): Update device availability -  device available: True - new availability: True - changed: False
2022-10-20 12:51:35.385 DEBUG (MainThread) [homeassistant.components.zha.core.device] [0xF228](TS0216): Device seen - marking the device available and resetting counter
2022-10-20 12:51:35.385 DEBUG (MainThread) [homeassistant.components.zha.core.device] [0xF228](TS0216): Update device availability -  device available: True - new availability: True - changed: False
2022-10-20 12:52:42.385 DEBUG (MainThread) [homeassistant.components.zha.core.device] [0xF228](TS0216): Device seen - marking the device available and resetting counter
2022-10-20 12:52:42.392 DEBUG (MainThread) [homeassistant.components.zha.core.device] [0xF228](TS0216): Update device availability -  device available: True - new availability: True - changed: False
2022-10-20 12:53:49.386 DEBUG (MainThread) [homeassistant.components.zha.core.device] [0xF228](TS0216): Device seen - marking the device available and resetting counter
2022-10-20 12:53:49.386 DEBUG (MainThread) [homeassistant.components.zha.core.device] [0xF228](TS0216): Update device availability -  device available: True - new availability: True - changed: False
2022-10-20 12:54:56.387 DEBUG (MainThread) [homeassistant.components.zha.core.device] [0xF228](TS0216): Device seen - marking the device available and resetting counter
2022-10-20 12:54:56.387 DEBUG (MainThread) [homeassistant.components.zha.core.device] [0xF228](TS0216): Update device availability -  device available: True - new availability: True - changed: False
2022-10-20 12:56:03.387 DEBUG (MainThread) [homeassistant.components.zha.core.device] [0xF228](TS0216): Device seen - marking the device available and resetting counter
2022-10-20 12:56:03.387 DEBUG (MainThread) [homeassistant.components.zha.core.device] [0xF228](TS0216): Update device availability -  device available: True - new availability: True - changed: False
2022-10-20 12:57:10.388 DEBUG (MainThread) [homeassistant.components.zha.core.device] [0xF228](TS0216): Device seen - marking the device available and resetting counter
2022-10-20 12:57:10.388 DEBUG (MainThread) [homeassistant.components.zha.core.device] [0xF228](TS0216): Update device availability -  device available: True - new availability: True - changed: False
2022-10-20 12:58:17.389 DEBUG (MainThread) [homeassistant.components.zha.core.device] [0xF228](TS0216): Device seen - marking the device available and resetting counter
2022-10-20 12:58:17.389 DEBUG (MainThread) [homeassistant.components.zha.core.device] [0xF228](TS0216): Update device availability -  device available: True - new availability: True - changed: False
2022-10-20 12:59:24.390 DEBUG (MainThread) [homeassistant.components.zha.core.device] [0xF228](TS0216): Device seen - marking the device available and resetting counter
2022-10-20 12:59:24.390 DEBUG (MainThread) [homeassistant.components.zha.core.device] [0xF228](TS0216): Update device availability -  device available: True - new availability: True - changed: False
2022-10-20 13:00:31.391 DEBUG (MainThread) [homeassistant.components.zha.core.device] [0xF228](TS0216): Device seen - marking the device available and resetting counter
2022-10-20 13:00:31.391 DEBUG (MainThread) [homeassistant.components.zha.core.device] [0xF228](TS0216): Update device availability -  device available: True - new availability: True - changed: False
2022-10-20 13:01:38.392 DEBUG (MainThread) [homeassistant.components.zha.core.device] [0xF228](TS0216): Device seen - marking the device available and resetting counter
2022-10-20 13:01:38.392 DEBUG (MainThread) [homeassistant.components.zha.core.device] [0xF228](TS0216): Update device availability -  device available: True - new availability: True - changed: False
2022-10-20 13:02:45.392 DEBUG (MainThread) [homeassistant.components.zha.core.device] [0xF228](TS0216): Device seen - marking the device available and resetting counter
2022-10-20 13:02:45.392 DEBUG (MainThread) [homeassistant.components.zha.core.device] [0xF228](TS0216): Update device availability -  device available: True - new availability: True - changed: False
2022-10-20 12:43:44.990 DEBUG (MainThread) [zigpy.appdb] [0xf228:1:0x0000] Attribute id: 4 value: _TYZB01_0wcfvptl
2022-10-20 12:43:45.595 DEBUG (MainThread) [zigpy.appdb] [0xf228:1:0x0000] Attribute id: 4 value: _TYZB01_0wcfvptl
2022-10-20 12:43:46.063 DEBUG (MainThread) [zigpy_deconz.zigbee.application] device: 0xf228 - _TYZB01_0wcfvptl TS0216, FFD=True, Rx_on_when_idle=True
2022-10-20 12:43:46.381 DEBUG (MainThread) [homeassistant.components.zha.core.gateway] [0xF228](_TYZB01_0wcfvptl TS0216) restored as 'available', last seen: 0:01:07 ago, consider_unavailable_time: 7200 seconds
javicalle commented 1 year ago

That seems the pairing logs for your device.

Please enable at least also the homeassistant.components.zha: debug.

And maintain some related logs to events. We need to track something like:

2022-10-12 21:05:14.754 DEBUG (MainThread) [zigpy.application] Received a packet: ZigbeePacket(src=AddrModeAddress(addr_mode=<AddrMode.NWK: 2>, address=0xB4E7), src_ep=1, dst=AddrModeAddress(addr_mode=<AddrMode.NWK: 2>, address=0x0000), dst_ep=1, source_route=None, extended_timeout=False, tsn=231, profile_id=260, cluster_id=61184, data=Serialized[b'\t_\x01\x00\t\x01\x04\x00\x01\x00'], tx_options=<TransmitOptions.NONE: 0>, radius=0, non_member_radius=0, lqi=216, rssi=-46)
2022-10-12 21:05:14.755 DEBUG (MainThread) [zigpy.zcl] [0xB4E7:1:0xef00] Received ZCL frame: b'\t_\x01\x00\t\x01\x04\x00\x01\x00'
2022-10-12 21:05:14.756 DEBUG (MainThread) [zigpy.zcl] [0xB4E7:1:0xef00] Decoded ZCL frame header: ZCLHeader(frame_control=FrameControl(frame_type=<FrameType.CLUSTER_COMMAND: 1>, is_manufacturer_specific=0, direction=<Direction.Client_to_Server: 1>, disable_default_response=0, reserved=0, *is_cluster=True, *is_general=False, *is_reply=True), tsn=95, command_id=1, *direction=<Direction.Client_to_Server: 1>, *is_reply=True)
2022-10-12 21:05:14.757 DEBUG (MainThread) [zigpy.zcl] [0xB4E7:1:0xef00] Decoded ZCL frame: AtlanticSwitchManufCluster:get_data(data=TuyaCommand(status=0, tsn=9, datapoints=[TuyaDatapointData(dp=1, data=TuyaData(dp_type=<TuyaDPType.ENUM: 4>, function=0, raw=b'\x00', *payload=<enum8.undefined_0x00: 0>))]))
2022-10-12 21:05:14.758 DEBUG (MainThread) [zigpy.zcl] [0xB4E7:1:0xef00] Received command 0x01 (TSN 95): get_data(data=TuyaCommand(status=0, tsn=9, datapoints=[TuyaDatapointData(dp=1, data=TuyaData(dp_type=<TuyaDPType.ENUM: 4>, function=0, raw=b'\x00', *payload=<enum8.undefined_0x00: 0>))]))
2022-10-12 21:05:14.775 DEBUG (MainThread) [zigpy.zcl] [0xB4E7:1:0xef00] Sending reply header: ZCLHeader(frame_control=FrameControl(frame_type=<FrameType.GLOBAL_COMMAND: 0>, is_manufacturer_specific=False, direction=<Direction.Client_to_Server: 1>, disable_default_response=1, reserved=0, *is_cluster=False, *is_general=True, *is_reply=True), tsn=95, command_id=<GeneralCommand.Default_Response: 11>, *direction=<Direction.Client_to_Server: 1>, *is_reply=True)
2022-10-12 21:05:14.776 DEBUG (MainThread) [zigpy.zcl] [0xB4E7:1:0xef00] Sending reply: Default_Response(command_id=1, status=<Status.SUCCESS: 0>)
2022-10-12 21:05:14.777 DEBUG (MainThread) [bellows.zigbee.application] Sending packet ZigbeePacket(src=AddrModeAddress(addr_mode=<AddrMode.NWK: 2>, address=0x0000), src_ep=1, dst=AddrModeAddress(addr_mode=<AddrMode.NWK: 2>, address=0xB4E7), dst_ep=1, source_route=None, extended_timeout=False, tsn=95, profile_id=260, cluster_id=61184, data=Serialized[b'\x18_\x0b\x01\x00'], tx_options=<TransmitOptions.NONE: 0>, radius=0, non_member_radius=0, lqi=None, rssi=None)
2022-10-12 21:05:14.779 DEBUG (MainThread) [bellows.ezsp.protocol] Send command sendUnicast: (<EmberOutgoingMessageType.OUTGOING_DIRECT: 0>, 0xb4e7, EmberApsFrame(profileId=260, clusterId=61184, sourceEndpoint=1, destinationEndpoint=1, options=<EmberApsOption.APS_OPTION_ENABLE_ROUTE_DISCOVERY|APS_OPTION_RETRY: 320>, groupId=0, sequence=95), 19, b'\x18_\x0b\x01\x00')

2022-10-12 21:05:14.922 DEBUG (MainThread) [bellows.zigbee.application] Received incomingMessageHandler frame with [<EmberIncomingMessageType.INCOMING_UNICAST: 0>, EmberApsFrame(profileId=260, clusterId=61184, sourceEndpoint=1, destinationEndpoint=1, options=<EmberApsOption.APS_OPTION_ENABLE_ROUTE_DISCOVERY: 256>, groupId=0, sequence=232), 216, -46, 0xb4e7, 255, 255, b'\t_\x01\x00\t\x01\x04\x00\x01\x00']
2022-10-12 21:05:14.923 DEBUG (MainThread) [zigpy.application] Received a packet: ZigbeePacket(src=AddrModeAddress(addr_mode=<AddrMode.NWK: 2>, address=0xB4E7), src_ep=1, dst=AddrModeAddress(addr_mode=<AddrMode.NWK: 2>, address=0x0000), dst_ep=1, source_route=None, extended_timeout=False, tsn=232, profile_id=260, cluster_id=61184, data=Serialized[b'\t_\x01\x00\t\x01\x04\x00\x01\x00'], tx_options=<TransmitOptions.NONE: 0>, radius=0, non_member_radius=0, lqi=216, rssi=-46)
2022-10-12 21:05:14.924 DEBUG (MainThread) [zigpy.zcl] [0xB4E7:1:0xef00] Received ZCL frame: b'\t_\x01\x00\t\x01\x04\x00\x01\x00'
2022-10-12 21:05:14.925 DEBUG (MainThread) [zigpy.zcl] [0xB4E7:1:0xef00] Decoded ZCL frame header: ZCLHeader(frame_control=FrameControl(frame_type=<FrameType.CLUSTER_COMMAND: 1>, is_manufacturer_specific=0, direction=<Direction.Client_to_Server: 1>, disable_default_response=0, reserved=0, *is_cluster=True, *is_general=False, *is_reply=True), tsn=95, command_id=1, *direction=<Direction.Client_to_Server: 1>, *is_reply=True)
2022-10-12 21:05:14.927 DEBUG (MainThread) [zigpy.zcl] [0xB4E7:1:0xef00] Decoded ZCL frame: AtlanticSwitchManufCluster:get_data(data=TuyaCommand(status=0, tsn=9, datapoints=[TuyaDatapointData(dp=1, data=TuyaData(dp_type=<TuyaDPType.ENUM: 4>, function=0, raw=b'\x00', *payload=<enum8.undefined_0x00: 0>))]))

2022-10-11 00:24:17.293 DEBUG (MainThread) [homeassistant.components.zha.entity] light.tz3210_ngqk6jia_ts110e_light: setting transitioning flag to True
2022-10-11 00:24:17.296 DEBUG (MainThread) [zigpy.zcl] [0xD1C0:1:0x0008] Sending Cluster Command. Cluster Command is 4, Arguments are ()
2022-10-11 00:24:17.297 DEBUG (MainThread) [zigpy.zcl] [0xD1C0:1:0x0008] Setting brightness to 1000
2022-10-11 00:24:17.307 DEBUG (MainThread) [zigpy.zcl] [0xD1C0:1:0x0008] Setting the NO manufacturer id in command: 240
2022-10-11 00:24:17.318 DEBUG (MainThread) [zigpy.zcl] [0xD1C0:1:0x0008] Sending request header: ZCLHeader(frame_control=FrameControl(frame_type=<FrameType.CLUSTER_COMMAND: 1>, is_manufacturer_specific=False, direction=<Direction.Server_to_Client: 0>, disable_default_response=0, reserved=0, *is_cluster=True, *is_general=False, *is_reply=False), tsn=7, command_id=240, *direction=<Direction.Server_to_Client: 0>, *is_reply=False)
2022-10-11 00:24:17.322 DEBUG (MainThread) [zigpy.zcl] [0xD1C0:1:0x0008] Sending request: schema(param1=TuyaLevelPayload(level=1000, transtime=0))
2022-10-11 00:24:17.329 DEBUG (MainThread) [zigpy_znp.zigbee.application] Sending packet ZigbeePacket(src=AddrModeAddress(addr_mode=<AddrMode.NWK: 2>, address=0x0000), src_ep=1, dst=AddrModeAddress(addr_mode=<AddrMode.NWK: 2>, address=0xD1C0), dst_ep=1, source_route=None, extended_timeout=False, tsn=7, profile_id=260, cluster_id=8, data=Serialized[b'\x01\x07\xf0\xe8\x03\x00\x00'], tx_options=<TransmitOptions.ACK: 1>, radius=0, non_member_radius=0, lqi=None, rssi=None)
2022-10-11 00:24:17.342 DEBUG (MainThread) [zigpy_znp.api] Sending request: AF.DataRequestExt.Req(DstAddrModeAddress=AddrModeAddress(mode=<AddrMode.NWK: 2>, address=0xD1C0), DstEndpoint=1, DstPanId=0x0000, SrcEndpoint=1, ClusterId=8, TSN=7, Options=<TransmitOptions.SUPPRESS_ROUTE_DISC_NETWORK|ACK_REQUEST: 48>, Radius=0, Data=b'\x01\x07\xF0\xE8\x03\x00\x00')
2022-10-11 00:24:17.377 DEBUG (MainThread) [zigpy_znp.api] Received command: AF.DataRequestExt.Rsp(Status=<Status.SUCCESS: 0>)
Charisketi commented 1 year ago

Hello! I use conbee 2 and ZHA. I changed my logger to:

logger:
  default: info
  logs:
    homeassistant.core: debug
    homeassistant.components.zha: debug
    bellows.zigbee.application: debug
    bellows.ezsp: debug
    zigpy: debug
    zigpy_deconz.zigbee.application: debug
    zigpy_deconz.api: debug
    zigpy_xbee.zigbee.application: debug
    zigpy_xbee.api: debug
    zigpy_zigate: debug
    zigpy_znp: debug
    zhaquirks: debug

My log file is massive because i use a lot of zigbee devices. So i try to filter log results using "TS0216" and "_TYZB01_0wcfvptl" Below are filtered results.

    Line  1339: 2022-10-24 13:29:23.918 DEBUG (MainThread) [zigpy.appdb] [0xf228:1:0x0000] Attribute id: 4 value: _TYZB01_0wcfvptl
    Line  1955: 2022-10-24 13:29:23.950 DEBUG (MainThread) [zigpy.quirks.registry] Checking quirks for _TYZB01_0wcfvptl TS0216 (::::::)
    Line  2759: 2022-10-24 13:29:24.331 DEBUG (MainThread) [zigpy.appdb] [0xf228:1:0x0000] Attribute id: 4 value: _TYZB01_0wcfvptl
    Line  2949: 2022-10-24 13:29:24.784 DEBUG (MainThread) [zigpy_deconz.zigbee.application] device: 0xf228 - _TYZB01_0wcfvptl TS0216, FFD=True, Rx_on_when_idle=True
    Line  3545: 2022-10-24 13:29:25.035 DEBUG (MainThread) [homeassistant.components.zha.core.gateway] [0xF228](_TYZB01_0wcfvptl TS0216) restored as 'available', last seen: 0:00:58 ago, consider_unavailable_time: 7200 seconds
    Line  1505: 2022-10-24 13:17:39.949 DEBUG (MainThread) [zigpy.appdb] [0xf228:1:0x0000] Attribute id: 5 value: TS0216
    Line  2125: 2022-10-24 13:17:40.282 DEBUG (MainThread) [zigpy.quirks.registry] Checking quirks for _TYZB01_0wcfvptl TS0216 (:::::)
    Line  3065: 2022-10-24 13:17:41.365 DEBUG (MainThread) [zigpy.appdb] [0xf228:1:0x0000] Attribute id: 5 value: TS0216
    Line  3372: 2022-10-24 13:17:42.275 DEBUG (MainThread) [zigpy_deconz.zigbee.application] device: 0xf228 - _TYZB01_0wcfvptl TS0216, FFD=True, Rx_on_when_idle=True
    Line  3954: 2022-10-24 13:17:42.546 DEBUG (MainThread) [homeassistant.components.zha.core.gateway] [0xF228](_TYZB01_0wcfvptl TS0216) restored as 'available', last seen: 0:03:00 ago, consider_unavailable_time: 7200 seconds
    Line  4090: 2022-10-24 13:17:42.559 DEBUG (MainThread) [homeassistant.components.zha.core.device] [0xF228](TS0216): started initialization
    Line  4091: 2022-10-24 13:17:42.559 DEBUG (MainThread) [homeassistant.components.zha.core.channels.base] [0xF228:ZDO](TS0216): 'async_initialize' stage succeeded
    Line  6159: 2022-10-24 13:17:42.647 DEBUG (MainThread) [homeassistant.components.zha.core.device] [0xF228](TS0216): power source: Mains
    Line  6160: 2022-10-24 13:17:42.647 DEBUG (MainThread) [homeassistant.components.zha.core.device] [0xF228](TS0216): completed initialization
    Line  6233: 2022-10-24 13:17:42.653 DEBUG (MainThread) [homeassistant.components.zha.core.device] [0xF228](TS0216): started initialization
    Line  6234: 2022-10-24 13:17:42.653 DEBUG (MainThread) [homeassistant.components.zha.core.channels.base] [0xF228:ZDO](TS0216): 'async_initialize' stage succeeded
    Line 15714: 2022-10-24 13:18:32.019 DEBUG (MainThread) [homeassistant.components.zha.core.device] [0xF228](TS0216): power source: Mains
    Line 15715: 2022-10-24 13:18:32.019 DEBUG (MainThread) [homeassistant.components.zha.core.device] [0xF228](TS0216): completed initialization
    Line 16495: 2022-10-24 13:19:09.546 DEBUG (MainThread) [homeassistant.components.zha.core.device] [0xF228](TS0216): Device seen - marking the device available and resetting counter
    Line 16496: 2022-10-24 13:19:09.546 DEBUG (MainThread) [homeassistant.components.zha.core.device] [0xF228](TS0216): Update device availability -  device available: True - new availability: True - changed: False
    Line 26079: 2022-10-24 13:20:36.546 DEBUG (MainThread) [homeassistant.components.zha.core.device] [0xF228](TS0216): Device seen - marking the device available and resetting counter
    Line 26080: 2022-10-24 13:20:36.546 DEBUG (MainThread) [homeassistant.components.zha.core.device] [0xF228](TS0216): Update device availability -  device available: True - new availability: True - changed: False

I also download diagnostics from the device:

zha-26ec3139cb678489c574327ee16f28bc-_TYZB01_0wcfvptl TS0216-7e99fe56646d5cec7de410aa3312bee8.json.txt

Is there a way to filter the results you need? I also can upload entire log file if you need it.

Charisketi commented 1 year ago

@javicalle can i offer any other information that might help? I realize I'm not providing enough information. You can guide me if you want to be able to contribute what is needed. I would appreciate any help possible.

javicalle commented 1 year ago

I have been busy this days and some issues have been left unattended. When I can I'll take a look at it and tell you something.

javicalle commented 1 year ago

Ok, let's see if we can move forward on this issue.

In addition to the indicated filters, it would be very useful if you include the Nwk filter of the device (you can see it in the 'Zigbee info' of the device view). It seems to be 0xf228 We need to have the traces of the Zigpy library to have more information.

I am aware that the debug logs can be very verbose. One thing that can be very helpfull is to have a tail of the homeassistant.log log activated and interact with the device. That way it is easier to identify which logs generate each event. Correlating the logs with the events is very helpful.

javicalle commented 1 year ago

Ok, according to Z2M is just some extended IasWd cluster.

That is my very early version for that device:

ts0216.py ```python """Map from manufacturer to standard clusters for the NEO Siren device.""" import logging from zigpy.profiles import zha from zigpy.quirks import CustomDevice import zigpy.types as t from zigpy.zcl.clusters.general import Basic, Ota, Time from zigpy.zcl.clusters.security import IasWd, IasZone from zhaquirks.const import ( DEVICE_TYPE, ENDPOINTS, INPUT_CLUSTERS, MODEL, OUTPUT_CLUSTERS, PROFILE_ID, ) TUYA_VOLUME_ATTR = 0x0002 TUYA_ALARM_ATTR = 0xF000 _LOGGER = logging.getLogger(__name__) class TuyaIasWd(IasWd): """Tuya IasWd cluster with custom attributes.""" attributes = IasWd.attributes.copy() attributes.update( { TUYA_VOLUME_ATTR: ("volume", t.uint8_t, True), TUYA_ALARM_ATTR: ("alarm", t.Bool, True), } ) class TuyaSiren(CustomDevice): """TS0216 Tuya Siren.""" 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=512, server_mask=11264, maximum_outgoing_transfer_size=512, # 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)", MODEL: "TS0216", ENDPOINTS: { 1: { # "profile_id": 260, # "device_type": "0x0403", # "in_clusters": ["0x0000","0x000a","0x0500","0x0502","0xef01"], # "out_clusters": ["0x0019"] PROFILE_ID: zha.PROFILE_ID, DEVICE_TYPE: zha.DeviceType.IAS_WARNING_DEVICE, INPUT_CLUSTERS: [ Basic.cluster_id, Time.cluster_id, IasZone.cluster_id, IasWd.cluster_id, 0xEF01, ], OUTPUT_CLUSTERS: [Ota.cluster_id], }, }, } replacement = { # in Z2M they are updating *is_router=False ENDPOINTS: { 1: { INPUT_CLUSTERS: [ Basic.cluster_id, Time.cluster_id, IasZone.cluster_id, TuyaIasWd, 0xEF01, ], OUTPUT_CLUSTERS: [Ota.cluster_id], }, } } ```

You will need to enable the local quirk in your instalation. There is a guide about enabling custom quirks:

Create a ts0216.py file in your local quirk folder and put the suggested quirk in the file.

Restart HA, remove and pair you device again. Check that the device is loading the quirk and that the device signature has changed.

For now there will only be 2 new attributes in the IasWd cluster, no UI control yet. You should be able to modify the configuration by changing the values from the 'Manage Zigbee Device' popup in the device view and selecting the TuyaIasWd cluster.

javicalle commented 1 year ago

For future reference:

Charisketi commented 1 year ago

Hello @javicalle ! I followed your instructions. Now i'm able to see TuyaIasWd cluster in "Manage Zigbee Device". The problem is that i'm not able to register any attribute. If i register and then read the attribute i always get "None". The device signature is:

{
  "node_descriptor": "NodeDescriptor(logical_type=<LogicalType.Router: 1>, complex_descriptor_available=0, user_descriptor_available=0, reserved=0, aps_flags=0, frequency_band=<FrequencyBand.Freq2400MHz: 8>, mac_capability_flags=<MACCapabilityFlags.AllocateAddress|RxOnWhenIdle|MainsPowered|FullFunctionDevice: 142>, manufacturer_code=4098, maximum_buffer_size=82, maximum_incoming_transfer_size=512, server_mask=11264, maximum_outgoing_transfer_size=512, descriptor_capability_field=<DescriptorCapability.NONE: 0>, *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": 260,
      "device_type": "0x0403",
      "in_clusters": [
        "0x0000",
        "0x000a",
        "0x0500",
        "0x0502",
        "0xef01"
      ],
      "out_clusters": [
        "0x0019"
      ]
    }
  },
  "manufacturer": "_TYZB01_0wcfvptl",
  "model": "TS0216",
  "class": "zigpy.device.Device"
}

Screenshot_3 Screenshot_4

Also on home assistant log i get these errors:

Unexpected error handling the frame

Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/zigpy_deconz/uart.py", line 84, in data_received
    self._api.data_received(frame)
  File "/usr/local/lib/python3.10/site-packages/zigpy_deconz/api.py", line 373, in data_received
    getattr(self, f"_handle_{command.name}")(data)
  File "/usr/local/lib/python3.10/site-packages/zigpy_deconz/api.py", line 505, in _handle_aps_data_indication
    self._app.handle_rx(
  File "/usr/local/lib/python3.10/site-packages/zigpy_deconz/zigbee/application.py", line 426, in handle_rx
    self.packet_received(
  File "/usr/local/lib/python3.10/site-packages/zigpy/application.py", line 842, in packet_received
    self.handle_message(
  File "/usr/local/lib/python3.10/site-packages/zigpy/application.py", line 348, in handle_message
    return sender.handle_message(
  File "/usr/local/lib/python3.10/site-packages/zigpy/device.py", line 371, in handle_message
    return endpoint.handle_message(
  File "/usr/local/lib/python3.10/site-packages/zigpy/endpoint.py", line 224, in handle_message
    handler(hdr, args, dst_addressing=dst_addressing)
  File "/usr/local/lib/python3.10/site-packages/zigpy/zcl/__init__.py", line 377, in handle_message
    self.handle_cluster_general_request(hdr, args, dst_addressing=dst_addressing)
  File "/usr/local/lib/python3.10/site-packages/zigpy/zcl/__init__.py", line 412, in handle_cluster_general_request
    value = self.attributes[attr.attrid].type(attr.value.value)
  File "/usr/local/lib/python3.10/site-packages/zigpy/types/basic.py", line 91, in __new__
    n = super().__new__(cls, *args, **kwargs)
TypeError: int() argument must be a string, a bytes-like object or a real number, not 'data8'

[0xF228:1:0x0502] Failed to convert attribute 0x0002 from (<class 'str'>) to type <class 'zigpy.types.basic.uint8_t'>: invalid literal for int() with base 10: ''

Unexpected error handling the frame

Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/zigpy_deconz/uart.py", line 84, in data_received
    self._api.data_received(frame)
  File "/usr/local/lib/python3.10/site-packages/zigpy_deconz/api.py", line 373, in data_received
    getattr(self, f"_handle_{command.name}")(data)
  File "/usr/local/lib/python3.10/site-packages/zigpy_deconz/api.py", line 505, in _handle_aps_data_indication
    self._app.handle_rx(
  File "/usr/local/lib/python3.10/site-packages/zigpy_deconz/zigbee/application.py", line 426, in handle_rx
    self.packet_received(
  File "/usr/local/lib/python3.10/site-packages/zigpy/application.py", line 842, in packet_received
    self.handle_message(
  File "/usr/local/lib/python3.10/site-packages/zigpy/application.py", line 348, in handle_message
    return sender.handle_message(
  File "/usr/local/lib/python3.10/site-packages/zigpy/device.py", line 371, in handle_message
    return endpoint.handle_message(
  File "/usr/local/lib/python3.10/site-packages/zigpy/endpoint.py", line 224, in handle_message
    handler(hdr, args, dst_addressing=dst_addressing)
  File "/usr/local/lib/python3.10/site-packages/zigpy/zcl/__init__.py", line 377, in handle_message
    self.handle_cluster_general_request(hdr, args, dst_addressing=dst_addressing)
  File "/usr/local/lib/python3.10/site-packages/zigpy/zcl/__init__.py", line 412, in handle_cluster_general_request
    value = self.attributes[attr.attrid].type(attr.value.value)
  File "/usr/local/lib/python3.10/site-packages/zigpy/types/basic.py", line 295, in __call__
    value = int(value)
TypeError: int() argument must be a string, a bytes-like object or a real number, not 'data8'
javicalle commented 1 year ago

You must put the value in the 'value' field, and leave the 'manufacturer code override' in blank.

Also check if the value gets updated when you change the volume from the device (select the attribute and push the 'get attribute' after every change).

Any log from your tests are welcomed.

MattWestb commented 1 year ago

@Charisketi The "class": "zigpy.device.Device" is saying that the quirk is not loaded of the system so somthing its not OK i the quirk signature. Have you adding your device in MODELS_INFO: ?

javicalle commented 1 year ago

🤦🏻‍♂️ Ouuuch! @MattWestb thanks for chasing the error!

I have updated this part of the code. But in the screenshoot it seems that the TuyaIasWd is there, so must have fixed that.

MattWestb commented 1 year ago

ZHA some time is not loading the quirk also then its OK defined (happens for my then testing and editing quirk intensive in the system). Can trying doing one reload of ZHA integration and see if its loading the quirk OK. Also as you was saying the tuya specific cluster is being used so its little strange.

javicalle commented 1 year ago

Also as you was saying the tuya specific cluster is being used so its little strange.

Yes, there is a 'new' 0xEF01 cluster but in Z2M seems that there is no use for it (for now).

Charisketi commented 1 year ago

@MattWestb the signature is not changed with custom quirk and is the same with signature i had before. I follow the instructions with the custom quirk and as i can see in quirk @javicalle posted there is a MODELS_INFO: [("_TZE200_t1blo2bj", "TS0601")

In my custom_zha_quirks folder with ts0216.py is created also a folder pycache .

@javicalle I try to change the value and not "manufacturer code override" as you told me and is working for volume and duration.

I also check if the values updated when i manualy change volume from physical device and they are updated

One strange behavior with siren ui is that when i click the switch to turn it on, it auto switch to off in 7 sec. This has nothing to do with siren duration, because siren keeps working after ui switch is turned off according to duration i give in the device cluster configuration.

Charisketi commented 1 year ago

@MattWestb i also reload ZHA integration but nothing changed on device signature

javicalle commented 1 year ago

Delete the __pycache__ folder on every restart. I have changed the MODELS_INFO part. Update the code with the current version from my comment, delete the __pycache__ folder, restart HA and re pair the device.

javicalle commented 1 year ago

So, more or less, the device is functional now?

Charisketi commented 1 year ago

I try it from the beginning. So i delete my siren device also both "ts0216.py" and "pycache" on custom quirks folder, then i put in custom quirks folder the new code file and restart home assistant and now i get this error on my zha intergration.

Error setting up entry ConBee II - /dev/serial/by-id/usb-dresden_elektronik_ingenieurtechnik_GmbH_ConBee_II_D------, s/n: ------- dresden elektronik ingenieurtechnik GmbH - 1CF1:0030 for zha
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 365, in async_setup
    result = await component.async_setup_entry(hass, self)
  File "/usr/src/homeassistant/homeassistant/components/zha/__init__.py", line 101, in async_setup_entry
    setup_quirks(config)
  File "/usr/local/lib/python3.10/site-packages/zhaquirks/__init__.py", line 409, in setup
    importer.find_module(modname).load_module(modname)
  File "<frozen importlib._bootstrap_external>", line 548, in _check_name_wrapper
  File "<frozen importlib._bootstrap_external>", line 1063, in load_module
  File "<frozen importlib._bootstrap_external>", line 888, in load_module
  File "<frozen importlib._bootstrap>", line 290, in _load_module_shim
  File "<frozen importlib._bootstrap>", line 719, in _load
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/config/custom_zha_quirks/ts0216.py", line 37, in <module>
    class TuyaSiren(CustomDevice):
  File "/config/custom_zha_quirks/ts0216.py", line 41, in TuyaSiren
    MODEL: "TS0216",
NameError: name 'MODEL' is not defined

I try also to add device first, then add quirk file in folder and then restart, but this way my device became unavailable and i can't remove it.

javicalle commented 1 year ago

Ouuuuch^2

Code updated. I forget the new import. Can you try again?

Charisketi commented 1 year ago

Ok. :) Now i see that signature is changed. Device is working the same way i told you in my previous comment. Changing clusters i can change device volume and duration.

Charisketi commented 1 year ago

I try to send squawk using cluster command with no success. I also try to send squawk using home assistant service "Zigbee Home Automation: Warning device squawk" but also no success. Is this posible?

javicalle commented 1 year ago

What is 'squawk'?

In Z2M the device has a custom command, but I have not reviewed yet.

dmulcahey commented 1 year ago

What is 'squawk'?

In Z2M the device has a custom command, but I have not reviewed yet.

It’s an OOTB ZCL command.

javicalle commented 1 year ago

Z2M only implements the start_warning command in an imaginative way. I have no evidence that the squawk can be done.

Any relevant info in your logs?

javicalle commented 1 year ago

David, the switch that apears in HA is created by the ZHASiren, isn't it?

Charisketi commented 1 year ago

No there are no logs when using squawk service. Only "Warning device warn" is working just to turn on siren.

dmulcahey commented 1 year ago

David, the switch that apears in HA is created by the ZHASiren, isn't it?

Yes

Charisketi commented 1 year ago

So I guess the only features available on this device are volume and duration?

Is it necessary to keep the custom quirk or will the volume and duration features be integrated in the next update?

Charisketi commented 1 year ago

Hello @javicalle! Will there be a quirk for siren support in terms of volume and duration? Do you need anything more from me?

javicalle commented 1 year ago

Do you need anything more from me?

No, I just don't have enough spare time.

ZHA already have implemented the siren entity and a few config selects:

We need to understand how attributes are handled in ZHA (I think the value of the volume is cached in ZHA, but the duration is not saved in any way) and find a way to translate the values to (and from) the Tuya attributes. An implementation specific to Tuya sirens might be the easiest path, but right now that's something I can't afford. If someone wants to try it I can give support but nothing else.

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

florismetzner commented 7 months ago

Hi,

I have a comparable device called: "manufacturer": "_TYZB01_4obovpbi", "model": "TS0216",

Can use the same quirk? I'm able to start the sirene via device -> "warn" and turn it of via sirene: off ...but...I get errors that the device is reachable which makes the situation unworkable. Anny suggestions?

Error: Failed to send request: Failed to deliver packet: <TXStatus.MAC_NO_ACK: 233>

{
  "node_descriptor": "NodeDescriptor(logical_type=<LogicalType.Router: 1>, complex_descriptor_available=0, user_descriptor_available=0, reserved=0, aps_flags=0, frequency_band=<FrequencyBand.Freq2400MHz: 8>, mac_capability_flags=<MACCapabilityFlags.FullFunctionDevice|MainsPowered|RxOnWhenIdle|AllocateAddress: 142>, manufacturer_code=4619, maximum_buffer_size=82, maximum_incoming_transfer_size=82, server_mask=11264, maximum_outgoing_transfer_size=82, descriptor_capability_field=<DescriptorCapability.NONE: 0>, *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": "0x0403",
      "input_clusters": [
        "0x0000",
        "0x0001",
        "0x0003",
        "0x0500",
        "0x0502",
        "0x0b05"
      ],
      "output_clusters": [
        "0x0004",
        "0x0019"
      ]
    },
    "242": {
      "profile_id": "0xa1e0",
      "device_type": "0x0061",
      "input_clusters": [],
      "output_clusters": [
        "0x0021"
      ]
    }
  },
  "manufacturer": "_TYZB01_4obovpbi",
  "model": "TS0216",
  "class": "zigpy.device.Device"
}