File tree Expand file tree Collapse file tree 2 files changed +20
-1
lines changed
homeassistant/components/shelly Expand file tree Collapse file tree 2 files changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -226,6 +226,8 @@ async def update_position(self) -> None:
226226 def _update_callback (self ) -> None :
227227 """Handle device update. Use a task when opening/closing is in progress."""
228228 super ()._update_callback ()
229+ if not self .coordinator .device .initialized :
230+ return
229231 if self .is_closing or self .is_opening :
230232 self .launch_update_task ()
231233
Original file line number Diff line number Diff line change 2323 CoverState ,
2424)
2525from homeassistant .components .shelly .const import RPC_COVER_UPDATE_TIME_SEC
26- from homeassistant .const import ATTR_ENTITY_ID
26+ from homeassistant .const import ATTR_ENTITY_ID , STATE_UNAVAILABLE
2727from homeassistant .core import HomeAssistant
2828from homeassistant .helpers .entity_registry import EntityRegistry
2929
@@ -417,3 +417,20 @@ async def test_update_position_no_movement(
417417 assert (state := hass .states .get (entity_id ))
418418 assert state .state == CoverState .OPEN
419419 assert state .attributes [ATTR_CURRENT_POSITION ] == 100
420+
421+
422+ async def test_rpc_not_initialized_update (
423+ hass : HomeAssistant , mock_rpc_device : Mock , monkeypatch : pytest .MonkeyPatch
424+ ) -> None :
425+ """Test update not called when device is not initialized."""
426+ entity_id = "cover.test_name_test_cover_0"
427+ await init_integration (hass , 2 )
428+
429+ assert (state := hass .states .get (entity_id ))
430+ assert state .state == CoverState .OPEN
431+
432+ monkeypatch .setattr (mock_rpc_device , "initialized" , False )
433+ mock_rpc_device .mock_update ()
434+
435+ assert (state := hass .states .get (entity_id ))
436+ assert state .state == STATE_UNAVAILABLE
You can’t perform that action at this time.
0 commit comments