Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
127 changes: 30 additions & 97 deletions zha/application/platforms/virtual.py
Original file line number Diff line number Diff line change
Expand Up @@ -1065,7 +1065,11 @@ class InovelliClientBind(VirtualEntity):

@register_entity(INOVELLI_CLUSTER)
class InovelliVzm30Init(VirtualEntity):
"""Inovelli VZM30-SN switch attribute init."""
"""Inovelli VZM30-SN switch attribute init.

Only attributes the quirk does not already read on startup. See

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: "does not already read on startup" isn't quite right for the second group — the quirk does read button_delay / smart_bulb_mode / local_protection / output_mode on startup, just from the cache. What this class still contributes for those is the fresh read, not the read itself.

Suggest "…the quirk does not already read fresh from the device on startup", or just dropping the first sentence and leaving the pointer to InovelliVzm31Init, whose docstring states both groups precisely. Same wording on InovelliVzm35Init (line 1149).

`InovelliVzm31Init` for what still has to live here.
"""

_unique_id_suffix = "inovelli_vzm30_init"

Expand All @@ -1078,42 +1082,17 @@ class InovelliVzm30Init(VirtualEntity):
attributes={
name: AttrConfig(read_on_startup=fresh)
for name, fresh in {
"dimming_speed_up_remote": False,
"dimming_speed_up_local": False,
"ramp_rate_off_to_on_remote": False,
"ramp_rate_off_to_on_local": False,
"dimming_speed_down_remote": False,
"dimming_speed_down_local": False,
"ramp_rate_on_to_off_remote": False,
"ramp_rate_on_to_off_local": False,
"minimum_level": False,
"maximum_level": False,
"invert_switch": False,
"auto_off_timer": False,
"default_level_local": False,
"default_level_remote": False,
"state_after_power_restored": False,
"load_level_indicator_timeout": False,
# no quirk entity
"active_power_reports": False,
"periodic_power_and_energy_reports": False,
"active_energy_reports": False,
"power_type": True,
"switch_type": True,
"internal_temp_monitor": False,
"overheated": False,
# quirk entity initializes from cache, we want a fresh read
"button_delay": True,
"smart_bulb_mode": True,
"led_color_when_on": False,
"led_color_when_off": False,
"led_intensity_when_on": False,
"led_intensity_when_off": False,
"led_scaling_mode": False,
"aux_switch_scenes": False,
"binding_off_to_on_sync_level": False,
"local_protection": True,
"output_mode": True,
"firmware_progress_led": False,
"disable_clear_notifications_double_tap": False,
}.items()
},
),
Expand All @@ -1122,7 +1101,16 @@ class InovelliVzm30Init(VirtualEntity):

@register_entity(INOVELLI_CLUSTER)
class InovelliVzm31Init(VirtualEntity):
"""Inovelli VZM31-SN dimmer attribute init."""
"""Inovelli VZM31-SN dimmer attribute init.

Most of what this used to read is now covered by the quirk, whose entities
each declare their own startup read (zha-quirks #5122, ported out of ZHA in
#802). Two groups still have to be read here:

- attributes with no quirk entity at all, and
- attributes whose quirk entity initializes from the cache (the
`QuirkBuilder` default) where ZHA wants a fresh read from the device.
"""

_unique_id_suffix = "inovelli_vzm31_init"

Expand All @@ -1135,52 +1123,19 @@ class InovelliVzm31Init(VirtualEntity):
attributes={
name: AttrConfig(read_on_startup=fresh)
for name, fresh in {
"dimming_speed_up_remote": False,
"dimming_speed_up_local": False,
"ramp_rate_off_to_on_remote": False,
"ramp_rate_off_to_on_local": False,
"dimming_speed_down_remote": False,
"dimming_speed_down_local": False,
"ramp_rate_on_to_off_remote": False,
"ramp_rate_on_to_off_local": False,
"minimum_level": False,
"maximum_level": False,
"invert_switch": False,
"auto_off_timer": False,
"default_level_local": False,
"default_level_remote": False,
"state_after_power_restored": False,
"load_level_indicator_timeout": False,
# no quirk entity
"active_power_reports": False,
"periodic_power_and_energy_reports": False,
"active_energy_reports": False,
"power_type": True,
"switch_type": True,
"quick_start_time": False,
"quick_start_level": False,
"increased_non_neutral_output": False,
"leading_or_trailing_edge": False,
"internal_temp_monitor": False,
"overheated": False,
"power_type": True,
# quirk entity initializes from cache, we want a fresh read

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These four are the entries most likely to be wrongly deleted by a later cleanup pass: unlike the group above, the attribute is covered by a quirk entity, so the only thing distinguishing them is a default (attribute_initialized_from_cache=True) that lives in zhaquirks/inovelli/builder.py and isn't visible from here.

That's the strongest argument for the regression test in the summary — an assertion on the merged {attr_name: read_on_startup} map for 0xFC31 is the only thing that would catch either a quirks-side change or an over-eager future deletion.

"switch_type": True,
"button_delay": True,
"smart_bulb_mode": True,
"double_tap_up_enabled": False,
"double_tap_down_enabled": False,
"double_tap_up_level": False,
"double_tap_down_level": False,
"led_color_when_on": False,
"led_color_when_off": False,
"led_intensity_when_on": False,
"led_intensity_when_off": False,
"led_scaling_mode": False,
"aux_switch_scenes": False,
"binding_off_to_on_sync_level": False,
"local_protection": True,
"output_mode": True,
"on_off_led_mode": False,
"firmware_progress_led": False,
"relay_click_in_on_off_mode": False,
"disable_clear_notifications_double_tap": False,
}.items()
},
),
Expand All @@ -1189,7 +1144,11 @@ class InovelliVzm31Init(VirtualEntity):

@register_entity(INOVELLI_CLUSTER)
class InovelliVzm35Init(VirtualEntity):
"""Inovelli VZM35-SN fan switch attribute init."""
"""Inovelli VZM35-SN fan switch attribute init.

Only attributes the quirk does not already read on startup. See
`InovelliVzm31Init` for what still has to live here.
"""

_unique_id_suffix = "inovelli_vzm35_init"

Expand All @@ -1202,43 +1161,17 @@ class InovelliVzm35Init(VirtualEntity):
attributes={
name: AttrConfig(read_on_startup=fresh)
for name, fresh in {
"dimming_speed_up_remote": False,
"dimming_speed_up_local": False,
"ramp_rate_off_to_on_local": False,
"ramp_rate_off_to_on_remote": False,
"dimming_speed_down_remote": False,
"dimming_speed_down_local": False,
"ramp_rate_on_to_off_local": False,
"ramp_rate_on_to_off_remote": False,
"minimum_level": False,
"maximum_level": False,
"invert_switch": False,
"auto_off_timer": False,
"default_level_local": False,
"default_level_remote": False,
"state_after_power_restored": False,
"load_level_indicator_timeout": False,
"power_type": True,
"switch_type": True,
# no quirk entity
"non_neutral_aux_med_gear_learn_value": False,
"non_neutral_aux_low_gear_learn_value": False,
"power_type": True,
# quirk entity initializes from cache, we want a fresh read
"switch_type": True,
"quick_start_time": True,
"button_delay": True,
"smart_fan_mode": True,
"double_tap_up_enabled": False,
"double_tap_down_enabled": False,
"double_tap_up_level": False,
"double_tap_down_level": False,
"led_color_when_on": False,
"led_color_when_off": False,
"led_intensity_when_on": False,
"led_intensity_when_off": False,
"aux_switch_scenes": False,
"local_protection": True,
"output_mode": True,
"on_off_led_mode": False,
"firmware_progress_led": False,
"smart_fan_led_display_levels": False,
}.items()
},
),
Expand Down
Loading