home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
73.73k stars 30.85k forks source link

ZHA Tuya attribute missing in TS130F curtain module #46146

Closed FaBRiK74 closed 1 year ago

FaBRiK74 commented 3 years ago

The problem

Not able to calibrate TS130F based Zigbee curtain module (e.g. https://zigbee.blakadder.com/Lonsonho_TS130F.html) in ZHA because the ZHA cluster and its attributes are missing. This attribute contains the calibration. This is Calibration (0xF001)

What is version of Home Assistant Core has the issue?

core-2021.2.0

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

ZHA

Link to integration documentation on our website

https://www.home-assistant.io/integrations/zha/

Example YAML snippet

# Put your YAML below this line

Anything in the logs that might be useful for us?

# Put your logs below this line
franderlink commented 3 years ago

I have already ordered the TUYA brand hub to do that this week I'll tell how it went.

franderlink commented 3 years ago

The calibration is different... Only the time that the curtain would last to open 100% is added

Screenshot_2021-08-05-18-49-27-505_com.tuya.smartlife.jpg

Here!

IMG_20210805_185043.jpg

i'm looking at the possibility of using ZShark with my conbee 2, but it asks me to update the firmware and I don't want to risk it

jrochate commented 3 years ago

Ok, this makes sense.

Now we just need to find your the register for that setting.

You can always revert / update firmware again from here:

http://deconz.dresden-elektronik.de/deconz-firmware/

You are a little step close to solution :)

navterro commented 3 years ago

@franderlink did you manage to capture calibration command sent by hub?

franderlink commented 3 years ago

I can't understand how zshark works. In addition, after calibrating the device with the TUYA hub, the calibration is saved and then it connects with zha HA with the calibrated operating time.

MattWestb commented 3 years ago

@franderlink If you is paring one device with the tuya ZBGW the network key is sent to the device with one well known mater key so its possible looking on the traffic if you is catching all from start pairing until you have doing the calibration.

If you is not having one joining device in thee beginning you need putting your (the tuya ZBGW)) network key in edit > preferences > protocols > Zigbee > Zigbee Network Layer > Edit. Then you can looking in all sniff made from that network until you is changing the network key in the network

jrochate commented 3 years ago

Thank you for you efforts. One question: if you disconnect tuya hub, configure the device to work with ZHA, then poweroff the device for about 1 hour, and then powerup again, does it "forget" the operating time or it maintains the calibration setting made before?

I'm asking this because I'm afraid that the device needs to sync some info with tuya cloud, like calibration time, instead of registering it on a non-volatile ram.

In that case, every time a power outage occurs, we would have to connect it again to Tuya, reconfigure calibration, and get back to HA.

franderlink commented 3 years ago

save settings forever ...

navterro commented 3 years ago

@franderlink could you post tuya hub model which you used and works with moes curtain module ?

I have only one module but I spent a lot of time and effort to physically install it... so Im desperate and I will buy this stupid hub :)

franderlink commented 3 years ago

Hub: https://www.amazon.es/MOES-automatizaci%C3%B3n-compatible-productos-inteligentes/dp/B08KFBPJ3N

Device Curtain: https://www.amazon.co.uk/MOES-Electric-Motorized-Available-Compatible/dp/B091CVPRGN

navterro commented 3 years ago

thx - i will look for moes zb-hub device

jrochate commented 3 years ago

FOUND IT!!!!

I was almost there by trying and error, but with this post I solved the problem!

https://github.com/Koenkk/zigbee2mqtt/issues/7128#issuecomment-895928027

The solution is to use the attribut 0xF003 but set it to t.uint16_t I had with enum8 and that doesn't work.

So, here is a snippetf of my quirk for attribut customization:

`class TuyaCoveringCluster(CustomCluster, WindowCovering): """TuyaSmartCurtainWindowCoveringCluster: Allow to setup Window covering tuya devices."""

attributes = WindowCovering.attributes.copy()
attributes.update({0xF000: ("tuya_moving_state", t.enum8)})
attributes.update({0xF001: ("tuya_calibration", t.enum8)})
attributes.update({0xF002: ("motor_reversal", t.enum8)})
attributes.update({0xF003: ("calibration_time", t.uint16_t)})

`

and i attach is HA cluster interface.

As you can see I have set a 20 second time, and it just works. The percentage adjusts to that time interval.

2021-08-10_15-14-04

silversmarty commented 3 years ago

I'm trying to use this method (calibration) with my Tuya Curtain Switch (_TZ3000_8kzqqzu4) but it doesn't seem the process is the same :

At some point, the curtain is blocked in a position where no action makes it move (up or down, whether in calibration mode or not). Is it something that you've already experienced ? I can send the device signature if it helps (device is this one)

Thanks!

moritan commented 3 years ago

Hello, the calibration process, i give was for an other model of switch. You should follow the step given by Tuya and start with curtain open before enter en calibration mode.

You can post signature, if you still have problèm. So we could check if ther is something different in your model.

silversmarty commented 3 years ago

Here is the 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=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": "0x0202", "in_clusters": [ "0x0000", "0x0004", "0x0005", "0x0006", "0x000a", "0x0102" ], "out_clusters": [ "0x0019" ] } }, "manufacturer": "_TZ3000_8kzqqzu4", "model": "TS130F", "class": "zhaquirks.tuya.ts130f.TuyaTS130F" }

lebretr commented 3 years ago

Hi,

I don't know if I am in the good place but the PR #980 don't resolve the pb for me.

I installed HA and ZHA on a Linux today. I launched the zigbee discovery scan and my TS130F module is discovered but I have not the "TuyaCoveringCluster" in the config and so I can't calibrate my module

Capture d’écran du 2021-09-28 21-58-17

Here the log for my TS130F:

2021-09-28 20:17:21 INFO (MainThread) [zigpy.device] [0xee00] Discovered basic device information for <Device model='TS130F' manuf='_TZ3000_fccpjz5z' nwk=0xEE00 ieee=a4:c1:38:f7:65:9b:54:e9 is_initialized=True>
2021-09-28 20:17:21 DEBUG (MainThread) [zigpy.application] Device is initialized <Device model='TS130F' manuf='_TZ3000_fccpjz5z' nwk=0xEE00 ieee=a4:c1:38:f7:65:9b:54:e9 is_initialized=True>
2021-09-28 20:17:21 DEBUG (MainThread) [zigpy.quirks.registry] Checking quirks for _TZ3000_fccpjz5z TS130F (a4:c1:38:f7:65:9b:54:e9)
2021-09-28 20:17:21 DEBUG (MainThread) [zigpy.quirks.registry] Considering <class 'zhaquirks.tuya.ts130f.TuyaTS130FTO'>
2021-09-28 20:17:21 DEBUG (MainThread) [zigpy.quirks.registry] Fail because endpoint list mismatch: {1} {1, 242}
2021-09-28 20:17:21 DEBUG (MainThread) [zigpy.quirks.registry] Considering <class 'zhaquirks.tuya.ts130f.TuyaZemismartTS130F'>
2021-09-28 20:17:21 DEBUG (MainThread) [zigpy.quirks.registry] Fail because endpoint list mismatch: {1} {1, 242}
2021-09-28 20:17:21 DEBUG (MainThread) [zigpy.quirks.registry] Considering <class 'zhaquirks.tuya.ts130f.TuyaTS130FTI'>
2021-09-28 20:17:21 DEBUG (MainThread) [zigpy.quirks.registry] Fail because endpoint list mismatch: {1} {1, 242}
MattWestb commented 3 years ago

@lebretr ZHA have not loading the quirk for your device as you can see in the log Fail because endpoint list mismatch: {1} {1, 242} . Post the Zigbee device signature from the device card.

lebretr commented 3 years ago

Here is the 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=4417, maximum_buffer_size=66, maximum_incoming_transfer_size=66, server_mask=10752, maximum_outgoing_transfer_size=66, 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": "0x0202",
      "in_clusters": [
        "0x0000",
        "0x0004",
        "0x0005",
        "0x0006",
        "0x0102"
      ],
      "out_clusters": [
        "0x000a",
        "0x0019"
      ]
    },
    "242": {
      "profile_id": 41440,
      "device_type": "0x0061",
      "in_clusters": [],
      "out_clusters": [
        "0x0021"
      ]
    }
  },
  "manufacturer": "_TZ3000_fccpjz5z",
  "model": "TS130F",
  "class": "zigpy.device.Device"
}
MattWestb commented 3 years ago

The "class": "zigpy.device.Device" is saying its no quirk loaded and the reason is that your device have one Zigbee Green power endpoint (242) that "normal old ones" is not having and need being added in the quirk for it to loading for your device.

lebretr commented 3 years ago

In /srv/homeassistant/lib/python3.8/site-packages/zhaquirks/tuya/ts130.py, I added "GreenPowerProxy" in the import like this:

from zigpy.zcl.clusters.general import Basic, GreenPowerProxy, Groups, OnOff, Ota, Scenes, Time

and I added a class like this

class TuyaTS130RLEB(CustomDevice):
    """Tuya smart curtain roller shutter Time In."""

    signature = {
        # SizePrefixedSimpleDescriptor(endpoint=1, profile=260, device_type=0x0202, device_version=1, input_clusters=[0, 4, 5, 6, 10, 0x0102], output_clusters=[25]))
        MODEL: "TS130F",
        ENDPOINTS: {
            1: {
                PROFILE_ID: zha.PROFILE_ID,
                DEVICE_TYPE: zha.DeviceType.WINDOW_COVERING_DEVICE,
                INPUT_CLUSTERS: [
                    Basic.cluster_id,
                    Groups.cluster_id,
                    Scenes.cluster_id,
                    OnOff.cluster_id,
                    WindowCovering.cluster_id,
                ],
                OUTPUT_CLUSTERS: [Time.cluster_id, Ota.cluster_id],
            },
            242: {
                # <SimpleDescriptor endpoint=242 profile=41440 device_type=97
                # input_clusters=[]
                # output_clusters=[33]
                PROFILE_ID: 41440,
                DEVICE_TYPE: 97,
                INPUT_CLUSTERS: [],
                OUTPUT_CLUSTERS: [GreenPowerProxy.cluster_id],
            },
        },
    }
    replacement = {
        ENDPOINTS: {
            1: {
                PROFILE_ID: zha.PROFILE_ID,
                DEVICE_TYPE: zha.DeviceType.WINDOW_COVERING_DEVICE,
                INPUT_CLUSTERS: [
                    Basic.cluster_id,
                    Groups.cluster_id,
                    Scenes.cluster_id,
                    OnOff.cluster_id,
                    TuyaCoveringCluster,
                ],
                OUTPUT_CLUSTERS: [Ota.cluster_id],
            },
            242: {
                PROFILE_ID: 41440,
                DEVICE_TYPE: 97,
                INPUT_CLUSTERS: [],
                OUTPUT_CLUSTERS: [GreenPowerProxy.cluster_id],
            },
        },
    }

And all work fine. Now I can calibrate my module and fully open my shutter

thanks @MattWestb

MattWestb commented 3 years ago

GREAT !!!

You have 2 problems in the PR one is its one missing blank line and you need braking the import then its little long.

Use Black playground for fixing the blank line and it perhaps doing the long line 2. https://black.vercel.app/ past your code in the left side and you is getting the patched on the right side.

-from zigpy.zcl.clusters.general import Basic, GreenPowerProxy, Groups, OnOff, Ota, Scenes, Time
+from zigpy.zcl.clusters.general import (
+    Basic,
+    GreenPowerProxy,
+    Groups,
+    OnOff,
+    Ota,
+    Scenes,
+    Time,
+)

 from zhaquirks.const import (
     DEVICE_TYPE,
@@ -187,6 +195,7 @@ class TuyaTS130FTO(CustomDevice):
         },
     }

+
 class TuyaTS130GP(CustomDevice):
     """Tuya ZemiSmart smart curtain roller shutter with Green Power."""

Very well done !!

Hedda commented 3 years ago

Is this "GreenPowerProxy" quirk in any way related to the Zigbee Green Power PR https://github.com/zigpy/zigpy/pull/656 ("[WIP] Add ZGP ...") for zigpy?

MattWestb commented 3 years ago

Nop is only one Zigbee 3 routing device and have one ZGP proxy cluster as all normal Zigbee 3 routers i having and the PR is only adding it for ZHA for matching the quirk on the endpoints and the cluster of the device.

All real zigbee 3 routers is having the proxy cluster for getting certified and is only being used as proxy for ZGP devices and is "transparent" function in the routers then they only forwarding the short ZGP frames to its neighbors so the ZGP devices can communicating in the network.

Smaster-Arch commented 3 years ago

Hello,

i am new to Home-Assistant and i am not a 'computer-professional'...

Nevertheless i managed to access the ts130.py file in /zhaquirks/tuya/, but i didn't understand, what i have to insert here exactly (the complete signature of my device, as displayed by Home-Assistantand under Device-Information - Zigbee-Signature?) and the exact position, where i have to insert it?

Although i dont know, if this change will survive Home-Assistant-Updates or if i have to repeat the change after every update?

Here is my Zigbee-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=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": "0x0203", "in_clusters": [ "0x0000", "0x0004", "0x0005", "0x0006", "0x0102" ], "out_clusters": [ "0x000a", "0x0019" ] } }, "manufacturer": "_TZ3000_1dd0d5yi", "model": "TS130F", "class": "zigpy.device.Device" }

And if i schould manage, to get the ts130.py file completed with the neccessary changes, will i be able to do the calibration and use the device with Home-Assistant and ZHA (i have a conbeeII to access my other devices, like Osram and Ikea plugs and buttons) or will i need a tuya-hub in addition?

Thank's for your help in advance!

MattWestb commented 3 years ago

One PR is being merged for 3 days ago that looks having the same signature https://github.com/zigpy/zha-device-handlers/pull/1154 so you can copy the ts130f.py from dev branch https://github.com/zigpy/zha-device-handlers/blob/dev/zhaquirks/tuya/ts130f.py and configuring local quirk and putting the newts130f.py in the new folder and restarting HA.

If its loading OK you shall getting the quirk name as device class instead of "class": "zigpy.device.Device".

Smaster-Arch commented 2 years ago

Hello and thanks alot for the fast help!

I tried the ts130.py file from your link this weekend and the neccessary quirks were loaded!

I did not have enough time for further settigngs and automations, but i am confident, that everything will work with the correct quirks loaded.

Thanks again and a lot of health to all here,

Smaster-Arch

HB1300 commented 2 years ago

hi Hi there, I also have a curtain switch and I also lack the cluster to calibrate

I have ha run on a PI3 and have downloaded the image from the HA page

but now I don't know how can I install the zha-device-handler or is it already installed? - I can't find a directory ...

{ "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": "0x0202", "in_clusters": [ "0x0000", "0x0003", "0x0004", "0x0005", "0x0102" ], "out_clusters": [] } }, "manufacturer": "_TZ3000_iaxvag8w", "model": "TS130F", "class": "zigpy.device.Device" }

this is the signature of my curtain switch

what do i have to do so that i have the cluster F001 available?

thank you for your help best regards harald

dmulcahey commented 2 years ago

Is this issue still valid?

martin3000 commented 2 years ago

If I retrieve the "calibration" attribute, I get "None". If I set it to 0 or 1, I also get "None". So it seems that it is not possible to access the calibration attribute 0xf001 But I can retrieve and set the "calibration_time". And if I understand the device correctly, all the calibration is only about that time constant. When closing, the motor is switched on for that time/10, when opening, the same happens.

MattWestb commented 2 years ago

@martin3000 I think the tuya implementation is having 2 methods of calibrating the device. One with counting how much the motor is turning and one with use time. I think (=not knowing) that device have only implemented one of the 2 method and if you device is working with calibrating time the normal is not working and the other way for other device.

txelut commented 2 years ago

Hello, and thanks everybody for the contribution on this topic. I was able to install the quirk and to calibrate the device, but in my case, it seems that the motor is a bit faster moving down than moving up. I guess the calibration is taking care of that, but if I move it up and down several times, there is a remaining distance that increases little by little before reaching the upper position, additionally, when moving down the distance is exceeded. Do you know how could I fine tune the calibration? Do you recommend any other curtain device that allow us to calibrate both times up and down by default? I am checking one sample of TS130F before buying the rest for my home, so I am on time to choose another faster "plug-and-play" option.

Thanks,

Àngel

BrixSat commented 1 year ago

thank you so much

jasimancas commented 1 year ago

I have a problem with this device, I do not know if it also happens to you, I have it calibrated, and it works correctly sometimes, but for example if I tell Google to open at 50%, it opens it, it stops but nevertheless in the HA interface it still appears to me that it continues to rise, I have to press manual STOP so that it appears open at 50%, does it also happen to you?

BrixSat commented 1 year ago

I have not tested with google yet, that is to be done when possible. But i got mine perfectly working and calibrated.

jasimancas commented 1 year ago

I have not tested with google yet, that is to be done when possible. But i got mine perfectly working and calibrated.

Can you tell me the firmware version you have installed on the module?

Tschuuuls commented 1 year ago

I have not tested with google yet, that is to be done when possible. But i got mine perfectly working and calibrated.

Can you tell me the firmware version you have installed on the module?

I would also appreciate the firmware version, as I would like to buy some zigbee blind actors and they all seem to use the same tuya module which has this weird flaw that it doesn't compensate for longer opening times as opposed to closing, therefore not opening all the way. Not looking forward to waiting weeks for them to ship, just to find out they don't work correctly :D

darmach commented 1 year ago

Hello, and thanks everybody for the contribution on this topic. I was able to install the quirk and to calibrate the device, but in my case, it seems that the motor is a bit faster moving down than moving up. I guess the calibration is taking care of that, but if I move it up and down several times, there is a remaining distance that increases little by little before reaching the upper position, additionally, when moving down the distance is exceeded. Do you know how could I fine tune the calibration? Do you recommend any other curtain device that allow us to calibrate both times up and down by default? I am checking one sample of TS130F before buying the rest for my home, so I am on time to choose another faster "plug-and-play" option.

Thanks,

Àngel

This drives me mad aswell, there are few interesting parameters in ToyaCoveringCluster - did you give any of them a try?

martin3000 commented 1 year ago

I cannot set acceleration_time_lift or velocity_lift. They seem to be read only. Maybe this was planned and never implemented.

Braintelligence commented 1 year ago

I'm using a Nous L12Z Curtain Module. It shows up as TS130F in ZHA, so I guess it is a duplicate model.

I don't see a way to calibrate it in the cluster settings. Any idea what I could try to make it work?

This is the 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.FullFunctionDevice|MainsPowered|RxOnWhenIdle|AllocateAddress: 142>, manufacturer_code=4417, maximum_buffer_size=66, maximum_incoming_transfer_size=66, server_mask=10752, maximum_outgoing_transfer_size=66, 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": "0x0202",
      "input_clusters": [
        "0x0000",
        "0x0003",
        "0x0004",
        "0x0005",
        "0x0102"
      ],
      "output_clusters": [
        "0x0019"
      ]
    }
  },
  "manufacturer": "_TZ3000_jwv3cwak",
  "model": "TS130F",
  "class": "zigpy.device.Device"
}

I see the following in debug:

2023-06-16 11:54:50.696 INFO (MainThread) [zigpy.device] [0x7a7e] Read model 'TS130F' and manufacturer '_TZ3000_jwv3cwak' from <Endpoint id=1 in=[basic:0x0000, identify:0x0003, groups:0x0004, scenes:0x0005, window_covering:0x0102] out=[ota:0x0019] status=<Status.ZDO_INIT: 1>>
2023-06-16 11:54:50.696 INFO (MainThread) [zigpy.device] [0x7a7e] Discovered basic device information for <Device model='TS130F' manuf='_TZ3000_jwv3cwak' nwk=0x7A7E ieee=a4:c1:38:cd:a6:8b:5c:64 is_initialized=True>
2023-06-16 11:54:50.696 DEBUG (MainThread) [zigpy.application] Device is initialized <Device model='TS130F' manuf='_TZ3000_jwv3cwak' nwk=0x7A7E ieee=a4:c1:38:cd:a6:8b:5c:64 is_initialized=True>
2023-06-16 11:54:50.696 DEBUG (MainThread) [zigpy.quirks.registry] Checking quirks for _TZ3000_jwv3cwak TS130F (a4:c1:38:cd:a6:8b:5c:64)
2023-06-16 11:54:50.696 DEBUG (MainThread) [zigpy.quirks.registry] Considering <class 'zhaquirks.tuya.ts130f.TuyaTS130ESTC'>
2023-06-16 11:54:50.697 DEBUG (MainThread) [zigpy.quirks.registry] Fail because endpoint list mismatch: {1, 242} {1}
2023-06-16 11:54:50.697 DEBUG (MainThread) [zigpy.quirks.registry] Considering <class 'zhaquirks.tuya.ts130f.TuyaTS130Double_GP'>
2023-06-16 11:54:50.697 DEBUG (MainThread) [zigpy.quirks.registry] Fail because endpoint list mismatch: {1, 2, 242} {1}
2023-06-16 11:54:50.697 DEBUG (MainThread) [zigpy.quirks.registry] Considering <class 'zhaquirks.tuya.ts130f.TuyaTS130GP'>
2023-06-16 11:54:50.697 DEBUG (MainThread) [zigpy.quirks.registry] Fail because endpoint list mismatch: {1, 242} {1}
2023-06-16 11:54:50.697 DEBUG (MainThread) [zigpy.quirks.registry] Considering <class 'zhaquirks.tuya.ts130f.TuyaTS130FTO'>
2023-06-16 11:54:50.697 DEBUG (MainThread) [zigpy.quirks.registry] Fail because input cluster mismatch on at least one endpoint
2023-06-16 11:54:50.697 DEBUG (MainThread) [zigpy.quirks.registry] Considering <class 'zhaquirks.tuya.ts130f.TuyaTS130FTI2'>
2023-06-16 11:54:50.697 DEBUG (MainThread) [zigpy.quirks.registry] Fail because device_type mismatch on at least one endpoint
2023-06-16 11:54:50.697 DEBUG (MainThread) [zigpy.quirks.registry] Considering <class 'zhaquirks.tuya.ts130f.TuyaTS130FTOGP'>
2023-06-16 11:54:50.697 DEBUG (MainThread) [zigpy.quirks.registry] Fail because endpoint list mismatch: {1, 242} {1}
2023-06-16 11:54:50.697 DEBUG (MainThread) [zigpy.quirks.registry] Considering <class 'zhaquirks.tuya.ts130f.TuyaZemismartTS130F'>
2023-06-16 11:54:50.697 DEBUG (MainThread) [zigpy.quirks.registry] Fail because input cluster mismatch on at least one endpoint
2023-06-16 11:54:50.698 DEBUG (MainThread) [zigpy.quirks.registry] Considering <class 'zhaquirks.tuya.ts130f.TuyaTS130FTI'>
2023-06-16 11:54:50.698 DEBUG (MainThread) [zigpy.quirks.registry] Fail because input cluster mismatch on at least one endpoint

All help appreciated!

etienn01 commented 1 year ago

@Braintelligence The Nous L12Z (_TZ3000_jwv3cwak) seems to work (got the TuyaCoveringCluster and was able to calibrate) with the following custom quirk:

class TuyaNousTS130F(CustomDevice):
    """Tuya Nous smart curtain roller shutter."""

    signature = {
        MODEL: "TS130F",
        ENDPOINTS: {
            1: {
                PROFILE_ID: zha.PROFILE_ID,
                DEVICE_TYPE: zha.DeviceType.WINDOW_COVERING_DEVICE,
                INPUT_CLUSTERS: [
                    Basic.cluster_id,
                    Identify.cluster_id,
                    Groups.cluster_id,
                    Scenes.cluster_id,
                    WindowCovering.cluster_id,
                ],
                OUTPUT_CLUSTERS: [Ota.cluster_id],
            },
        },
    }
    replacement = {
        ENDPOINTS: {
            1: {
                PROFILE_ID: zha.PROFILE_ID,
                DEVICE_TYPE: zha.DeviceType.WINDOW_COVERING_DEVICE,
                INPUT_CLUSTERS: [
                    Basic.cluster_id,
                    Identify.cluster_id,
                    Groups.cluster_id,
                    Scenes.cluster_id,
                    TuyaCoveringCluster,
                ],
                OUTPUT_CLUSTERS: [Ota.cluster_id],
            },
        },
    }
Braintelligence commented 1 year ago

That sounds awesome. Will try it out later. Do you think it might be included in a future update?

Braintelligence commented 1 year ago

Thanks @etienn01 Everything works.

Here is my minimal working custom quirk script for reference if anyone wants to set it up as well:

"""Device handler for loratap TS130F smart curtain switch."""
from zigpy.profiles import zha#, zgp
from zigpy.quirks import CustomCluster, CustomDevice
import zigpy.types as t
from zigpy.zcl.clusters.closures import WindowCovering
from zigpy.zcl.clusters.general import (
    Basic,
    GreenPowerProxy,
    Groups,
    OnOff,
    Ota,
    Scenes,
    Time,
    Identify,
)

from zhaquirks.const import (
    DEVICE_TYPE,
    ENDPOINTS,
    INPUT_CLUSTERS,
    MODEL,
    OUTPUT_CLUSTERS,
    PROFILE_ID,
)
from zhaquirks.tuya import SwitchBackLight, TuyaZBExternalSwitchTypeCluster

ATTR_CURRENT_POSITION_LIFT_PERCENTAGE = 0x0008
CMD_GO_TO_LIFT_PERCENTAGE = 0x0005

class MotorMode(t.enum8):
    """Tuya motor mode enum."""

    STRONG_MOTOR = 0x00
    WEAK_MOTOR = 0x01

class TuyaCoveringCluster(CustomCluster, WindowCovering):
    """TuyaSmartCurtainWindowCoveringCluster: Allow to setup Window covering tuya devices."""

    attributes = WindowCovering.attributes.copy()
    attributes.update({0x8000: ("motor_mode", MotorMode)})
    attributes.update({0xF000: ("tuya_moving_state", t.enum8)})
    attributes.update({0xF001: ("calibration", t.enum8)})
    attributes.update({0xF002: ("motor_reversal", t.enum8)})
    attributes.update({0xF003: ("calibration_time", t.uint16_t)})

    def _update_attribute(self, attrid, value):
        if attrid == ATTR_CURRENT_POSITION_LIFT_PERCENTAGE:
            # Invert the percentage value (cf https://github.com/dresden-elektronik/deconz-rest-plugin/issues/3757)
            value = 100 - value
        super()._update_attribute(attrid, value)

    async def command(
        self, command_id, *args, manufacturer=None, expect_reply=True, tsn=None
    ):
        """Override default command to invert percent lift value."""
        if command_id == CMD_GO_TO_LIFT_PERCENTAGE:
            percent = args[0]
            # Invert the percentage value (cf https://github.com/dresden-elektronik/deconz-rest-plugin/issues/3757)
            percent = 100 - percent
            v = (percent,)
            return await super().command(command_id, *v)
        return await super().command(
            command_id,
            *args,
            manufacturer=manufacturer,
            expect_reply=expect_reply,
            tsn=tsn
        )

class TuyaNousTS130F(CustomDevice):
    """Tuya Nous smart curtain roller shutter."""

    signature = {
        MODEL: "TS130F",
        ENDPOINTS: {
            1: {
                PROFILE_ID: zha.PROFILE_ID,
                DEVICE_TYPE: zha.DeviceType.WINDOW_COVERING_DEVICE,
                INPUT_CLUSTERS: [
                    Basic.cluster_id,
                    Identify.cluster_id,
                    Groups.cluster_id,
                    Scenes.cluster_id,
                    WindowCovering.cluster_id,
                ],
                OUTPUT_CLUSTERS: [Ota.cluster_id],
            },
        },
    }
    replacement = {
        ENDPOINTS: {
            1: {
                PROFILE_ID: zha.PROFILE_ID,
                DEVICE_TYPE: zha.DeviceType.WINDOW_COVERING_DEVICE,
                INPUT_CLUSTERS: [
                    Basic.cluster_id,
                    Identify.cluster_id,
                    Groups.cluster_id,
                    Scenes.cluster_id,
                    TuyaCoveringCluster,
                ],
                OUTPUT_CLUSTERS: [Ota.cluster_id],
            },
        },
    }

I hope this might find its way into the base code soon as well. The Nous L12Z seems to be the cheapest zigbee curtain module I could find in my country.

nilsharm commented 1 year ago

I am trying to calibrate the Nous L12Z. Using the custom quirk script I was able to access the TuyaCoveringCluster for the first time. I am also able to read the calibration time. However, it seems to be a read only value. How can the calibration be accomplished?

In addition, some attribute values seem odd, e.g. calibration. I would expect a 1 or 0.

image

Braintelligence commented 1 year ago

@nilsharm ignore calibration, you need to set calibration time.

Works just fine for me.

nilsharm commented 1 year ago

@Braintelligence thanks for replying so quickly. The error sits in front of the screen. I tried to set the new value in 'Manufacteurer Code Override' instead of using the line above. That was too simple.

darmach commented 1 year ago

Does it work for you? It used to work for me but looks like calibration_time does not change afterwards.

Braintelligence commented 1 year ago

Works flawlessly

nilsharm commented 1 year ago

Works flawlessly, just do not make the same mistake I did and use the first line to override the value. Anything in the second line will not change anything. image

darmach commented 1 year ago

@nilsharm @Braintelligence I meant calibration (0/1) not calibration_time.

I have one controller on which it used to work, installed 3 new and calibration does not activate on any of them after setting calibration to 0.

Braintelligence commented 1 year ago

@nilsharm @Braintelligence I meant calibration (0/1) not calibration_time.

I have one controller on which it used to work, installed 3 new and calibration does not activate on any of them after setting calibration to 0.

No one said to use calibration. I even explicitly told to ignore it. Use calibration_time.