1 """Platform allowing several button entities to be grouped into one single button."""
3 from __future__
import annotations
7 import voluptuous
as vol
10 DOMAIN
as BUTTON_DOMAIN,
11 PLATFORM_SCHEMA
as BUTTON_PLATFORM_SCHEMA,
28 from .entity
import GroupEntity
30 DEFAULT_NAME =
"Button group"
35 PLATFORM_SCHEMA = BUTTON_PLATFORM_SCHEMA.extend(
37 vol.Required(CONF_ENTITIES): cv.entities_domain(BUTTON_DOMAIN),
38 vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string,
39 vol.Optional(CONF_UNIQUE_ID): cv.string,
47 async_add_entities: AddEntitiesCallback,
48 __: DiscoveryInfoType |
None =
None,
50 """Set up the button group platform."""
54 config.get(CONF_UNIQUE_ID),
56 config[CONF_ENTITIES],
64 config_entry: ConfigEntry,
65 async_add_entities: AddEntitiesCallback,
67 """Initialize button group config entry."""
68 registry = er.async_get(hass)
69 entities = er.async_validate_entity_ids(
70 registry, config_entry.options[CONF_ENTITIES]
75 config_entry.entry_id,
85 hass: HomeAssistant, name: str, validated_config: dict[str, Any]
87 """Create a preview button."""
91 validated_config[CONF_ENTITIES],
96 """Representation of an button group."""
98 _attr_available =
False
99 _attr_should_poll =
False
103 unique_id: str |
None,
105 entity_ids: list[str],
107 """Initialize a button group."""
114 """Forward the press to all buttons in the group."""
115 await self.
hasshass.services.async_call(
125 """Query all members and determine the button group state."""
128 state.state != STATE_UNAVAILABLE
130 if (state := self.
hasshass.states.get(entity_id))
is not None