diff --git a/homeassistant/components/group/cover.py b/homeassistant/components/group/cover.py index b0d0b8b7bd2..ab2ad65713d 100644 --- a/homeassistant/components/group/cover.py +++ b/homeassistant/components/group/cover.py @@ -39,7 +39,7 @@ from homeassistant.const import ( STATE_OPEN, STATE_OPENING, ) -from homeassistant.core import State +from homeassistant.core import CoreState, State import homeassistant.helpers.config_validation as cv from homeassistant.helpers.event import async_track_state_change_event @@ -162,6 +162,10 @@ class CoverGroup(GroupEntity, CoverEntity): self.hass, self._entities, self._update_supported_features_event ) ) + + if self.hass.state == CoreState.running: + await self.async_update() + return await super().async_added_to_hass() @property diff --git a/homeassistant/components/group/light.py b/homeassistant/components/group/light.py index 289bb8df3f0..007e05edfbb 100644 --- a/homeassistant/components/group/light.py +++ b/homeassistant/components/group/light.py @@ -36,7 +36,7 @@ from homeassistant.const import ( STATE_ON, STATE_UNAVAILABLE, ) -from homeassistant.core import State +from homeassistant.core import CoreState, State import homeassistant.helpers.config_validation as cv from homeassistant.helpers.event import async_track_state_change_event from homeassistant.helpers.typing import ConfigType, HomeAssistantType @@ -111,6 +111,11 @@ class LightGroup(GroupEntity, light.LightEntity): self.hass, self._entity_ids, async_state_changed_listener ) ) + + if self.hass.state == CoreState.running: + await self.async_update() + return + await super().async_added_to_hass() @property diff --git a/tests/components/group/test_light.py b/tests/components/group/test_light.py index a22c56b4bfc..ba8fecbed32 100644 --- a/tests/components/group/test_light.py +++ b/tests/components/group/test_light.py @@ -737,6 +737,11 @@ async def test_reload_with_base_integration_platform_not_setup(hass): }, ) await hass.async_block_till_done() + hass.states.async_set("light.master_hall_lights", STATE_ON) + hass.states.async_set("light.master_hall_lights_2", STATE_OFF) + + hass.states.async_set("light.outside_patio_lights", STATE_OFF) + hass.states.async_set("light.outside_patio_lights_2", STATE_OFF) yaml_path = path.join( _get_fixtures_base_path(), @@ -755,6 +760,8 @@ async def test_reload_with_base_integration_platform_not_setup(hass): assert hass.states.get("light.light_group") is None assert hass.states.get("light.master_hall_lights_g") is not None assert hass.states.get("light.outside_patio_lights_g") is not None + assert hass.states.get("light.master_hall_lights_g").state == STATE_ON + assert hass.states.get("light.outside_patio_lights_g").state == STATE_OFF def _get_fixtures_base_path():