-
Notifications
You must be signed in to change notification settings - Fork 738
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 Inovelli VZM36 support and rework manufacturer clusters #2960
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## dev #2960 +/- ##
==========================================
+ Coverage 87.68% 87.72% +0.04%
==========================================
Files 297 298 +1
Lines 9084 9119 +35
==========================================
+ Hits 7965 8000 +35
Misses 1119 1119 ☔ View full report in Codecov by Sentry. |
zhaquirks/inovelli/__init__.py
Outdated
cluster_id = 0xFC31 | ||
name = "InovelliVZM31SNCluster" | ||
ep_attribute = "inovelli_vzm31sn_cluster" | ||
class Inovelli_Cluster(CustomCluster): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's preferred to use "CamelCase" / "CapWords" for class names.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From what I can see, cluster_id
and ep_attribute
is the same for all Inovelli cluster classes.
Can we just put it in this base class then?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Re the class name, are you saying the preference would be to do "InovelliCluster" as opposed to "Inovelli_Cluster"? This was staying consistent to the existing naming, but can definitely change it if needed. Just have to change it in the device-specific imports as well.
Putting cluster_id and ep_attribute in the base class is giving async_initialize errors...it all appears to work, but putting them across each cluster resolved that and is why I ended up splitting them out.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
saying the preference would be to do "InovelliCluster" as opposed to "Inovelli_Cluster"?
Yes. That's preferred.
Putting cluster_id and ep_attribute in the base class is giving async_initialize errors...it all appears to work, but putting them across each cluster resolved that and is why I ended up splitting them out.
Weird. There shouldn't be any difference. Are you sure it wasn't just some connectivity issue?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updating all the classes, thanks for the clarification!
And yeah agreed it's weird, just re-tested. In 2024.2.0 it no longer shows up as a warning, but it's still in the logs -
2024-02-09 08:05:45.026 DEBUG (MainThread) [homeassistant.components.zha.core.cluster_handlers] [0x90CF:1:0xfc31]: failed to get attributes '['power_type', 'switch_type', 'button_delay', 'smart_bulb_mode', 'local_protection']' on 'inovelli_vzm31sn_cluster' cluster:
2024-02-09 08:05:45.027 DEBUG (MainThread) [homeassistant.components.zha.core.cluster_handlers] [0x90CF:1:0x0019]: initializing cluster handler: from_cache: False
2024-02-09 08:05:45.027 DEBUG (MainThread) [homeassistant.components.zha.core.cluster_handlers] [0x90CF:1:0x0019]: initializing cached cluster handler attributes: ['current_file_version']
2024-02-09 08:05:45.027 DEBUG (MainThread) [homeassistant.components.zha.core.cluster_handlers] [0x90CF:1:0x0019]: Reading attributes in chunks: ['current_file_version']
2024-02-09 08:05:45.027 DEBUG (MainThread) [homeassistant.components.zha.core.cluster_handlers] [0x90CF:1:0x0019]: finished cluster handler initialization
2024-02-09 08:05:45.082 DEBUG (MainThread) [homeassistant.components.zha.core.cluster_handlers] [0x90CF:1:0x0006]: 'async_initialize' stage succeeded
2024-02-09 08:05:45.082 DEBUG (MainThread) [homeassistant.components.zha.core.cluster_handlers] [0x90CF:1:0x0008]: 'async_initialize' stage succeeded
2024-02-09 08:05:45.082 DEBUG (MainThread) [homeassistant.components.zha.core.cluster_handlers] [0x90CF:1:0x0000]: 'async_initialize' stage succeeded
2024-02-09 08:05:45.082 DEBUG (MainThread) [homeassistant.components.zha.core.cluster_handlers] [0x90CF:1:0x0b04]: 'async_initialize' stage succeeded
2024-02-09 08:05:45.082 DEBUG (MainThread) [homeassistant.components.zha.core.cluster_handlers] [0x90CF:1:0x0003]: 'async_initialize' stage succeeded
2024-02-09 08:05:45.083 DEBUG (MainThread) [homeassistant.components.zha.core.cluster_handlers] [0x90CF:1:0x0702]: 'async_initialize' stage succeeded
2024-02-09 08:05:45.083 DEBUG (MainThread) [homeassistant.components.zha.core.cluster_handlers] [0x90CF:1:0x0019]: 'async_initialize' stage succeeded
2024-02-09 08:05:45.083 DEBUG (MainThread) [homeassistant.components.zha.core.cluster_handlers] [0x90CF:1:0xfc31]: 'async_initialize' stage failed:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The log level was changed indeed. Are there more (debug) log messages when zigpy
is also set to debug level?
There's no reason I can see why this could happen. Setting cluster_id
, name
, and ep_attribute
in the "base class" vs the one inheriting that doesn't make a difference.
Can you double-confirm that the error happens every time? And not every time when set in the base classes?
Also, did you check that all attributes set here are correct?
https://github.com/home-assistant/core/blob/567a179084e0226a45d1db01ffb5d4e2e37f3d8c/homeassistant/components/zha/core/cluster_handlers/manufacturerspecific.py#L249-L253
(There might be more info in zigpy debug logs)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've had both zigpy and zhaquirks set to debug while trying to figure out what's going on and haven't seen anything relevant from zigpy unfortunately. Confirmed I end up with at least one Inovelli device giving that error every time. It's not all of them, and the devices do still seem to work, but I do get at least one log message in 100% of my tests but I don't when I have them set as in the current PR state. I'm not certain why that is because I'd expect it to be the same.
I did also double check the attributes, those all check out, I do find it interesting that the attributes that error are split between the base and one inheriting, but not sure if that's relevant?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Possibly related comment: #2960 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated to that and was still getting them, however when flipping back to how the PR is currently, I also replicated it once...so I'm just going to chalk it up to my network? Not entirely sure what's causing it, but if it happens in both scenarios it's likely unrelated. I'll move these to the base class and thanks for the ideas in trying to narrow it down.
name = "InovelliVZM31SNCluster" | ||
ep_attribute = "inovelli_vzm31sn_cluster" | ||
class Inovelli_Cluster(CustomCluster): | ||
"""Inovelli base cluster.""" | ||
|
||
attributes = { | ||
0x0001: ("dimming_speed_up_remote", t.uint8_t, True), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not for this PR, but we need to switch to the new zigpy AttributeDefs
style at some point.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, no need to do it in this PR already, but saving a code sample here for reference how it would look:
zha-device-handlers/zhaquirks/legrand/cable_outlet.py
Lines 42 to 59 in ab0d248
class LegrandCluster(CustomCluster): | |
"""LegrandCluster.""" | |
cluster_id = MANUFACTURER_SPECIFIC_CLUSTER_ID | |
name = "LegrandCluster" | |
ep_attribute = "legrand_cluster" | |
class AttributeDefs(BaseAttributeDefs): | |
device_mode = ZCLAttributeDef( | |
id=0x0000, | |
type=t.data16, # DeviceMode | |
is_manufacturer_specific=True, | |
) | |
led_dark = ZCLAttributeDef( | |
id=0x0001, | |
type=t.Bool, | |
is_manufacturer_specific=True, | |
) |
zhaquirks/inovelli/__init__.py
Outdated
attributes = { | ||
key: InovelliCluster.attributes[key] for key in InovelliCluster.attributes | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you use:
attributes = InovelliCluster.attributes.copy()
Please also test if you still have the initialization error then.
... although there shouldn't be a difference I think. But still, use the .copy()
one now that attributes no longer need to removed, as it's what we're using "everywhere" already.
zhaquirks/inovelli/__init__.py
Outdated
name = "InovelliVZM31SNCluster" | ||
|
||
attributes = InovelliCluster.attributes.copy() | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you also remove this empty line between attributes = ...
and attributes.update(...
everywhere?
(To follow what other quirks do)
zhaquirks/inovelli/__init__.py
Outdated
AUX_ON = "Aux Up" | ||
AUX_OFF = "Aux Down" | ||
AUX_CONFIG = "Aux Config" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think these should follow HA standards and be "Aux up", "Aux down", "Aux config"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks!
Proposed change
This change adds support for the Inovelli VZM36 canopy module and re-organizes the __init__.py file to simplify the parameters across devices.
Additional information
I believe the ep_attribute has to stay pointed to the inovelli_vzm31sn_cluster as that's what's referenced within ZHA so changing that would result in a breaking change. In the interest of avoiding that, I've kept it in place.
Checklist
pre-commit
checks pass / the code has been formatted using Black