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
684 stars 637 forks source link

[Device Support Request] TCP-Smart Zigbee TRV Radiator Valve (Tuya/Zigbee Quirks) [Old Integration Supported, testing/debugging new integration] #1180

Closed accessiblepixel closed 2 years ago

accessiblepixel commented 2 years ago

Edit: to make this make a bit more sense.

The old integration method and quirks file works with the TCP-Smart Zigbee TRV Valve, which I've added to my github at https://github.com/accessiblepixel/TCP-Smart-TRV/blob/master/ts0601_trv.py

To get this valve working with the old integration, create a folder in your config directory called custom_zha_quirks and upload the ts0601_trv.py there.

Then edit your main configuration.yaml to include zha: custom_quirks_path: /config/custom_zha_quirks/

and restart, and add/pair the device as usual.

Later on in the thread we are testing the 'new' integration and trying to get support for all features of the device :)

Original post is as follows:

Is your feature request related to a problem? Please describe. I cannot pair and access features of a TCP-Smart ZigBee TRV Valve. Originally it came with a Tuya compatible WiFi gateway, but I've since picked up a CC2531 USB Zigbee Gateway, but when I try and find the device in home assistant it says This Device Has No Entities.

Describe the solution you'd like It looks like it's very similar to a model listed on https://zigbee.blakadder.com/Alecto_SMART-HEAT10.html it physically looks the same.

*Device signature - this can be acquired by removing the device from ZHA and pairing it again from the add { "node_descriptor": "NodeDescriptor(logical_type=<LogicalType.EndDevice: 2>, complex_descriptor_available=0, user_descriptor_available=0, reserved=0, aps_flags=0, frequency_band=<FrequencyBand.Freq2400MHz: 8>, mac_capability_flags=<MACCapabilityFlags.AllocateAddress: 128>, manufacturer_code=0, maximum_buffer_size=82, maximum_incoming_transfer_size=255, server_mask=11264, maximum_outgoing_transfer_size=255, descriptor_capability_field=<DescriptorCapability.NONE: 0>, allocate_address=True, is_alternate_pan_coordinator=False, is_coordinator=False, is_end_device=True, is_full_function_device=False, is_mains_powered=False, is_receiver_on_when_idle=False, is_router=False, is_security_capable=False)", "endpoints": { "1": { "profile_id": 260, "device_type": "0x0000", "in_clusters": [ "0x0000", "0x0003" ], "out_clusters": [ "0x0003", "0x0019" ] } }, "manufacturer": "_TYST11_czk78ptr", "model": "zk78ptr", "class": "zigpy.device.Device" }

Additional context If I have put this in the wrong place, please move it to the correct one. I'm very new to zigbee integration but if you need any other logfiles, please let me know. I think one of the quirks that exists for similar devices might work for this one, but it's all a bit beyond me. I hope someone can help, I'd like to move my thermostats away from the Tuya Zigbee gateway to local control with Home Assistant.

Kind regards, Jessica

Edit: Here's a link to the product page on Amazon (UK) for the valve itself https://www.amazon.co.uk/gp/product/B0898FVKMT and here's a link to the first device you buy that comes with the gateway that it uses: https://www.amazon.co.uk/gp/product/B0898CHSZS

It appears to be Zigbee, and I can search and find it with ZHA in Home Assistant, just no controls are created. I've been trying to look at other quirks, and since it's similar to other devices that are the same, it could just be a case of adding the IDs to one of them (but I'm just guessing. This is all new to me!)

accessiblepixel commented 2 years ago

Updated my original post, because apparently I can't github properly. Added some links to the device on Amazon, and corrected the device manufacturer.

Have looked at the device, and without disassembly, I can't find any additional model numbers on it, which is a pain.

The device (as bought) is a TRV smart radiator valve, which claimed at one point on it's listing page Zigbee 3 support. It's supposed to connect to the TCP Smart Wireless Hub, which is a Zigbee to Tuya/Smart Life (or TCP Smart's own branded version of Tuya/Smart Life) via WiFi, so any control requires the cloud.

My thought was to get a USB Zigbee gateway to remove the problems I'm having getting local control of the device with Home Assistant, but looks like it's going to be more "plug 'n' pray" to someone smarter than I am with these things. If I can give any more info, let me know as we might stop someone else wanting to pull their hair out :D

Kind regards, Jessica

MattWestb commented 2 years ago

Hi Jessica your device looks 100% like my Siterwell white labeled so i think its it shall being no problem getting it working with ZHA.

Do you have one brand and name of the TRV ?

I have patched 2 feles that need being added in your system and one is easy and the second its little tricky getting in right place..

First configuring "local quirks" https://github.com/zigpy/zha-device-handlers/discussions/693#discussioncomment-857274. Copy the ts0601_trv.py the the new local quirk folder. Next you need getting access to your HA docker container with CLI https://github.com/zigpy/zha-device-handlers/discussions/693#discussion-1237451. Copy the climate.py to your HA config folder and then from the HA docker container CLI copy it in to the folder with this command:

cp /config/climate.py /usr/src/homeassistant/homeassistant/components/zha/climate.py

Restart HA and if all is going OK you shall getting one TRV device in ZHA.

If you is getting problem pleas ask !!

This is the current "old" implementation with not all in place and not working but we have one with more function that you can trying later if you like.

MattWestb commented 2 years ago

Sorry i was writing one wrong thing !! The climate.py you shall not copy for using the "normal" quirk only if you later like testing the new updated quirk !!

Only copy the ts0601_trv.py to the local quirk folder and it shall working.

Its being little late for my and need little sleep i think ;-)

accessiblepixel commented 2 years ago

@MattWestb Thanks for the reply.

Where do I find ts0601_trv.py ?

The manufacturer is TCP-Smart and model number on Amazon is TBUWTRVZIG and has the Zigbee Device Fingerprint as above.

Other than that it doesn't have a model number, it's just called the TCP Smart Thermostatic Radiator Valve & Wireless Hub (linked both the kit and the extra valves in first comment)

Kind regards, Jessica

MattWestb commented 2 years ago

Some where under the . . . ts0601_trv_new.zip

You see im needing little sleep ;-(

Config local quirk and copy the ts0601_trv.py to the new folder and restart HA.

I can helping more tomorrow if needed.

MattWestb commented 2 years ago

I have putting it in the tuya TRV matrix with brand and model https://github.com/zigpy/zigpy/discussions/653#discussioncomment-314395 so other user can see its supported (then we have doing one working PR for it).

accessiblepixel commented 2 years ago

Ahh, thank you. Just trying it out now.

I've copied over the ts0601_trv.py to the custom folder in config and added the entry to my configuration yaml, tried doing a restart from "server control" but haven't had any success yet, so I'm trying a host reboot.

There's no real rush in fixing this, given I should probably sleep too :) Thanks for your help so far, you're a star.

Kind regards, Jessica.

MattWestb commented 2 years ago

If ZHA is matching the device OK for the quirk and loading it you shall getting in the last line on the device card like (not exact) Quirk: ts0601_trv_siterwell.SiterwellGS361_Type1 and also in the device signature.

accessiblepixel commented 2 years ago

@MattWestb Hmm, after putting that folder and copying the ts061_trv.py file into /config/custom_zha_quirks now when I try and use the ZHA integrations thing it says "Failed to set up" and gives a link to view the logs, which are blank. I must be doing something wrong!

Is the tr061_trv file the only one I need to put in to get it working, or do I need to put the climate.py in there too?

Don't need an answer right now, though, I'll just update my trials as I go on for a bit before I crash :)

Kind regards, Jessica

MattWestb commented 2 years ago

Can you posting the error from HA ? Local quirk can caching ZHA and its not starting but normally its mismatch of versions or bad copy paste from my side.

accessiblepixel commented 2 years ago

What I posted was the error, it's not showing anything in my HA logfile.

The only entries I get are unrealated (about having HACS loaded and localtuya)

It looks like it's crashing out the ZHA integration, just says "Failed to setup click for logs" so I click logs, and there aren't any :(

Is there a way to turn a "debug" mode on, so I can help a bit better?

accessiblepixel commented 2 years ago

These are screenshots of what I can see... (which are as useless as a chocolate fire guard!)

https://i.lowrex.com/i/CzTa.png https://i.lowrex.com/i/CFoh.png

MattWestb commented 2 years ago

No climate.py for the "old" quirk that we is testing first.

OK its one updated line that is not updated in HA 2021.11. Can you looking for TuyaPowerConfigurationCluster2AA and relapsing it with TuyaPowerConfigurationCluster in all lines you can finding (its only the 2AA that is changed) ?

accessiblepixel commented 2 years ago

That seems to have worked, it seems to be responding now 👯

Thank you very much. After you and I have had some sleep, I'm more than willing to help you test out the "new" integration to help support another device.

Thank you so much <3

Until tomorrow.

Jessica.

MattWestb commented 2 years ago

The first is 2 warning that you is using external components = OK then its no error. The second can being that the quirk is not OK and crashing ZHA. For eliminating the problem with the local quirk you can renaming it to ts0601_trv.Xpy then ZHA is not trying loading it.

You can also clicking "load full home assistant log" in the log window and you can see more.

accessiblepixel commented 2 years ago

That was with the full home assistant log shown. I only have two errors, and they're both for custom compoenents (hacs and localtuya)... however, it indeed looks like the custom zha "quirk" was casuing an issue in the ZHA integration, but those edits you got me to make have made it respond (and seemingly respond pretty well!)

Go have some well deserved rest. Can pick up the next testing tomorrow. <3

accessiblepixel commented 2 years ago

So just to log some things I've noticed for us tomorrow.

It doesn't seem to communicate with ZHA very often, and seems a bit... "laggy", and doesn't accept updates as fast as I would expect, but I'm all out of energy so will check in tomorrow :) Definitely closer to a solution than we were 👍

Edit: Gonna just keep editing this post with updates to hopefully prevent update email spam.

Hmm... Deleting the integration and re-adding it seems to have made things work a bit better (than not at all). I'm wondering if this could be a range issue? Although I never did have a problem with range with the original Zigbee>Wireless gateway.

HA says LQI is 99, but not sure what that means, but it doesn't seem communicate with ZHA after it has been paired and will no doubt go back to sleep (it being a battery device?)

and under power % in the device info it says "unknown", so I think... maybe we're missing something? I'm a total noob when it comes to Zigbee though, so I'm very much just guessing.

Hmm, further testing seems to indicate it only sends temperature updates at every 0.5C? Certainly it only sends a "same temperature" if you change a control, then it responds almost straight away.... so... I guess it is working?

Here's the pairing log after I repaired the device.

New device 0xce92 (ec:1b:bd:ff:fe:c2:8b:fe) joined the network [0xce92] Scheduling initialization Received frame on uninitialized device from ep 0 to ep 0, cluster ZDOCmd.Device_annce: b'\xFF\x92\xCE\xFE\x8B\xC2\xFE\xFF\xBD\x1B\xEC\x80' [0xce92:zdo] ZDO request ZDOCmd.Device_annce: [0xCE92, ec:1b:bd:ff:fe:c2:8b:fe, 128] Tries remaining: 3 [0xce92] Requesting 'Node Descriptor' Tries remaining: 2 [0xce92] Extending timeout for 0x07 request Received frame on uninitialized device from ep 0 to ep 0, cluster ZDOCmd.Node_Desc_rsp: b'\x07\x00\x92\xCE\x02\x40\x80\x00\x00\x52\xFF\x00\x00\x2C\xFF\x00\x00' [0xce92] Got Node Descriptor: NodeDescriptor(logical_type=<LogicalType.EndDevice: 2>, complex_descriptor_available=0, user_descriptor_available=0, reserved=0, aps_flags=0, frequency_band=<FrequencyBand.Freq2400MHz: 8>, mac_capability_flags=<MACCapabilityFlags.AllocateAddress: 128>, manufacturer_code=0, maximum_buffer_size=82, maximum_incoming_transfer_size=255, server_mask=11264, maximum_outgoing_transfer_size=255, descriptor_capability_field=<DescriptorCapability.NONE: 0>, allocate_address=True, is_alternate_pan_coordinator=False, is_coordinator=False, is_end_device=True, is_full_function_device=False, is_mains_powered=False, is_receiver_on_when_idle=False, is_router=False, *is_security_capable=False) [0xce92] Discovering endpoints Tries remaining: 3 [0xce92] Extending timeout for 0x08 request Received frame on uninitialized device from ep 0 to ep 0, cluster ZDOCmd.Active_EP_rsp: b'\x08\x00\x92\xCE\x01\x01' [0xce92] Discovered endpoints: [1] [0xce92] Initializing endpoints [<Endpoint id=1 in=[] out=[] status=<Status.NEW: 0>>] [0xce92:1] Discovering endpoint information Tries remaining: 3 [0xce92] Extending timeout for 0x09 request Received frame on uninitialized device from ep 0 to ep 0, cluster ZDOCmd.Simple_Desc_rsp: b'\x09\x00\x92\xCE\x10\x01\x04\x01\x00\x00\x00\x02\x00\x00\x03\x00\x02\x03\x00\x19\x00' [0xce92:1] Discovered endpoint information: SizePrefixedSimpleDescriptor(endpoint=1, profile=260, device_type=0, device_version=0, input_clusters=[0, 3], output_clusters=[3, 25]) [0xce92] Extending timeout for 0x0a request [0xce92:1:0x0000] ZCL deserialize: <ZCLHeader frame_control= manufacturer=None tsn=10 command_id=Command.Read_Attributes_rsp> [0xce92] Read model 'zk78ptr' and manufacturer '_TYST11_czk78ptr' from <Endpoint id=1 in=[basic:0x0000, identify:0x0003] out=[identify:0x0003, ota:0x0019] status=<Status.ZDO_INIT: 1>> [0xce92] Discovered basic device information for Device is initialized Checking quirks for _TYST11_czk78ptr zk78ptr (ec:1b:bd:ff:fe:c2:8b:fe) Considering <class 'ts0601_trv.SiterwellGS361_Type1'> Found custom device replacement for ec:1b:bd:ff:fe:c2:8b:fe: <class 'ts0601_trv.SiterwellGS361_Type1'> 'climate' component -> 'Thermostat' using ['thermostat'] 'sensor' component -> 'ThermostatHVACAction' using ['thermostat'] device - 0xCE92:ec:1b:bd:ff:fe:c2:8b:fe entering async_device_initialized - is_new_join: True device - 0xCE92:ec:1b:bd:ff:fe:c2:8b:fe has joined the ZHA zigbee network 0xCE92: started configuration 0xCE92:ZDO: 'async_configure' stage succeeded [0xCE92:1:0x0201]: bound 'thermostat' cluster: Status.SUCCESS [0xCE92:1:0x0201]: Successfully configured reporting for '{'local_temp': (30, 900, 25), 'occupied_cooling_setpoint': (30, 900, 25), 'occupied_heating_setpoint': (30, 900, 25)}' on 'thermostat' cluster: [ConfigureReportingResponseRecord(status=0)] [0xCE92:1:0x0201]: Successfully configured reporting for '{'unoccupied_cooling_setpoint': (30, 900, 25), 'unoccupied_heating_setpoint': (30, 900, 25), 'running_mode': (30, 900, 25)}' on 'thermostat' cluster: [ConfigureReportingResponseRecord(status=0)] [0xCE92:1:0x0201]: Successfully configured reporting for '{'running_state': (30, 900, 5), 'system_mode': (30, 900, 25), 'occupancy': (30, 900, 1)}' on 'thermostat' cluster: [ConfigureReportingResponseRecord(status=0)] [0xCE92:1:0x0201]: Successfully configured reporting for '{'pi_cooling_demand': (30, 900, 5), 'pi_heating_demand': (30, 900, 5)}' on 'thermostat' cluster: [ConfigureReportingResponseRecord(status=0)] [0xCE92:1:0x0201]: finished channel configuration [0xCE92:1:0x0000]: finished channel configuration [0xCE92:1:0x0001]: bound 'power' cluster: Status.SUCCESS [0xCE92:1:0x0001]: Successfully configured reporting for '{'battery_voltage': (3600, 10800, 1), 'battery_percentage_remaining': (3600, 10800, 1)}' on 'power' cluster: [ConfigureReportingResponseRecord(status=0)] [0xCE92:1:0x0001]: finished channel configuration [0xCE92:1:0x0019]: finished channel configuration Error handling '_save_attribute' event with (ec:1b:bd:ff:fe:c2:8b:fe, 1, 0, 4, '_TYST11_czk78ptr') params: FOREIGN KEY constraint failed [0xCE92:1:0x0201]: 'async_configure' stage succeeded [0xCE92:1:0x0000]: 'async_configure' stage succeeded [0xCE92:1:0x0001]: 'async_configure' stage succeeded [0xCE92:1:0x0019]: 'async_configure' stage succeeded Error handling '_save_attribute' event with (ec:1b:bd:ff:fe:c2:8b:fe, 1, 0, 5, 'zk78ptr') params: FOREIGN KEY constraint failed 0xCE92: completed configuration 0xCE92: stored in registry: ZhaDeviceEntry(name='_TYST11_czk78ptr zk78ptr', ieee='ec:1b:bd:ff:fe:c2:8b:fe', last_seen=1637921673.628254) [0xce92] Extending timeout for 0x0b request [0xce92:1:0x0003] ZCL deserialize: <ZCLHeader frame_control= manufacturer=None tsn=11 command_id=Command.Default_Response> [0xCE92:1:0x0003]: executed 'trigger_effect' command with args: '(2, 0)' kwargs: '{}' result: [64, <Status.UNSUP_CLUSTER_COMMAND: 129>] 0xCE92: started initialization 0xCE92:ZDO: 'async_initialize' stage succeeded [0xCE92:1:0x0201]: initializing channel: from_cache: False [0xCE92:1:0x0201]: Attribute report 'SiterwellThermostat'[ctrl_seqe_of_oper] = ControlSequenceOfOperation.Heating_Only [0xCE92:1:0x0201]: Attribute report 'SiterwellThermostat'[ctrl_seqe_of_oper] = ControlSequenceOfOperation.Heating_Only [0xCE92:1:0x0201]: Attribute report 'SiterwellThermostat'[ctrl_seqe_of_oper] = ControlSequenceOfOperation.Heating_Only [0xCE92:1:0x0201]: finished channel initialization [0xCE92:1:0x0000]: initializing channel: from_cache: False [0xCE92:1:0x0000]: finished channel initialization [0xCE92:1:0x0001]: initializing channel: from_cache: False [0xCE92:1:0x0001]: finished channel initialization [0xCE92:1:0x0019]: initializing channel: from_cache: False [0xCE92:1:0x0019]: finished channel initialization [0xCE92:1:0x0201]: 'async_initialize' stage succeeded [0xCE92:1:0x0000]: 'async_initialize' stage succeeded [0xCE92:1:0x0001]: 'async_initialize' stage succeeded [0xCE92:1:0x0019]: 'async_initialize' stage succeeded 0xCE92: power source: Battery or Unknown 0xCE92: completed initialization Error handling '_unsupported_attribute_added' event with (ec:1b:bd:ff:fe:c2:8b:fe, 1, 513, 0) params: FOREIGN KEY constraint failed Error handling '_unsupported_attribute_added' event with (ec:1b:bd:ff:fe:c2:8b:fe, 1, 513, 17) params: FOREIGN KEY constraint failed Error handling '_unsupported_attribute_added' event with (ec:1b:bd:ff:fe:c2:8b:fe, 1, 513, 18) params: FOREIGN KEY constraint failed Error handling '_unsupported_attribute_added' event with (ec:1b:bd:ff:fe:c2:8b:fe, 1, 513, 19) params: FOREIGN KEY constraint failed Error handling '_unsupported_attribute_added' event with (ec:1b:bd:ff:fe:c2:8b:fe, 1, 513, 20) params: FOREIGN KEY constraint failed Error handling '_unsupported_attribute_added' event with (ec:1b:bd:ff:fe:c2:8b:fe, 1, 513, 30) params: FOREIGN KEY constraint failed Error handling '_unsupported_attribute_added' event with (ec:1b:bd:ff:fe:c2:8b:fe, 1, 513, 41) params: FOREIGN KEY constraint failed Error handling '_unsupported_attribute_added' event with (ec:1b:bd:ff:fe:c2:8b:fe, 1, 513, 28) params: FOREIGN KEY constraint failed Error handling '_unsupported_attribute_added' event with (ec:1b:bd:ff:fe:c2:8b:fe, 1, 513, 2) params: FOREIGN KEY constraint failed Error handling '_unsupported_attribute_added' event with (ec:1b:bd:ff:fe:c2:8b:fe, 1, 513, 7) params: FOREIGN KEY constraint failed Error handling '_unsupported_attribute_added' event with (ec:1b:bd:ff:fe:c2:8b:fe, 1, 513, 8) params: FOREIGN KEY constraint failed Error handling '_unsupported_attribute_added' event with (ec:1b:bd:ff:fe:c2:8b:fe, 1, 1, 32) params: FOREIGN KEY constraint failed Error handling '_unsupported_attribute_added' event with (ec:1b:bd:ff:fe:c2:8b:fe, 1, 1, 33) params: FOREIGN KEY constraint failed Error handling '_unsupported_attribute_added' event with (ec:1b:bd:ff:fe:c2:8b:fe, 1, 1, 49) params: FOREIGN KEY constraint failed Error handling '_unsupported_attribute_added' event with (ec:1b:bd:ff:fe:c2:8b:fe, 1, 1, 51) params: FOREIGN KEY constraint failed [0xce92:1:0xef00] ZCL deserialize: <ZCLHeader frame_control= manufacturer=None tsn=0 command_id=1> [0xce92:1:0xef00] ZCL request 0x0001: [Command(status=0, tsn=62, command_id=257, function=0, data=[1, 1])] [0xce92:1:0xef00] ZCL deserialize: <ZCLHeader frame_control= manufacturer=None tsn=1 command_id=1> [0xce92:1:0xef00] ZCL request 0x0001: [Command(status=0, tsn=63, command_id=1293, function=0, data=[1, 2])] [0xce92:1:0xef00] ZCL deserialize: <ZCLHeader frame_control= manufacturer=None tsn=2 command_id=1> [0xce92:1:0xef00] ZCL request 0x0001: [Command(status=0, tsn=64, command_id=1038, function=0, data=[1, 1])] [0xce92:1:0xef00] ZCL deserialize: <ZCLHeader frame_control= manufacturer=None tsn=3 command_id=1> [0xce92:1:0xef00] ZCL request 0x0001: [Command(status=0, tsn=65, command_id=1028, function=0, data=[1, 0])] [0xCE92:1:0x0201]: Attribute report 'SiterwellThermostat'[system_mode] = SystemMode.Off [0xCE92:1:0x0201]: Attribute report 'SiterwellThermostat'[running_mode] = RunningMode.Off [0xCE92:1:0x0201]: Attribute report 'SiterwellThermostat'[running_state] = RunningState.Idle climate.tyst11_czk78ptr_zk78ptr_fe8bc2fe_thermostat: Attribute 'system_mode' = SystemMode.Off update climate.tyst11_czk78ptr_zk78ptr_fe8bc2fe_thermostat: Attribute 'running_mode' = RunningMode.Off update climate.tyst11_czk78ptr_zk78ptr_fe8bc2fe_thermostat: Attribute 'running_state' = RunningState.Idle update [0xce92:1:0xef00] ZCL deserialize: <ZCLHeader frame_control= manufacturer=None tsn=4 command_id=1> [0xce92:1:0xef00] ZCL request 0x0001: [Command(status=0, tsn=66, command_id=514, function=0, data=[4, 0, 0, 0, 190])] [0xCE92:1:0x0201]: Attribute report 'SiterwellThermostat'[occupied_heating_setpoint] = 1900 climate.tyst11_czk78ptr_zk78ptr_fe8bc2fe_thermostat: Attribute 'occupied_heating_setpoint' = 1900 update [0xce92:1:0xef00] ZCL deserialize: <ZCLHeader frame_control= manufacturer=None tsn=5 command_id=1> [0xce92:1:0xef00] ZCL request 0x0001: [Command(status=0, tsn=67, command_id=274, function=0, data=[1, 1])] [0xce92:1:0xef00] ZCL deserialize: <ZCLHeader frame_control= manufacturer=None tsn=6 command_id=1> [0xce92:1:0xef00] ZCL request 0x0001: [Command(status=0, tsn=68, command_id=263, function=0, data=[1, 0])] [0xce92:1:0xef00] ZCL deserialize: <ZCLHeader frame_control= manufacturer=None tsn=7 command_id=1> [0xce92:1:0xef00] ZCL request 0x0001: [Command(status=0, tsn=69, command_id=1041, function=0, data=[1, 1])] [0xce92:1:0xef00] ZCL deserialize: <ZCLHeader frame_control= manufacturer=None tsn=8 command_id=1> [0xce92:1:0xef00] ZCL request 0x0001: [Command(status=0, tsn=70, command_id=515, function=0, data=[4, 0, 0, 0, 154])] [0xCE92:1:0x0201]: Attribute report 'SiterwellThermostat'[local_temp] = 1540 climate.tyst11_czk78ptr_zk78ptr_fe8bc2fe_thermostat: Attribute 'local_temp' = 1540 update

accessiblepixel commented 2 years ago

So I put lots of updates in the previous comment to avoid loads of comment notifications...

It seems to be working alright, just a bit slow on the temperature updates, but I guess that's just because it's battery powered.

Whenever you're ready let me know how to test the new integration :)

Also, does the ZHA-Device_Handlers project have a 'coffee donation' type thing, or a charity that they'd prefer donations to be sent to (in their name)? Feel like sending a couple of bucks in support.

Kind regards, Jessica

MattWestb commented 2 years ago

The last question you can find in https://github.com/zigpy/zigpy/blob/dev/CONTRIBUTING.md#how-to-contribute-as-an-end-user.

And all tuya TRV is sleeping end devices so they is not have the radio on all the time and can taking some seconds before they is catching waiting commands from its parent.

"Normal" Zigbee device is its possible configuration of attribute reporting all normal clusters. But tuya is reusing MCUs from other platforms like WiFi and BT and is only using the ZIgbee module a one tunnel for there "MQTT to cloud" service (sending DP commands = Data Points). So on the Zigbee level we cant do any thing at all. My TRV is reporting local temperature around 60 min and if the temperature is changing more then 1°C its updating it faster.

Some TRVs is possible sending one updating local temperature calibration and the MCU is sending one old and new local temperature but our MCU have that not implanted.

Now to the funny thing !! The TRV was added in the first commit for 10 mount ago but with only basic function and most other have getting updates from nice coding user but our not. I have starting trying copy and paste for getting things working but it was not 100% but now one very good code warier have fixing nearly all lost broken things plus implanting some new good things.

Dow load the new quirk from this post https://github.com/zigpy/zha-device-handlers/discussions/1084#discussioncomment-1701973 and deleting the "old one" and restart HA. If you can copy the climate.py you is also getting presets working in ZHA but is not one must.

You is getting some new switches and sensors that needs being renamed but is not easy to finding them. I can explaining later how to finding the function but i must looking little on the last version before i writing that.

If all is going well you shall getting somthing like this on the device card (after adding new custom classed and icon to the entry's: TRV_ZHA18

And from loverns card with TRV and sensor graf: TRV_ZHA19 I posting more info for doing the custom things !!

MattWestb commented 2 years ago

The switches and sensors is having this configuration in the quirk: EP 1: Window Detection switch On / Off EP 2: Valve Detection switch On / Off EP 3: Window Open Alarm sensor EP 4: Valve Jammed Alarm sensor EP 5: Child Lock switch On / Off EP 6: Install Mode (FI) Switch On / Off EP 7: Local Temp Calibration sensor (slider + - 10 ° / 0.1°)

And the first on/off is the window detection and you can trying switching it on and off and you shall see it changing on the TRV display. The second is val detect is have no icon in the display so you cant see it. The third Children lock you can pressing the button on the TRV for 5 seconds and the switch is toggled in ZHA. The forth is FI (= taking the battery out and putting them back and doing calibration of the valve) and if you is switching it on the TRV is showing FI1 and you must calibrating the valve.

The sensors is: First Window Open / anti freeze Alarm sensor Second Valve Jammed Alarm sensor and the last is one slider for local temperature calibration.

The name of all is not 110% but its possible finding them out.

For valve jammed put the setpoint to high and the TRV is sending valve jammed and one ! in the window (if activated). Putting the TRV in the freezer and you is getting window open / antifreeze alarm (if activated).

I have making this customization in HA for getting good icons and functions:

From my customize.yaml in HA:

binary_sensor.tyst11_trv_binary_input_2:
  device_class: problem
binary_sensor.tyst11_trv_binary_input:
  device_class: opening
switch.tyst11_trv_on_off:
  icon: mdi:window-open-variant
switch.tyst11_trv_on_off_2:
  icon: mdi:pipe-valve
switch.tyst11_trv_on_off_3:
  icon: mdi:lock
switch.tyst11_kfvq6avy_fvq6avy_c1db03fe_on_off:
  icon: mdi:wrench

The name of the sensors / switches is always little trickey.

Its also possible giving all names and and looking / editing in \.storage\core.entity_registry and finding the right end point:

            {
                "entity_id": "switch.tyst11_kfvq6avy_fvq6avy_c1db03fe_on_off",
                "config_entry_id": "1509216dc5c6aac3464ac35895885f7b",
                "device_id": "55b2995a1e4187422eef81c61b572b3f",
                "area_id": null,
                "unique_id": "bc:33:ac:ff:fe:03:db:c1-6-6",
                "platform": "zha",
                "name": "TYST11 TRV FI",
                "icon": "mdi:wrench",
                "disabled_by": null,
                "capabilities": {},
                "supported_features": 0,
                "device_class": null,
                "unit_of_measurement": null,
                "original_name": "_TYST11_kfvq6avy fvq6avy c1db03fe on_off",
                "original_icon": null,
                "entity_category": null
            }
        ]
    }

Then the unique_id bc:33:ac:ff:fe:03:db:c1 is the long address for the device and in the end the end point and cluster number 6-6. Cross reference with the En point list. name is the name the entry is having in the HA GUI.

The local temperature calibration is only for ZHA showing heating / idle and also getting the graf looking nice. I have -0.9° for the moment and it can being adjusted for making it looks right then the TRV is not sending any status of the valve is open or closed so the quirk is comparing and saying heating or idle.

MattWestb commented 2 years ago

Sorry i was missing your communicating problems (sorry TRV . . ). Sending commands can being little tricky but resiving is normal working very fast. But its one sleeping end device and we can do so much about it. If having larger problem delete the device in ZHA waiting one minute and restarting HA. Then ZHA is stable adding the device and look if all looks OK. If the quirk is not loaded OK restart HA and it shall doing it OK.

accessiblepixel commented 2 years ago

Sorry if I was a little confusing!

I'll try using the new climate.py as suggested and report back :)

Edit: Do I use the climate.py from the first zip file you gave me?

MattWestb commented 2 years ago

Yes ! :-)

accessiblepixel commented 2 years ago

This folder /usr/src/homeassistant/homeassistant/components/zha/ doesn't exist. Should I create it?

This is the output when searching for a 'zha' directory. [core-ssh /]$ find | grep zha ./config/custom_zha_quirks ./config/custom_zha_quirks/climate.py ./config/custom_zha_quirks/ts0601_trv_siterwell.py ./config/custom_zha_quirks/__pycache__ ./config/custom_zha_quirks/__pycache__/ts0601_trv_siterwell.cpython-39.pyc ./config/custom_zha_quirks/__pycache__/ts0601_trv.cpython-39.pyc ./config/.storage/zha.storage

MattWestb commented 2 years ago

Its not existing in the OS. You must connecting to the docker container and open one CLI in it for getting it then its only in the container.

Do you running on bare metal , VM or OS ?

MattWestb commented 2 years ago

You looks being much better in the Linux CLI then my ;-((

accessiblepixel commented 2 years ago

It's running in a virtual machine. I'm running Home Assistant OS 6.5.

I've installed the addon to let me SSH to it. I'll try having a look from the CLI.

Ah... Yes. I can see that folder if I login from the CLI, but I don't have SSH access to that with the addon SSH thing... so I needed to setup a private key and insert a usb stick to get access to the "real" SSH...

Anyway, I have copied that file over and am now rebooting... Certainly nothing simple about HA is there? 🤣

Edit: To anyone else reading, to get access to the Supervisor, the place where you need to update the climate.py you have to create an SSH key, and put it on a USB stick with the label "CONFIG" in a file called authorized_keys (no extension) and it must be ANSI with Linux line terminations, and then reboot the host. Then you can SSH in on port 22222 and use the command docker exec -it homeassistant /bin/bash which will get you into the console for the Supervisor Docker Container. These instructions I found at this address: https://developers.home-assistant.io/docs/operating-system/debugging/

accessiblepixel commented 2 years ago

Okay, now I've replaced climate.py and used that file from the linked thread, but now the integration isn't working again, it just says Failed to set up Check the logs

And when I check the logs, nothing is listed there :(

Am I allowed to hit it yet? 🤣

MattWestb commented 2 years ago

I hope you was only copying the climate.py to the container and not the quirk for the device.

You can delete the quirk in the local quirk folder so its not making problems.

If you is not having one very large set up little more debug logging like:

logger:
  default: info
  logs:
    homeassistant.core: info
    homeassistant.components.zha: debug
    zigpy: debug
    zhaquirks: debug
accessiblepixel commented 2 years ago

Yes, only copied the climate.py to /usr/src/homeassistant/homeassistant/components/zha/climate.py.

D'oh! I only COPIED climate.py to that folder, I didn't delete it from the custom_zha_components folder where I uploaded it to :( 🤦

Okay so the integration had loaded up again, but now there's no controls shown, so I don't think it's recognising to use the new quirk file with the device.

MattWestb commented 2 years ago

Perhaps some one was forgetting adding your device id in the quirk ?

Adding it in or after line 648 (you can using one of the old one than you dont having then if you like) (copy the string from the first quirk in the zip is best)

I can get enough sleep . . .

accessiblepixel commented 2 years ago

Perhaps some one was forgetting adding your device id in the quirk ?

Adding it in or after line 648 (you can using one of the old one than you dont having then if you like)

I can get enough sleep . . .

Whoops! Well, adding it has got some functionality working again :)

I think it's just it doesn't know what the names of the things are like you said in one of your other posts.

Here's a screenshot of the device in ZHA. I've gotta disappear for a bit, but I'll have a crack at figuring out what is what when I get back.

https://i.lowrex.com/i/C0aA.png

I'm super appreciative of your help, thanks just doesn't seem to be enough. Hopefully since we've gone through this, the next person who tries to do what I'm doing won't have to lose so much hair xD

MattWestb commented 2 years ago

The grayed out you can delete its some old thing from the old quirk. The first with the slider is local temperature correction set it to -0.9° and adjusting it later if you need. I hope your device is communicating OK but you dont have any battery reading but its only reported one or 2 times day.

Try switching the children lock on the TRV and see if you is getting on of the switches changing state.

MattWestb commented 2 years ago

PR made waiting merging :)

accessiblepixel commented 2 years ago

PR made waiting merging :)

Amazing :) I'll have a play with the device to see if I can get some names figured out for each of the sensors and configurations after I've defrosted from being outside. It's about 3C out, so quite tepid :rofl:

My partner and I are very grateful for your help!

I do have a question when the change is merged and finally added upstream, will I just have to remove the custom quirk or will it be an "automagic" process at some point when it gets into the main HA branch?

MattWestb commented 2 years ago

I was going to LIDL on noon and it was raining snow and not its 10 cm of the col well JUNCK outside !!!

The merger is for the old implementation then we have not getting OK for the new then its one braking thing with many users is using it in there systems and its not popular braking working systems.

If leaving the local quirk its overriding the one in the HA docker container. So if you like using the old you deleting the new one in the local quirk folder and and ZHA is using the internal one.

The only thing is the the presets (the modified climate.py) is gone and need being copy in to the container with SSH but its shall not being used if using the old quirk then its not having presets.

accessiblepixel commented 2 years ago

I'll leave it running the new one for now then, and see if I can get the whole network swapped over, do some testing to find out which switches correspond to which function.

I agree, it's probably best not to break people's systems (although Home Assistant did that massive breaking change when they changed the Tuya API, although Tuya only gave them 2 months, but now they extended it)...

However, any support is much better than no support 👯‍♀️

... and your support has been exceptional. Thank you greatly.

JyothishGeorge commented 2 years ago

Hi

I have similar trv with me trying to pair and the pairing is successful. The HA is updated to core-2021.12.0 and I copied zha-quirks 0.0.65 to the zha-quirks folder. Removed the pycache and HA restarted. After pairing the TRV not all the entities are loaded for me. Please see the device signature below.

{ "node_descriptor": "NodeDescriptor(logical_type=<LogicalType.EndDevice: 2>, complex_descriptor_available=0, user_descriptor_available=0, reserved=0, aps_flags=0, frequency_band=<FrequencyBand.Freq2400MHz: 8>, mac_capability_flags=<MACCapabilityFlags.AllocateAddress: 128>, manufacturer_code=0, maximum_buffer_size=82, maximum_incoming_transfer_size=255, server_mask=11264, maximum_outgoing_transfer_size=255, descriptor_capability_field=<DescriptorCapability.NONE: 0>, allocate_address=True, is_alternate_pan_coordinator=False, is_coordinator=False, is_end_device=True, is_full_function_device=False, is_mains_powered=False, is_receiver_on_when_idle=False, is_router=False, *is_security_capable=False)", "endpoints": { "1": { "profile_id": 260, "device_type": "0x0301", "in_clusters": [ "0x0000", "0x0001", "0x0003", "0x0201", "0x0204", "0xef00" ], "out_clusters": [ "0x0003", "0x0019" ] } }, "manufacturer": "_TYST11_czk78ptr", "model": "zk78ptr", "class": "zhaquirks.tuya.ts0601_trv.SiterwellGS361_Type1" }

All I get is thermostat and hvac_action. Could you please help me figuring out to load the rest of the attributes? Any help on this is greatly appreciated. Not sure what am I missing.

trv

Thanks George

MattWestb commented 2 years ago

You dont need updating the the quirk in HA 2021.12 then all is in for the basic function for your TRV. But for the moment its looks like your is not communicating then you dont have any battery status reported.

For getting te extended quirk you need configuring local quirks in HA https://github.com/zigpy/zha-device-handlers/discussions/693#discussioncomment-857274 and puting the unziped file from this post https://github.com/zigpy/zha-device-handlers/discussions/1084#discussioncomment-1756246 in the new local quirk forlder. After restart of HA you shall getting all new entries but not presets in the thermostat card. Unzip the climate.py from this file climate.zip and copy it to your HA configuring folder. Then you need open one CLI in the HA docker container and copy it in the the ZHA folder with this command:

 cp /config/climate.py /usr/src/homeassistant/homeassistant/components/zha/climate.py

restart HA anad you shall having presets in the thermostat card.

JyothishGeorge commented 2 years ago

Thanks MattWestb for looking in to this, I still have'nt got any luck in getting all the attributes loaded for thsi TRV.

My HA configuration is as follows

zha: custom_quirks_path: /config/custom_zha_quirks/

logger: default: info logs: homeassistant.components.zha: debug zigpy: debug zhaquirks: debug ts0601_trv_siterwell: debug

I followed below steps

  1. HA uodated to core-2021.12.1
  2. Copied ts0601_trv_siterwell.py to /config/custom_zha_quirks/
  3. Copied attached climate.zip file ( cp /config/climate.py /usr/src/homeassistant/homeassistant/components/zha/climate.py )
  4. Removed pycache from custom_zha_quirks and /usr/local/lib/python3.79/site-packages/zhaquirks/
  5. Restarted HA
  6. Paied the TRV again

I see a message 2021-12-13 13:05:17 DEBUG (MainThread) [zhaquirks] Loading custom quirks module ts0601_trv_siterwell

But no attributes were loaded as before, I tried to set one of the presets from dropdown from GUI, I get following error

021-12-13 13:44:51 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [1691801344] 'operation_preset' Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 185, in handle_call_service await hass.services.async_call( File "/usr/src/homeassistant/homeassistant/core.py", line 1495, in async_call task.result() File "/usr/src/homeassistant/homeassistant/core.py", line 1530, in _execute_service await handler.job.target(service_call) File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 209, in handle_service await self.hass.helpers.service.entity_service_call( File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 663, in entity_service_call future.result() # pop exception if have File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 896, in async_request_call await coro File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 700, in _handle_entity_call await result File "/usr/src/homeassistant/homeassistant/components/zha/climate.py", line 466, in async_set_preset_mode if preset_mode != PRESET_NONE and not await self.async_preset_handler( File "/usr/src/homeassistant/homeassistant/components/zha/climate.py", line 772, in async_preset_handler return await self._thrm.write_attributes( File "/usr/src/homeassistant/homeassistant/components/zha/core/channels/hvac.py", line 292, in write_attributes res = await self.cluster.write_attributes(data, **kwargs) File "/usr/local/lib/python3.9/site-packages/zhaquirks/tuya/init.py", line 583, in write_attributes records = self._write_attr_records(attributes) File "/usr/local/lib/python3.9/site-packages/zigpy/zcl/init.py", line 358, in _write_attr_records attrid = self.attridx[attrid] KeyError: 'operation_preset'

Looks like some mismatch in the version of the files, could you please let me know where have I gone wrong,

trv

Thanks a lot, George

MattWestb commented 2 years ago

Sorry its my fault !!!

The new device DI was not added in the quirk then its one new device. I have making on updated version of the last one i have in my system with your device added.

ts0601_trv_siterwell.zip

Replacing the old one in your local quirk folder and deleting the cash folder and restarting HA and look how its working.

JyothishGeorge commented 2 years ago

Hi MattWest

Its working for lot more attributes , you are super helpful, appreciate your time to check this, I will look around and understand the code in detail and looking forward to contributing if I can, I have few more TRVs (Tuya) and going to put in testing soon,

Thanks a lot, George trv

MattWestb commented 2 years ago

Great !!

I wondering why you not having any battery reported ?

You can trying deleting the device and waiting one minute and paring it and look if you is getting data from the device OK. Also you have one old switch that i think is from the old quirk have saving in the device database that is not have any function.

For getting the functions of the switches and sensors look in the quirk for the endpoints and ZHA is pupotling them with first found is without number in the entity ID and the second one is getting 2 and so on.

All thanks is going to @jacekk015 that have doing the coding !!!

accessiblepixel commented 2 years ago

Just a slight update, the "old" (current integration) in home assistant works fine with my valve.

I don't get battery info, but other than that it gets the temperature, I can set the temperature and can turn heat on/off.

I deleted the custom quirk when upgrading to home assistant 2021.12.6 and it all works magically fine (and reports in every 10 minutes if there's no change, where as the "new" beta method didn't update itself for some reason at all).

Thanks again for all the help :)

james-fry commented 1 year ago

Is battery reporting working in ZHA? I can see above a few commments that its not... I am trying to add support for TCP valve (modelID: 'zk78ptr', manufacturerName: '_TYST11_czk78ptr') to zigbee2mqtt but I dont get battery reported.

MattWestb commented 1 year ago

Try its with ZHA only disable Z2M and installing ZHA and you can testing it.

accessiblepixel commented 1 year ago

I've never had battery indication work in my home assistant... I use the Lithium AA batteries which will do a whole year so long as the valves aren't too active, but it would be nice to have it reporting battery status.

Edit: This is how it looks in mine... "unknown %", but no other functionality is affected. It'd be nice, but... not something I've pursued recently. @MattWestb - Do you have any ideas about this, since I know when we spoke about this before you thought it would update over time, but I never did... I just didn't think it important enough to bug devs about, but now someone's emailed in asking about it, let me know how I can help debug/fix :)

Screenshot: https://i.lowrex.com/i/BN1K2.png

MattWestb commented 1 year ago

Nop i have 5 in production and test network and all is reporting battery % and one is eating double battery then the other.

Perhaps is your Lithium but i dont think it shall doing any different as ling you is getting enough voltages for the device from them.

You can try taking the battery out and waiting one minute and putting them back then the MCU shall reporting all DP to the host system.

Its also possible that this device MCU is having one different firmware that is using other functions but then you shall see the DP in the log that is changing then it reporting it (also after repower).

accessiblepixel commented 1 year ago

Hmm. I'm not sure that it's because of the lithium AA batteries... I have a couple that are running standard Alkalines and they don't report either...

It might be because mine are the TCP Smart ones, maybe it reports it's battery info in a different variable (or a different way), maybe just slightly different to the device the quirk is based on? @MattWestb Is there anything I can grab from them to show all the data that they have available, to see if we can find that battery info and "map" it to the right field if this is what's happening? :)

MattWestb commented 1 year ago

@accessiblepixel If you have one TRV that is pared OK with ZHA and have logging enabled and then taking the battery out and waiting one minute and outing it back the tuya MCU shall sending all DPs (commands) its using and you is getting them in the HA log.

I can being that its one updated version of the MCU firmware that have changing commands its using (some other manufacture have doing it) and if we is getting the DPs and then its possible doing one new mapping with them and its working OK but we is needing the information. If i remember is the TRV not reporting the battery status so oft but i think its around 23 hours.

Have you looking if Z2M and deCONZ have getting the device supported and if the is using the came code for other devices ?

One current snapshot from my test TRV: TRV001