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
683 stars 634 forks source link

[Device Support Request] RTX Zigbee Tuya ZIR aka. TS1201 #1687

Open sobkas opened 1 year ago

sobkas commented 1 year ago

Is your feature request related to a problem? Please describe. Adding support for Tuya TS1201 link: https://allegro.pl/oferta/uniwersalny-pilot-ir-tuya-zigbee-smart-remote-360-11845030905

Describe the solution you'd like Everything is described at https://github.com/Koenkk/zigbee2mqtt/issues/11633

Device signature ```yaml { "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": 260, "device_type": "0xf000", "in_clusters": [ "0x0000", "0x0003", "0x0004", "0x0005", "0x0006", "0xe004", "0xed00" ], "out_clusters": [ "0x000a", "0x0019" ] }, "242": { "profile_id": 41440, "device_type": "0x0061", "in_clusters": [], "out_clusters": [ "0x0021" ] } }, "manufacturer": "_TZ3290_7v1k4vufotpowp9z", "model": "TS1201", "class": "zigpy.device.Device" } ```
Diagnostic information ```yaml { "home_assistant": { "installation_type": "Home Assistant OS", "version": "2022.8.1", "dev": false, "hassio": true, "virtualenv": false, "python_version": "3.10.5", "docker": true, "arch": "x86_64", "timezone": "Europe/Warsaw", "os_name": "Linux", "os_version": "5.15.55", "supervisor": "2022.07.0", "host_os": "Home Assistant OS 8.4", "docker_version": "20.10.14", "chassis": "vm", "run_as_root": true }, "custom_components": {}, "integration_manifest": { "domain": "zha", "name": "Zigbee Home Automation", "config_flow": true, "documentation": "https://www.home-assistant.io/integrations/zha", "requirements": [ "bellows==0.31.2", "pyserial==3.5", "pyserial-asyncio==0.6", "zha-quirks==0.0.78", "zigpy-deconz==0.18.0", "zigpy==0.48.0", "zigpy-xbee==0.15.0", "zigpy-zigate==0.9.0", "zigpy-znp==0.8.1" ], "usb": [ { "vid": "10C4", "pid": "EA60", "description": "*2652*", "known_devices": [ "slae.sh cc2652rb stick" ] }, { "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" ] } ], "codeowners": [ "@dmulcahey", "@adminiuga", "@puddly" ], "zeroconf": [ { "type": "_esphomelib._tcp.local.", "name": "tube*" }, { "type": "_zigate-zigbee-gateway._tcp.local.", "name": "*zigate*" } ], "after_dependencies": [ "onboarding", "usb", "zeroconf" ], "iot_class": "local_polling", "loggers": [ "aiosqlite", "bellows", "crccheck", "pure_pcapy3", "zhaquirks", "zigpy", "zigpy_deconz", "zigpy_xbee", "zigpy_zigate", "zigpy_znp" ], "is_built_in": true }, "data": { "ieee": "**REDACTED**", "nwk": 8650, "manufacturer": "_TZ3290_7v1k4vufotpowp9z", "model": "TS1201", "name": "_TZ3290_7v1k4vufotpowp9z TS1201", "quirk_applied": false, "quirk_class": "zigpy.device.Device", "manufacturer_code": 4098, "power_source": "Mains", "lqi": 99, "rssi": null, "last_seen": "2022-08-09T15:39:04", "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": 260, "device_type": "0xf000", "in_clusters": [ "0x0000", "0x0003", "0x0004", "0x0005", "0x0006", "0xe004", "0xed00" ], "out_clusters": [ "0x000a", "0x0019" ] }, "242": { "profile_id": 41440, "device_type": "0x0061", "in_clusters": [], "out_clusters": [ "0x0021" ] } } }, "active_coordinator": false, "entities": [ { "entity_id": "button.uniwersalny_pilot_identifybutton", "name": "_TZ3290_7v1k4vufotpowp9z TS1201" }, { "entity_id": "switch.uniwersalny_pilot_switch", "name": "_TZ3290_7v1k4vufotpowp9z TS1201" } ], "neighbors": [], "endpoint_names": [ { "name": "undefined_0xf000" }, { "name": "unknown 97 device_type of 0xa1e0 profile id" } ], "user_given_name": "Uniwersalny pilot ", "device_reg_id": "1fea9570578603f815e8598267a40c96", "area_id": "salon", "cluster_details": { "1": { "device_type": { "name": "undefined_0xf000", "id": 61440 }, "profile_id": 260, "in_clusters": { "0x0000": { "endpoint_attribute": "basic", "attributes": { "0x0004": { "attribute_name": "manufacturer", "value": "_TZ3290_7v1k4vufotpowp9z" }, "0x0005": { "attribute_name": "model", "value": "TS1201" } }, "unsupported_attributes": {} }, "0x0004": { "endpoint_attribute": "groups", "attributes": {}, "unsupported_attributes": {} }, "0x0005": { "endpoint_attribute": "scenes", "attributes": {}, "unsupported_attributes": {} }, "0x0003": { "endpoint_attribute": "identify", "attributes": {}, "unsupported_attributes": {} }, "0xed00": { "endpoint_attribute": null, "attributes": {}, "unsupported_attributes": {} }, "0xe004": { "endpoint_attribute": null, "attributes": {}, "unsupported_attributes": {} }, "0x0006": { "endpoint_attribute": "on_off", "attributes": { "0x0000": { "attribute_name": "on_off", "value": 1 } }, "unsupported_attributes": { "0x4003": { "attribute_name": "start_up_on_off" } } } }, "out_clusters": { "0x0019": { "endpoint_attribute": "ota", "attributes": {}, "unsupported_attributes": {} }, "0x000a": { "endpoint_attribute": "time", "attributes": {}, "unsupported_attributes": {} } } }, "242": { "device_type": { "name": "unknown", "id": 97 }, "profile_id": 41440, "in_clusters": {}, "out_clusters": { "0x0021": { "endpoint_attribute": "green_power", "attributes": {}, "unsupported_attributes": {} } } } } } } ```
nimrodolev commented 1 year ago

+1 Here!

This is also sold as Moes UFO-R11.

Would very much like to have support for this one.

ranton1990 commented 1 year ago

+1 This seems to be working with zigbee2mqtt, which I want to avoid using. Only thing that works at the moment is the "Identify" button within ZHA.

akarabach commented 1 year ago

Any updates on it ?

ferehcarb commented 1 year ago

Hi, I'm working on it, learning mode is functional, I need to write the code to send IR frames. I'll do a PR when it'll be finished.

ferehcarb commented 1 year ago

Quirk is functional, here: https://github.com/ferehcarb/zha-device-handlers/blob/dev/zhaquirks/tuya/ts1201.py Learning mode must be set with "Manage Zigbee Device": image When you click on "Issue Zigbee Command" the blue led on the device should light up.

Then, you press the button on your IR remote and the IR code is available in homeassistant logs, the blue led should turn down.

You can replay the IR code with: image

Warning, very early code, I must clean up and better integrate it with HA. Should work too for issue #1782 and #1955

ranton1990 commented 1 year ago

Hey THX a lot for that. I am trying to follow your guide but i don't seem to get any codes in my logs. The blue LED lights up for about 20 seconds if I dont point a remote at it and even earlier if I do, but nothing in the logs. Do you mean the standard home-assistant.log, which is also shown in the settings?

ferehcarb commented 1 year ago

Hey THX a lot for that. I am trying to follow your guide but i don't seem to get any codes in my logs. The blue LED lights up for about 20 seconds if I dont point a remote at it and even earlier if I do, but nothing in the logs. Do you mean the standard home-assistant.log, which is also shown in the settings?

Yes, in the standard logs, file /config/home-assistant.log, you should see "Command 0x05: Ir message really totally received:" followed by the IR code (base64 encoded). Your log config must be at least to info I think, I use debug for zha on my side:

logger:
  default: warning
  logs:
    homeassistant.components.zha: warning
    zigpy: debug
    custom_components.zha_toolkit: debug
    custom_zha_quirks: debug
    zhaquirks: debug
ranton1990 commented 1 year ago

Thx, Zigpy logging must be info.

ranton1990 commented 1 year ago

Here is a sample script to send a code:

alias: Vacuum Start
sequence:
  - service: zha.issue_zigbee_cluster_command
    data:
      cluster_type: in
      endpoint_id: 1
      command: 2
      ieee: 38:5b:44:ff:fe:33:11:8a
      command_type: server
      params:
        code: >-
          C7ILsgsfAskBHwLGBYADwAtAB+APA8ArwAfgDyfgIxfAS0AHQDdAB8ADB/pPsguyCx8C4AEXArMCBWCzB8kByQGzAskBQAGAH0AHCR8CyQHJAR8CxgXgBQNAE+A3A+ADU0BL4AMP4AmnAR8CwCNAB+APA0An4AMD4A8n4CMX4AdP4AMP4JWnBLMCxgUfYAPglacJHwLGBR8CxgUfAg==
      cluster_id: 57348
mode: single
icon: mdi:robot-vacuum

You will need to switch out the ieee as well as the code. The cluster_id was translated from 0xe004

ferehcarb commented 1 year ago

@ranton1990 Is it working for your device ? I developed the last pieces of code outside my home and didn't test it on a real device...

ranton1990 commented 1 year ago

@ferehcarb Yes it is, I can successfully start my Robo Vacuum and send it back to its station.

kukukk commented 1 year ago

Hi!

I have a similar zigbee IR Remote Controller. It looks different, but identifies as TS1201 by _TZ3290_ot6ewjvmejq5ekhl: https://www.ebay.com/itm/275310058694

I can confirm that it works with this custom quirk. I tried it with a Yamaha amplifier (power on/off and volume up/down). Both learning and sending IR codes.

Thank you for your work!

loclamor commented 1 year ago

Hi @ferehcarb i'm trying to use your quirk (first time for me, maybe i missed something), but i have the following errors on stratup : image Any ideas what i'm wrong ?

MattWestb commented 1 year ago

You have copy the URL for the quirk and not the real file so the system cant loading it. In the GIT clicking on the file and the raw button and copy the raw data and saving it in your local quirk file then you doing getting the http things with.

loclamor commented 1 year ago

Yes, no more error with the correct file :+1:

But when adding my device it is not using the quirk :

{
  "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=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": 260,
      "device_type": "0xf000",
      "in_clusters": [
        "0x0000",
        "0x0003",
        "0x0004",
        "0x0005",
        "0x0006",
        "0xe004",
        "0xed00"
      ],
      "out_clusters": [
        "0x000a",
        "0x0019"
      ]
    },
    "242": {
      "profile_id": 41440,
      "device_type": "0x0061",
      "in_clusters": [],
      "out_clusters": [
        "0x0021"
      ]
    }
  },
  "manufacturer": "_TZ3290_7v1k4vufotpowp9z",
  "model": "TS1201",
  "class": "zigpy.device.Device"
}
MattWestb commented 1 year ago

Then you must updating the signature in the quirk so it matching your device then the system can loading it.

ferehcarb commented 1 year ago

Hi, the signature for "_TZ3290_7v1k4vufotpowp9z" is already in the quirk. Did you specify the custom directory for quirks in your config ?

loclamor commented 1 year ago

Yes, and i can see a "pycache" folder in my custom quirk folder.

I have delete and add again the device but still the same class.

image image

(the local ha-config is binded to /config in docker)

loclamor commented 1 year ago

@ferehcarb Could this help ? image

ferehcarb commented 1 year ago

"Foreign key constraint failed". Don't know from what it could came. We need a zha expert...

loclamor commented 1 year ago

@ferehcarb I think the main problem is this :

Checking quirks for _TZ3290_7v1k4vufotpowp9z TS1201 (dc:8e:95:ff:fe:f4:28:56)
Considering <class 'ts1201.ZosungIRBlaster'>
Fail because endpoint list mismatch: {1} {1, 242}

The signature of my device did not match the ENDPOINTS list in the quirk

{
  "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=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": 260,
      "device_type": "0xf000",
      "in_clusters": [
        "0x0000",
        "0x0003",
        "0x0004",
        "0x0005",
        "0x0006",
        "0xe004",
        "0xed00"
      ],
      "out_clusters": [
        "0x000a",
        "0x0019"
      ]
    },
    "242": {
      "profile_id": 41440,
      "device_type": "0x0061",
      "in_clusters": [],
      "out_clusters": [
        "0x0021"
      ]
    }
  },
  "manufacturer": "_TZ3290_7v1k4vufotpowp9z",
  "model": "TS1201",
  "class": "zigpy.device.Device"
}

But i do not have any idea of what to add in the quirk to have a match

ferehcarb commented 1 year ago

Well seen. Try to remove this lines:

ferehcarb commented 1 year ago

Arf... you have another endpoint (242) too. You should add to "ENDPOINTS" dictionary signature I think.

loclamor commented 1 year ago

I wasn't know quirks 2 days ago 😅 What should i add as endpoint for 242 ?for profil, device type and clusters ?

ferehcarb commented 1 year ago

Neither me, I wasn't know what it was 2 months ago ;-) I pushed a new version with your device signature, give it a try.

loclamor commented 1 year ago

@ferehcarb Thx ! Seems to have worked : image I'll try with an IR remote tonigth at home or tomorow :)

ferehcarb commented 1 year ago

By the way, now you can get the learned IR code with an attribute: image You don't need any more to catch it in the hommeassistant logs.

loclamor commented 1 year ago

@ferehcarb I have this error when triggering the IRLearn : image And i cannot set the on_off value to true : image I have try to directly write the yaml to issue the zigbee command, but i do not know where to place this on_off parameter ?

service: zha.issue_zigbee_cluster_command
data:
  ieee: dc:8e:95:ff:fe:f4:28:56
  cluster_id: 57348
  endpoint_id: 1
  command: 1
  on_off: true   <--- "Échec d'appel du service zha.issue_zigbee_cluster_command. extra keys not allowed @ data['on_off']. Got None"
  command_type: server
  cluster_type: in
ferehcarb commented 1 year ago

What is this sorcery ? Can you put zha in debug mode and post logs please ? Something like this:

logger:
  default: warning
  logs:
    homeassistant.components.zha: debug
    zigpy: debug
    custom_components.zha_toolkit: debug
    custom_zha_quirks: debug
    zhaquirks: debug
loclamor commented 1 year ago

I think related logs is there :

2023-03-15 09:33:40.442 DEBUG (MainThread) [zigpy.zcl] [0x56C3:1:0x0000] Received ZCL frame: b'\x08\x1a\n\x01\x00 F\xe2\xff \x1f\xe4\xff \x00'
2023-03-15 09:33:40.443 DEBUG (MainThread) [zigpy.zcl] [0x56C3:1:0x0000] Decoded ZCL frame header: ZCLHeader(frame_control=FrameControl(frame_type=<FrameType.GLOBAL_COMMAND: 0>, is_manufacturer_specific=0, direction=<Direction.Client_to_Server: 1>, disable_default_response=0, reserved=0, *is_cluster=False, *is_general=True, *is_reply=True), tsn=26, command_id=10, *direction=<Direction.Client_to_Server: 1>, *is_reply=True)
2023-03-15 09:33:40.445 DEBUG (MainThread) [zigpy.zcl] [0x56C3:1:0x0000] Decoded ZCL frame: Basic:Report_Attributes(attribute_reports=[Attribute(attrid=0x0001, value=TypeValue(type=uint8_t, value=70)), Attribute(attrid=0xFFE2, value=TypeValue(type=uint8_t, value=31)), Attribute(attrid=0xFFE4, value=TypeValue(type=uint8_t, value=0))])
2023-03-15 09:33:40.446 DEBUG (MainThread) [zigpy.zcl] [0x56C3:1:0x0000] Received command 0x0A (TSN 26): Report_Attributes(attribute_reports=[Attribute(attrid=0x0001, value=TypeValue(type=uint8_t, value=70)), Attribute(attrid=0xFFE2, value=TypeValue(type=uint8_t, value=31)), Attribute(attrid=0xFFE4, value=TypeValue(type=uint8_t, value=0))])
2023-03-15 09:33:40.447 DEBUG (MainThread) [zigpy.zcl] [0x56C3:1:0x0000] Attribute report received: app_version=70, 0xFFE2=31, 0xFFE4=0
2023-03-15 09:33:40.450 DEBUG (MainThread) [zigpy.zcl] [0x56C3:1:0x0000] 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=26, command_id=<GeneralCommand.Default_Response: 11>, *direction=<Direction.Client_to_Server: 1>, *is_reply=True)
2023-03-15 09:33:40.451 DEBUG (MainThread) [zigpy.zcl] [0x56C3:1:0x0000] Sending reply: Default_Response(command_id=10, status=<Status.SUCCESS: 0>)
2023-03-15 09:33:42.645 DEBUG (MainThread) [homeassistant.components.zha.api] Requested attributes for: cluster_id: 57348, cluster_type: 'in', endpoint_id: 1, response: [{'id': 0, 'name': 'last_learned_ir_code'}]
2023-03-15 09:33:42.646 DEBUG (MainThread) [homeassistant.components.zha.api] Requested commands for: cluster_id: 57348, cluster_type: 'in', endpoint_id: 1, response: [{'type': 'server', 'id': 0, 'name': 'data'}, {'type': 'server', 'id': 1, 'name': 'IRLearn'}, {'type': 'server', 'id': 2, 'name': 'IRSend'}]
2023-03-15 09:33:44.091 DEBUG (MainThread) [zigpy.zcl] [0xC78F:1:0x0b04] Received ZCL frame: b'\x18\xf8\n\x0f\x05!\xac\r'
2023-03-15 09:33:44.092 DEBUG (MainThread) [zigpy.zcl] [0xC78F:1:0x0b04] Decoded ZCL frame header: ZCLHeader(frame_control=FrameControl(frame_type=<FrameType.GLOBAL_COMMAND: 0>, is_manufacturer_specific=0, direction=<Direction.Client_to_Server: 1>, disable_default_response=1, reserved=0, *is_cluster=False, *is_general=True, *is_reply=True), tsn=248, command_id=10, *direction=<Direction.Client_to_Server: 1>, *is_reply=True)
2023-03-15 09:33:44.093 DEBUG (MainThread) [zigpy.zcl] [0xC78F:1:0x0b04] Decoded ZCL frame: ElectricalMeasurement:Report_Attributes(attribute_reports=[Attribute(attrid=0x050F, value=TypeValue(type=uint16_t, value=3500))])
2023-03-15 09:33:44.093 DEBUG (MainThread) [zigpy.zcl] [0xC78F:1:0x0b04] Received command 0x0A (TSN 248): Report_Attributes(attribute_reports=[Attribute(attrid=0x050F, value=TypeValue(type=uint16_t, value=3500))])
2023-03-15 09:33:44.094 DEBUG (MainThread) [zigpy.zcl] [0xC78F:1:0x0b04] Attribute report received: apparent_power=3500
2023-03-15 09:33:45.028 DEBUG (MainThread) [zigpy.zcl] [0x9A87:1:0x0006] Received ZCL frame: b'\x08g\n\x00\x00\x10\x00'
2023-03-15 09:33:45.029 DEBUG (MainThread) [zigpy.zcl] [0x9A87:1:0x0006] Decoded ZCL frame header: ZCLHeader(frame_control=FrameControl(frame_type=<FrameType.GLOBAL_COMMAND: 0>, is_manufacturer_specific=0, direction=<Direction.Client_to_Server: 1>, disable_default_response=0, reserved=0, *is_cluster=False, *is_general=True, *is_reply=True), tsn=103, command_id=10, *direction=<Direction.Client_to_Server: 1>, *is_reply=True)
2023-03-15 09:33:45.031 DEBUG (MainThread) [zigpy.zcl] [0x9A87:1:0x0006] Decoded ZCL frame: OnOff:Report_Attributes(attribute_reports=[Attribute(attrid=0x0000, value=TypeValue(type=Bool, value=<Bool.false: 0>))])
2023-03-15 09:33:45.031 DEBUG (MainThread) [zigpy.zcl] [0x9A87:1:0x0006] Received command 0x0A (TSN 103): Report_Attributes(attribute_reports=[Attribute(attrid=0x0000, value=TypeValue(type=Bool, value=<Bool.false: 0>))])
2023-03-15 09:33:45.032 DEBUG (MainThread) [zigpy.zcl] [0x9A87:1:0x0006] Attribute report received: on_off=<Bool.false: 0>
2023-03-15 09:33:45.033 DEBUG (MainThread) [zigpy.zcl] [0x9A87:1:0x0006] 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=103, command_id=<GeneralCommand.Default_Response: 11>, *direction=<Direction.Client_to_Server: 1>, *is_reply=True)
2023-03-15 09:33:45.034 DEBUG (MainThread) [zigpy.zcl] [0x9A87:1:0x0006] Sending reply: Default_Response(command_id=10, status=<Status.SUCCESS: 0>)
2023-03-15 09:33:48.677 DEBUG (MainThread) [zigpy.zcl] [0x7C0E:1:0xe004] Receive command with args: () and kwargs {}
2023-03-15 09:33:48.678 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [140043253743920] 'on_off'
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 200, in handle_call_service
await hass.services.async_call(
File "/usr/src/homeassistant/homeassistant/core.py", line 1738, in async_call
task.result()
File "/usr/src/homeassistant/homeassistant/core.py", line 1775, in _execute_service
await cast(Callable[[ServiceCall], Awaitable[None]], handler.job.target)(
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 746, in admin_handler
await result
File "/usr/src/homeassistant/homeassistant/components/zha/api.py", line 1273, in issue_zigbee_cluster_command
response = await zha_device.issue_cluster_command(
File "/usr/src/homeassistant/homeassistant/components/zha/core/device.py", line 677, in issue_cluster_command
response = await cluster.command(
File "/config/zha_quirks/ts1201.py", line 119, in command
if kwargs["on_off"]:
KeyError: 'on_off'

full log is here : https://gist.github.com/loclamor/07218efd03849c66696785f107f451aa

ferehcarb commented 1 year ago

You can try to call the service with the "Developper Tools": image

Yaml generated:

service: zha.issue_zigbee_cluster_command
data:
  cluster_type: in
  ieee: 38:5b:44:ff:fe:33:11:fa
  endpoint_id: 1
  cluster_id: 57348
  command_type: server
  command: 1
  params:
    on_off: true

If it works, the blue LED should light on.

loclamor commented 1 year ago

@ferehcarb the "params" key is not recognized Oo Échec d'appel du service zha.issue_zigbee_cluster_command. extra keys not allowed @ data['params'].

The params field is not proposed in the UI view image

Maybe my HA version is not good ?

Home Assistant 2022.9.7
Interface utilisateur : 20220907.2 - latest
loclamor commented 1 year ago

@ferehcarb I was not up-to-date... i'm now on Home Assistant 2023.3.4 : Zigbee cluster : image cluster command : image

Seems promizing... I will try soon !

loclamor commented 1 year ago

Thank you for your work @ferehcarb ! I have manage to learn a code from my climatiser remote and succesfully emit it from ha ! 😍 now i have to manage an automation with all possible temperatures and fan speed, for heat and freeze 😅

ferehcarb commented 1 year ago

Good news, thank you for your perseverance, we've got now another device supported by the quirk. I think yours is not battery powered but by charger, right ?

loclamor commented 1 year ago

@ferehcarb sadly yes !

davidbb commented 1 year ago

Just a quick comment to say the quirk worked for me. I was able to learn new IR codes and replay them as described in https://github.com/zigpy/zha-device-handlers/issues/1687#issuecomment-1424357574

My device is the battery powered version, reported as:

TS1201
by _TZ3290_ot6ewjvmejq5ekhl

Thanks for putting this together @ferehcarb!

ferehcarb commented 1 year ago

Good news, I think it's time to create a PR.

blair287 commented 1 year ago

Good news, I think it's time to create a PR.

I've tested this I'm having an issue with commands that require a long press it's only sending a short press anyway to fix this please?

davidbb commented 1 year ago

@blair287 have you tried sending the same command in rapid succession? you could write a home assistant script that issues a set of zigbee cluster commands N times to simulate your key hold or long press. That's usually all that the remote is doing.

blair287 commented 1 year ago

@blair287 have you tried sending the same command in rapid succession? you could write a home assistant script that issues a set of zigbee cluster commands N times to simulate your key hold or long press. That's usually all that the remote is doing.

Broadlink shows different commands for long and short but they aren't in tje same format this returns a short press even though your still holding the button

bedroomtv": { "on": "JgBYAAABK5IVEBURFBEUNhUQFRAVERU1FTUVNhU1FRAVNhU1FTYVEBUQFRAVEBURFDYVEBUQFREVNRU1FTYVNRUQFTYVNRU2FAAFFAABKUkVAAxYAAEpSRUADQU=", "off": "JgAAAQABKJQTEhQSExITNxMSFBITEhM3EzgTNxM3FBITNxM3EzgTEhMSExITExMSEzcTEhMTExITNxM4EzcTNxMTEzcTNxM4EwAFFQABKUkTAAxaAAEpShMADFoAAShKEwAMWgABKUkTAAxaAAEpSRMADFoAASlKEwAMWgABKEoTAAxaAAEpSRMADFoAASlJEwAMWgABKUoTAAxaAAEoShMADFoAASlJEwAMWgABKUkTAAxaAAEpSRQADFoAAShKEwAMWgABKUkTAAxaAAEpSRMADFoAASlKEwAMWQABKUoTAAxaAAEpShMADFoAAShKEwAMWgABKUkTAAxaAAEpSRMADQUAAAAAAAAAAA==" }

Is what broadlink shows on is a short press off is a long press if I try same on the tuya device tje short and long press do the same thing a short press which just puts into sleep not off sending it rapidly just makes it go sleep on sleep on.

Was really hoping to replace my broadlink with this but looks like gonna have to use a esp home as this device just doesn't work with long press ir commands.

ranton1990 commented 1 year ago

Not sure when it first happened, but today I noticed this while starting HA:

2023-04-06 13:35:17.633 ERROR (MainThread) [zhaquirks] Unexpected exception importing custom quirk 'ts1201'

Traceback (most recent call last):

  File "/usr/local/lib/python3.10/site-packages/zhaquirks/__init__.py", line 418, in setup

    importer.find_module(modname).load_module(modname)

  File "", line 548, in _check_name_wrapper

  File "", line 1063, in load_module

  File "", line 888, in load_module

  File "", line 290, in _load_module_shim

  File "", line 719, in _load

  File "", line 688, in _load_unlocked

  File "", line 883, in exec_module

  File "", line 241, in _call_with_frames_removed

  File "/config/custom_zha_quirks/ts1201.py", line 53, in 

    class ZosungIRControl(CustomCluster):

  File "/config/custom_zha_quirks/ts1201.py", line 65, in ZosungIRControl

    0x00: foundation.ZCLCommandDef(

TypeError: ZCLCommandDef.__init__() got an unexpected keyword argument 'is_reply'
ranton1990 commented 1 year ago

After removing all is_reply lines in the py file, it works again perfectly.

ferehcarb commented 1 year ago

After removing all is_reply lines in the py file, it works again perfectly.

We must replace is_reply=True by direction = Direction.Client_to_Server or something like this , and the invert for is_reply=False. The zigbbe lib code has changed and dropped this attribute I think. is_reply is necessary, otherwise, without it, frames from the devices are repeated and there is much delay to learn or send the IR code.

ferehcarb commented 1 year ago

@ranton1990 , fixed with this commit

blair287 commented 1 year ago

@ranton1990 , fixed with this commit

Any idea how to get long presses working at all?

Manbearpig92 commented 1 year ago

I have this IR blaster: https://www.aliexpress.com/item/1005003813684787.html?spm=a2g0o.order_list.order_list_main.15.575d1802a2M0rC

I am unable to get IR learn and IR send Clusters in any of these drop down menu's. How do I get this? I'm running the newest Home assistant update with a sky connect -660631294221974772

ranton1990 commented 1 year ago

@ranton1990 , fixed with this commit

Just tested it, works flawless.

I have this IR blaster: https://www.aliexpress.com/item/1005003813684787.html?spm=a2g0o.order_list.order_list_main.15.575d1802a2M0rC

I am unable to get IR learn and IR send Clusters in any of these drop down menu's. How do I get this? I'm running the newest Home assistant update with a sky connect -660631294221974772

It is supposed to be in the Clusters dropdown at the top. Although your blaster looks different to mine.

Manbearpig92 commented 1 year ago

@ranton1990 do you have a link to the one you have?

ferehcarb commented 1 year ago

I am unable to get IR learn and IR send Clusters in any of these drop down menu's. How do I get this? I'm running the newest Home assistant update with a sky connect

You must choose the cluster "ZosungIRControl" and "commands" tab. Your screenshot show us "basic cluster" and "attributes".