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
71.81k stars 30.07k forks source link

ZHA Tuya attribute missing in TS130F curtain module #46146

Closed FaBRiK74 closed 10 months 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
bekon16 commented 3 years ago

Hi, It would be nice to have this integration in ZHA (because of installation HA core without supervisor i can't event switch on mqtt). Is it possible to add it in future? Thanks in advance.

silversmarty commented 3 years ago

Same thing here, not possible to make any calibration without this feature implemented :-(

manueljortega commented 3 years ago

Same here. The modul is unusefull if cannot be calibrated.

JoeyGnarf commented 3 years ago

Same here, looking forward to updates!

ViperRNMC commented 3 years ago

Same issue here, without calibration I don't know were my cover position is.

moritan commented 3 years ago

If i understand the quirks documentation, we need to modify this file : https://github.com/zigpy/zha-device-handlers/blob/dev/zhaquirks/tuya/ts130f.py

i try to edit the line 71 to add ("_TZ3000_vd43bbfq", "TS130F"), but the quirks don't look like to be used.

any idea how to check if quirks are used ?

MattWestb commented 3 years ago

All information in the signature = section must matching or the quirk is not being triggered. If you is having one identical device with all parameters is the same and only the device MODELS_INFO: is different its only adding one more line.

On the device card and the last line of the device info you is getting the quirk is one is loaded or not: Quirk: zhaquirks.ikea.fivebtnremotezha.IkeaTradfriRemote or its no quirk line if o match is made.

moritan commented 3 years ago

You were right, it was the signature. After fixing the signature, the quirk is loaded. I will give more infos tomorrow after more tests. It's too late to play with the calibration of covers tonight.

image

MattWestb commented 3 years ago

If you is getting it working with adding the model id to the signature and its working OK pleas do one PR for adding it in the quirk so other user can using there device 2 :-))

I can being that you need splitting the line to one record / line like this (example from valve.py):

        MODELS_INFO: [
            ("_TYST11_jeaxp72v", "eaxp72v"),
            ("_TYST11_kfvq6avy", "fvq6avy"),
            ("_TYST11_zivfvd7h", "ivfvd7h"),
        ],
ViperRNMC commented 3 years ago

You were right, it was the signature. After fixing the signature, the quirk is loaded. I will give more infos tomorrow after more tests. It's too late to play with the calibration of covers tonight.

image

any news? how did you make the change?

MattWestb commented 3 years ago

For testing quirks look in the wiki how to using / editing local quirks https://github.com/zigpy/zha-device-handlers/discussions/693#discussioncomment-857274.

Its looks like @moritan was using this quirk https://github.com/home-assistant/core/issues/46146#issuecomment-867137565 and fixing the signature and it was working for him.

moritan commented 3 years ago

Sorry, i didn't have time to give news. So yes it's works with the modification i made ( I just modify the the signature). But of course it's break compatibility for other model.

And according to this one (https://github.com/zigpy/zha-device-handlers/pull/902), there is 4 differents type of model;

I will try to confirm it later( because i don't test this version) but this file should be ok =>https://github.com/zigpy/zha-device-handlers/pull/943

ViperRNMC commented 3 years ago

can't get this working, did add to config:

zha:
  custom_quirks_path: /config/custom_zha_quirks/

Add file /config/custom_zha_quirks/tuya/ts130f.py with your adjustment, but when I restart has I don't get the calibration option

my signature is:


  "node_descriptor": "NodeDescriptor(byte1=1, byte2=64, mac_capability_flags=142, manufacturer_code=4098, maximum_buffer_size=82, maximum_incoming_transfer_size=82, server_mask=11264, maximum_outgoing_transfer_size=82, descriptor_capability_field=0, *allocate_address=True, *complex_descriptor_available=False, *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, *is_valid=True, *logical_type=<LogicalType.Router: 1>, *user_descriptor_available=False)",
  "endpoints": {
    "1": {
      "profile_id": 260,
      "device_type": "0x0202",
      "in_clusters": [
        "0x0000",
        "0x0004",
        "0x0005",
        "0x0102"
      ],
      "out_clusters": [
        "0x000a",
        "0x0019"
      ]
    }
  },
  "manufacturer": "_TZ3000_vd43bbfq",
  "model": "TS130F",
  "class": "zigpy.device.Device"
}```
moritan commented 3 years ago

I didn't have used the "custom_quirks_path".

Based on this wiki [ here ] :

Hope this will help

moritan commented 3 years ago

i confirm the previous procedure work for me

Emile86 commented 3 years ago

You were right, it was the signature. After fixing the signature, the quirk is loaded. I will give more infos tomorrow after more tests. It's too late to play with the calibration of covers tonight.

image

I have same screen now but how can i calibrate? What do i have to send as command? Thanks

ViperRNMC commented 3 years ago

thank, I use OS 6.1 on a blue, can't find the site-packages folder.

moritan commented 3 years ago

I have same screen now but how can i calibrate? What do i have to send as command? Thanks

The good news is that all the action can be done from the same screen. The bad news ? No bad news.

So :

It's done.

moritan commented 3 years ago

thank, I use OS 6.1 on a blue, can't find the site-packages folder.

Sorry but what is a blue ?

MattWestb commented 3 years ago

@ViperRNMC in you configure folder its in the deps folder (If they is being installed or its dont have it) but i dont knowing how to accessing it in OS. In supeerviced i can accessing it with installing the file editor add on that is starting in the config directory.

MattWestb commented 3 years ago

@moritan https://www.home-assistant.io/blue/

moritan commented 3 years ago

it looks like it's a standard installation, so you should be able to ssh in the system and open a docker bash console.

ViperRNMC commented 3 years ago

@ViperRNMC in you configure folder its in the deps folder (If they is being installed or its dont have it) but i dont knowing how to accessing it in OS. In supeerviced i can accessing it with installing the file editor add on that is starting in the config directory.

found it, but...

OS 6.1 has Python 3.7.3 and I found in de folder deps after install zha-quirks package

/config/deps/lib/python3.8/site-packages/zhaquirks/ and no folder Tuya

MattWestb commented 3 years ago

Then you is in the OS (rasbian or woth they is running on the blue have older python then the HA container). If you have portainer installed then is the homeassiistant container you shall open the CLI in. Containers is virtual so they can having complete different things installed also different versions of files then the OS or other containers.

michaelbeyhs commented 3 years ago

Just wanted to confirm that the modified quirk works for me too. I was able to calibrate my QS-Zigbee-C01 Curtain module that shows up as "TS130F by _TZ3000_vd43bbfq" using the quirk and the above instructions.

MattWestb commented 3 years ago

From the linked guide:

Access the quirks directory on HA > 0.113: /usr/local/lib/python3.8/site-packages/zhaquirks/ on HA < 0.113: /usr/local/lib/python3.7/site-packages/zhaquirks/

so all current HA is running python 3.8.

From Portainer you is having home the assistant container like this (the spelling of home assistant can being different): HAPORT Click on the >_ and you is getting: HAPORTC Then click on connect and you shall having one bash terminal in the HA container.

And the path to ZHAQuirks is working: HAPORTD

Emile86 commented 3 years ago

I have same screen now but how can i calibrate? What do i have to send as command? Thanks

The good news is that all the action can be done from the same screen. The bad news ? No bad news.

So :

  • Open the clusters window
  • Select "TuyaCoveringCluster (Endpoint id: 1, Id: 0x0102, Type: in)"
  • Launch the "down_close (id: 0x0001)" command
  • Once closed launch the "stop (id: 0x0002)" command
  • Activate calibration mode by setting "0" to the zigbee attribute
  • Launch the "up_open (id: 0x0000)" command
  • Once opened, launch the "stop (id: 0x0002)" command
  • Launch the "down_close (id: 0x0001)" command
  • Once closed launch the "stop (id: 0x0002)" command
  • desactivate calibration mode by setting "1" to the zigbee attribute

It's done.

Thank you! I will try it today

jrochate commented 3 years ago

Hi. I was able to get calibration (id: 0xf001) on the cluster atributes, using the quirck file.

But now I can't set a value for the calibration. I fill the Value text box and also Manufacturer Code Override with the 0 value, but the window cover stops after 10 seconds.

if I press Get Zigbee Attribute on the cluster attribute I always get "None" no Mather what SET I make. Do you have any tips?

thanks.

jrochate commented 3 years ago

BTW: I had to configure a diferent DEVICE_TYPE since the MOES window roller shutter had this:

# SizePrefixedSimpleDescriptor(endpoint=1, profile=260, device_type=515, device_version=1, input_clusters=[0, 4, 5, 258, 6], output_clusters=[25, 10])

DEVICE_TYPE: zha.DeviceType.WINDOW_COVERING_CONTROLLER,

This is 0x0203 and not 0x0202 like the WINDOW_COVERING_DEVICE on the original quirk.

MattWestb commented 3 years ago

One controller is on remote and one device is the receiver with the motor for driving the coverings.

manueljortega commented 3 years ago

the updated quirk is working properly. Now I can calibrate the device. Thank you very much for your help!!

MattWestb commented 3 years ago

Can some one that have getting it working making one PR in https://github.com/zigpy/zha-device-handlers so other user can using it without "hacking" there systems after every HA update ??

moritan commented 3 years ago

The PR is done and merge. https://github.com/zigpy/zha-device-handlers/pull/943

Now, we just need to wait integration in a next release

MattWestb commented 3 years ago

Thanks very much one more tuya device in place :-)))

int3ring0 commented 3 years ago

Worked me ! Great thanks.

Any change to get calibration mode as switch in lovelace?

franderlink commented 3 years ago

You were right, it was the signature. After fixing the signature, the quirk is loaded. I will give more infos tomorrow after more tests. It's too late to play with the calibration of covers tonight.

image

Hi, I have the same problem, you can show your file. to see how it looks. I change one of the devices for the signature of mine and nothing works. my signature is the same model but something different from yours " _TZ3000_1dd0d5yi"

MattWestb commented 3 years ago

@franderlink I was looking for your device ID but is no commits with it so i dont know witch version its is.

You can look in https://github.com/zigpy/zha-device-handlers/pull/943 how the other devices is added and trying adding your device IDs signature on one type and and see is its loading (then you is getting the quirk name on the device card ZHA is using) and if it not loading trying the next type. Between you shall deleting the __pycache__ and restarting HA.

franderlink commented 3 years ago

@franderlink I was looking for your device ID but is no commits with it so i dont know witch version its is.

You can look in zigpy/zha-device-handlers#943 how the other devices is added and trying adding your device IDs signature on one type and and see is its loading (then you is getting the quirk name on the device card ZHA is using) and if it not loading trying the next type. Between you shall deleting the __pycache__ and restarting HA.

It doesn't work, I don't know what it does. since home assistant connects but does not enter the calibration

image

MattWestb commented 3 years ago

@franderlink Your device " _TZ3000_1dd0d5yi" is not supported then no user have posted one device signature so its not possible finding the right quirk for the devs for adding it.

Pleas post the signature of your device.

franderlink commented 3 years ago

@MattWestb
This is the signature of my device

`{

"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.0: 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" }`

MattWestb commented 3 years ago

Its one TuyaZemismartTS130F type and can being added but i waiting the devs saying yes or no to using generic model TS130F and if its OK its working then its being merged or if they dont like it i putting your device ID in the right place.

If you like adding it here: https://github.com/zigpy/zha-device-handlers/blob/21af0860992021c39b26260b6e2ae4f9c1af75d1/zhaquirks/tuya/ts130f.py#L116

you can deleting the "old" ID if you dont have that device and adding your new one and it shall working.

jrochate commented 3 years ago

The device 0x0203 using _TZ3000_1dd0d5yi does NOT have 0xf001 (calibration) available as a function on it. When you set a command on that attribut, the log shows "not available"

Until now there is no known cluster atribute to calibrate it.

I think the only way to find it is using Tuya App and a zigbee sniffer to understand what comands does the App send to device when calibrating.

MattWestb commented 3 years ago

@jrochate wot is the name of the quirk the ZHA have loaded for you device 0x0203 ?

And if you can only making the curtain moving for some seconds with your remote i think you is having one defect device then its also not working in de(C)CCONZ or the model have not implanting the calibration function.

jrochate commented 3 years ago

I'm using my own quirk since 0x0203 wasn't in any public quick.

Here it goes

This device can only up/down the curtain for MAX 10 seconds, from 1 to 100 percent. The device is fine, as you see from the report of @franderlink above. And there is more reports on the net that this _1dd0d5yi does not accept 0xf001 (calibration).

The device can up / down more than 10 seconds if used by a physical button or by the Tuya App. I have more 3 devices like this and they all work this way.

We must reverse engineer the working model of this device in order to see how the App can calibrate.

jrochate commented 3 years ago

Check this out:

https://github.com/dresden-elektronik/deconz-rest-plugin/issues/3134

MattWestb commented 3 years ago

One hint with tuya devices that is doing strange things disabling the time cluster in the quirk looks being one of the best ways getting then "behaving".

Sorry de(F)CONZ is dead form my part after they is treating most of there payed user so badly so i cant helping you with that.

jrochate commented 3 years ago

I'm not using deCONZ also, but using ZHA. The link is to access a chain of similar reports using these Tuya devices. Maybe we can get a hint reading all that info in order to get a solution for a quirk of a cluster command.

MattWestb commented 3 years ago

I think the best is sniffing how tuya GW is handling it but then you need one tuya ZBGW and one sniffer device. I cant recommending IT CC-2531 then its too limit better with one Nordic or one EZSP device with NCP firmware loaded (its the normal coordinator firmware and its working with all version of it). One nice device is tuya / LIDL ZBGW that also is working for sniffing if hacking the device OS for installing the serial server to ZHA but then you cant using it for searing your device that you like to sniffing or you need 2 of them :-))

jrochate commented 3 years ago

Yep. At the moment I already got a ZBGW hacked, that I used with ZHA and ir worked fine. So, I will need to buy another one (since this has the firmware changed). Ordering it now... Another option is to use the ConBee II and there are some info about using it to sniff.

I will keep you posted if I advance in this quest :) Too much effort for inexpensive devices, but it's fun.

MattWestb commented 3 years ago

I think Rasp/CornBee sniffing is broke or at least using it as one router is broken but its not so easy finding out then its not so well documented.

Im using IKEA modules (aka Billy EZSP) and one LIDL / tuya LED Stripe controller for sniffing and as coordinator and it working great beside for one tuya and one LIDL ZBGW with EZSP 6.10.0.0.

Its possible rolling back the EZSP firmware on the tuya ZBGW and reverting the serial server but i dont knowing if tuya cloud is liking it or not and i think no user have trying it (i have only trying downgrading EZSP to 6.5.1.0 after flashing the normal 6.7.0.0 and from ZHA is working OK but i was not roiling back the tuya start so not tested with tuya cloud).