mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Add entity list to light and cover group attributes (#36477)
Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io> Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
This commit is contained in:
parent
492874c4a0
commit
bdc098645b
@ -200,6 +200,11 @@ class CoverGroup(CoverEntity):
|
|||||||
"""Return current tilt position for all covers."""
|
"""Return current tilt position for all covers."""
|
||||||
return self._tilt_position
|
return self._tilt_position
|
||||||
|
|
||||||
|
@property
|
||||||
|
def device_state_attributes(self):
|
||||||
|
"""Return the state attributes for the cover group."""
|
||||||
|
return {ATTR_ENTITY_ID: self._entities}
|
||||||
|
|
||||||
async def async_open_cover(self, **kwargs):
|
async def async_open_cover(self, **kwargs):
|
||||||
"""Move the covers up."""
|
"""Move the covers up."""
|
||||||
data = {ATTR_ENTITY_ID: self._covers[KEY_OPEN_CLOSE]}
|
data = {ATTR_ENTITY_ID: self._covers[KEY_OPEN_CLOSE]}
|
||||||
|
@ -183,6 +183,11 @@ class LightGroup(light.LightEntity):
|
|||||||
"""No polling needed for a light group."""
|
"""No polling needed for a light group."""
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
@property
|
||||||
|
def device_state_attributes(self):
|
||||||
|
"""Return the state attributes for the light group."""
|
||||||
|
return {ATTR_ENTITY_ID: self._entity_ids}
|
||||||
|
|
||||||
async def async_turn_on(self, **kwargs):
|
async def async_turn_on(self, **kwargs):
|
||||||
"""Forward the turn_on command to all lights in the light group."""
|
"""Forward the turn_on command to all lights in the light group."""
|
||||||
data = {ATTR_ENTITY_ID: self._entity_ids}
|
data = {ATTR_ENTITY_ID: self._entity_ids}
|
||||||
|
@ -86,6 +86,12 @@ async def test_attributes(hass, setup_comp):
|
|||||||
state = hass.states.get(COVER_GROUP)
|
state = hass.states.get(COVER_GROUP)
|
||||||
assert state.state == STATE_CLOSED
|
assert state.state == STATE_CLOSED
|
||||||
assert state.attributes[ATTR_FRIENDLY_NAME] == DEFAULT_NAME
|
assert state.attributes[ATTR_FRIENDLY_NAME] == DEFAULT_NAME
|
||||||
|
assert state.attributes[ATTR_ENTITY_ID] == [
|
||||||
|
DEMO_COVER,
|
||||||
|
DEMO_COVER_POS,
|
||||||
|
DEMO_COVER_TILT,
|
||||||
|
DEMO_TILT,
|
||||||
|
]
|
||||||
assert ATTR_ASSUMED_STATE not in state.attributes
|
assert ATTR_ASSUMED_STATE not in state.attributes
|
||||||
assert state.attributes[ATTR_SUPPORTED_FEATURES] == 0
|
assert state.attributes[ATTR_SUPPORTED_FEATURES] == 0
|
||||||
assert ATTR_CURRENT_POSITION not in state.attributes
|
assert ATTR_CURRENT_POSITION not in state.attributes
|
||||||
|
@ -34,17 +34,25 @@ from tests.async_mock import MagicMock
|
|||||||
|
|
||||||
async def test_default_state(hass):
|
async def test_default_state(hass):
|
||||||
"""Test light group default state."""
|
"""Test light group default state."""
|
||||||
|
hass.states.async_set("light.kitchen", "on")
|
||||||
await async_setup_component(
|
await async_setup_component(
|
||||||
hass,
|
hass,
|
||||||
LIGHT_DOMAIN,
|
LIGHT_DOMAIN,
|
||||||
{LIGHT_DOMAIN: {"platform": DOMAIN, "entities": [], "name": "Bedroom Group"}},
|
{
|
||||||
|
LIGHT_DOMAIN: {
|
||||||
|
"platform": DOMAIN,
|
||||||
|
"entities": ["light.kitchen", "light.bedroom"],
|
||||||
|
"name": "Bedroom Group",
|
||||||
|
}
|
||||||
|
},
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
state = hass.states.get("light.bedroom_group")
|
state = hass.states.get("light.bedroom_group")
|
||||||
assert state is not None
|
assert state is not None
|
||||||
assert state.state == STATE_UNAVAILABLE
|
assert state.state == STATE_ON
|
||||||
assert state.attributes[ATTR_SUPPORTED_FEATURES] == 0
|
assert state.attributes[ATTR_SUPPORTED_FEATURES] == 0
|
||||||
|
assert state.attributes.get(ATTR_ENTITY_ID) == ["light.kitchen", "light.bedroom"]
|
||||||
assert state.attributes.get(ATTR_BRIGHTNESS) is None
|
assert state.attributes.get(ATTR_BRIGHTNESS) is None
|
||||||
assert state.attributes.get(ATTR_HS_COLOR) is None
|
assert state.attributes.get(ATTR_HS_COLOR) is None
|
||||||
assert state.attributes.get(ATTR_COLOR_TEMP) is None
|
assert state.attributes.get(ATTR_COLOR_TEMP) is None
|
||||||
|
Loading…
x
Reference in New Issue
Block a user