-
Notifications
You must be signed in to change notification settings - Fork 726
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for ZY-M100 wall mount #1928
Conversation
Pull Request Test Coverage Report for Build 3486299868
💛 - Coveralls |
Codecov ReportBase: 82.68% // Head: 82.68% // No change to project coverage 👍
Additional details and impacted files@@ Coverage Diff @@
## dev #1928 +/- ##
=======================================
Coverage 82.68% 82.68%
=======================================
Files 245 245
Lines 7647 7647
=======================================
Hits 6323 6323
Misses 1324 1324
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
I have one of these sensors with the updated manufacturer, so I can +1 this |
Quick question, it seems that this sensor is now indeed detected by ZHA under Home Assistant, but it only exposes "presence", while it should also have |
Those aren't included in the quirk |
Would it be hard to add those? I'd like to contribute to that if possible but haven't made a quirk yet and it looks a bit intimidating |
I just received this sensor and I +1 Kevin's question, I'd gladly contribute to the quirk but I have almost zero knowledge of python and I don't really understand how the quirks file works at all (and yes, I tried reading the docu, didn't help me at all). |
Hi, I been messing with the clusters in "Manage Zigbee Device". I have also found on Tasmota docs that they explain what all the different DP mappings are, here: https://templates.blakadder.com/ZY-M100.html.
When I read I also had a look at the code which implements these |
@ark- there is a docu that explains how to build a custom quirk: |
Okay, I think I begin to understand that. This line:
translates dp_x to something meaningful. For example, occupancy (dp_1) gets put into TuyaOccupancySensing which is an extension of OccupancySensing and that seems to be "automatically" translated into Occupancy entity in HA. Same for illuminance. |
Thanks, I've read that guide, it's the same as the README for this repo, but like you I found it didn't quite match the implementation in this PR. I'm glad it's not just me who thinks this is a little spaghetti (though I suspect it's because I'm looking at the end of a working day). I imagine it's an unfortunate side effect of the nature of this repo: complicated, needs to be modular and has to support lots of different systems. I also thought the mapping e.g. I also notice that my detected status sometimes gets stuck too. It will refresh if I force a cluster read on occupancy. |
Occupancy and Illuminance both work for me just fine since I connected the sensor yesterday. It's just the other settings that don't get into HA and when I tried setting them that doesn't work for me either. I assume it's because it lacks the Bus (but that would also mean it shouldn't even read them?). I'm not sure if there are any devices at all in ZHA that support some kind of settings. If yes maybe we could try to pick those quirks apart. |
Funny, I was just thinking this. I change my Tuya Siren's "tune" using the clusters UI. Here's the relevant file: https://github.com/zigpy/zha-device-handlers/blob/dev/zhaquirks/tuya/ts0601_siren.py |
I note the addition of a write_attributes() which fills out the manufacturer ID https://github.com/zigpy/zha-device-handlers/blob/dev/zhaquirks/tuya/ts0601_siren.py#LL274C5-L279C10. Maybe we need to enter that in the UI or add a similar function to the Quirk. The question is, whats the Manufacturer ID of the ZY-M100. Edit: Oh that just resolves to It might be that the dp_to_attribute part has a type 7: DPToAttributeMapping(
TuyaMCUSiren.ep_attribute,
"alarm_duration",
dp_type=TuyaDPType.VALUE, #<See here
), |
For me the manufacturer ID is _TZE204_ztc6ggyl but maybe the same line from the siren would work just fine? Still doesn't quite resolve the issue with the various attributes not being picked up as entities though |
The python script that creates sensors seems to be https://github.com/home-assistant/core/blob/dev/homeassistant/components/zha/sensor.py |
I understand you want the sensors to show up as entities but thats only half the problem. Until the clusters can be communicated with you wont be able to change anything anyway. Zigbee2Mqtt have the following DP mapping: https://github.com/Koenkk/zigbee-herdsman-converters/blob/master/lib/tuya.js#L834:L841. Which align to my earlier table, so I'm fairly certain I have the mapping correct. These values are converted here: https://github.com/Koenkk/zigbee-herdsman-converters/blob/master/converters/toZigbee.js#L7011:L7031. I see no reason they cant And sent here: https://github.com/Koenkk/zigbee-herdsman-converters/blob/master/lib/tuya.js#L1043 I don't see anything specific they're doing to write these values. |
Yep, understood |
Some excellent discussion here: #1645 I need to try that custom quirk for this device and see if it works. Will report back when I get a chance, could be a few days. |
So scanning the code from #1645, to propagate attributes up to Home Assistant, you need to add an additional endpoint for each one to the |
I was optimistic in my "could be a few days". I've unfortunately not had a chance and not sure when I can cast my eye over this again. |
Any idea if there will be a solution in the near future? Would be nice to get the full use out of this sensor. |
@mjdegraaff You might want to try the quirk here: #1645 |
Is that something which is easy? I'm not that experienced with these things.... Thanks for your reply btw! |
I have 2 of these and I loaded up the custom quirk. The first one works fine, the second one works, except the illuminance sensor isn’t there. Both loaded the same quirk, and have the same device info. |
@broyuken Try restarting HA then sometime is ZHA being lazy loading quirks OK the adding devices and both is matching the quirk so it shall being the same. |
yea I restarted HA and readded it and it showed up. |
I’m using _TZE204_ztc6ggyl together with the quirk @aquemy mentioned and I still have the problem, that the values cannot be set: the sliders are automatically brought back to their default value. Is there a solution for this in the meantime? |
you meed to apply the correction in #1928 (comment) Never the less you have the full code below. It worked for me:
|
When will this be available with a normal HA release, without quirks? |
@cobirnm could you test to replace the self._update_attribute(self.attributes_by_name["min_present_value"].id, 1)
self._update_attribute(self.attributes_by_name["max_present_value"].id, 9)
self._update_attribute(self.attributes_by_name["resolution"].id, 1) With expressions like this others (be carefull, I have changed the self.update_attribute("min_present_value", 1)
self.update_attribute("max_present_value", 9)
self.update_attribute("resolution", 1) All the magic would come from here: zha-device-handlers/zhaquirks/tuya/__init__.py Lines 807 to 822 in f6ab87e
|
Did this custom quirk break on 2023.3 for anyone else? |
The error I got was:
|
Yep that’s the same error I got. |
Same error as well - believe this is due to this PR in the zigpy project (TuyaDPType is now automatic?) I commented out all of the references to TuyaDPType and it began working as it did before:
|
thank you, you need to remove those tick marks on the very last line, but other than that it seems to work great! edit: actually, the illuminance sensor doesn't seem to show up with this quirk |
Edited to remove the Markdown ticks that were in an unfortunate spot 😁 |
I've rebooted after installing the quirk and removed/re-added the device a couple times now and it still doesn't show. the occupancy and controls for that all show up, but nothing about illuminance |
Got it - it was this line: Those returned numbers need to be int to be interpreted as dp_type of VALUE (see here) - so fixing like this fixes the illuminance sensor: Edited comment above to fix it |
"I commented out all of the references to TuyaDPType and it began working as it did before" |
A solution would be to merge the "custom quirk" into zha-quirks, so that custom quirks don't have to be used. |
I have your updated quirk, but am still only getting occupancy sensor, no illuminance |
Anything else we can try to get these entities back? |
@broyuken |
its the one in this issue. And the quirk was working perfectly until 2023.3 and the tuyaDP issue. Thats why I was bringing it back up here. But sure, I'll create a new issue |
ok strangely enough I just re-added it for about the 10th time after about the same HA reboots and now the sensor is there, who knows...I did update to 2023.3.1 this morning but outside of that I didn't do anything else different. Regardless, it's there now, I'm happy. |
This is a PR and not an issue. That's the reason I was asking to move this to an issue. So in order to finally get this device properly supported without any custom quirks, can you:
That way, we can properly track this and finally support it correctly. Again, your custom quirk will break again. It's not a solution. |
i cant get the sensors to show, it was fine before 2023.3, how can I fix??
i cant get the sensors to show, it was fine before 2023.3, how can I fix?? |
Like mentioned before, create a new issue if you still have problems. Those sensors might not show up until movement was triggered and HA is restarted, because the attributes are not properly initialized. |
https://zigbee.blakadder.com/Tuya_ZY-M100-S.html