Remove conditional test of self.hass from tplink_omada switch (#88325)

pull/88292/head
Erik Montnemery 2023-02-17 19:16:37 +01:00 committed by GitHub
parent 30384501af
commit 45829b016c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 2 deletions

View File

@ -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: