Skip to content

Comments

Add quirks v2 siren entity based on SwitchMetadata#667

Draft
TheJulianJES wants to merge 7 commits intozigpy:devfrom
TheJulianJES:tjj/siren_v2_quirk
Draft

Add quirks v2 siren entity based on SwitchMetadata#667
TheJulianJES wants to merge 7 commits intozigpy:devfrom
TheJulianJES:tjj/siren_v2_quirk

Conversation

@TheJulianJES
Copy link
Contributor

@TheJulianJES TheJulianJES commented Feb 21, 2026

DRAFT. TODO: Requires zigpy change adding SIREN = "siren" to EntityPlatform.

Based on:

Proposed change

This allows quirks v2 entities to provide entity_platform=EntityPlatform.SIREN for .switch() entities to create a siren entity on the HA side, instead of a switch entity.

Additional information

A lot of the logic and tests are copied from the switch entity, but there's no nice way around that. A downside of using SwitchMetadata is that we also support the "inverter attribute" logic which is not really necessary in all cases.. I thought of just ignoring that for the siren platform, but it's kept in here for now.
The logic is more similar to ConfigurableAttributeSwitch and its tests then.

It's a bit weird doing .switch to create a siren entity, but it's very similar to what we do with .enum to crate an enum sensor entity when providing a different entity_platform (and entity_type due to HA restrictions).

@dmulcahey
Copy link
Contributor

Maybe we add another method to the builder to make it clearer we are making a siren ex: siren_from_switch? or if this doesn't generalize well maybe something more generic like entity(entity_cls, ...) and we specify the actual class being created and what is needed? I feel like what is in the test for the builder:

QuirkBuilder(zigpy_dev.manufacturer, zigpy_dev.model)
    .switch(
        general.Basic.AttributeDefs.power_source.name,
        general.Basic.cluster_id,
        on_value=1,
        off_value=0,
        entity_platform=EntityPlatform.SIREN,
        translation_key="siren",
        fallback_name="Siren",
    )
    .add_to_registry()
)

makes sense to us but maybe will confuse potential contributors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants