From 45829b016c9aced6d4c98ea6eebe9b406ae928f7 Mon Sep 17 00:00:00 2001 From: Erik Montnemery Date: Fri, 17 Feb 2023 19:16:37 +0100 Subject: [PATCH] Remove conditional test of self.hass from tplink_omada switch (#88325) --- homeassistant/components/tplink_omada/switch.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/tplink_omada/switch.py b/homeassistant/components/tplink_omada/switch.py index 00c7551f4a5..dd5ee3168d2 100644 --- a/homeassistant/components/tplink_omada/switch.py +++ b/homeassistant/components/tplink_omada/switch.py @@ -88,6 +88,10 @@ class OmadaNetworkSwitchPortPoEControl(OmadaSwitchDeviceEntity, SwitchEntity): self._attr_unique_id = f"{device.mac}_{port_id}_poe" self._attr_name = f"{get_port_base_name(self.port_details)} PoE" + + async def async_added_to_hass(self) -> None: + """When entity is added to hass.""" + await super().async_added_to_hass() self._refresh_state() async def _async_turn_on_off_poe(self, enable: bool) -> None: @@ -108,8 +112,7 @@ class OmadaNetworkSwitchPortPoEControl(OmadaSwitchDeviceEntity, SwitchEntity): def _refresh_state(self) -> None: self._attr_is_on = self.port_details.poe_mode != PoEMode.DISABLED - if self.hass: - self.async_write_ha_state() + self.async_write_ha_state() @callback def _handle_coordinator_update(self) -> None: