From 7ea23533cf2bf35b1637215f3a5b91338cabaf16 Mon Sep 17 00:00:00 2001 From: djtimca <60706061+djtimca@users.noreply.github.com> Date: Fri, 14 May 2021 04:02:54 -0400 Subject: [PATCH] Address late review for Omnilogic Switch (#50404) * Address previous PR comments. * Update all instances of async_schedule_update_ha_state to async_write_ha_state. --- homeassistant/components/omnilogic/common.py | 2 ++ homeassistant/components/omnilogic/sensor.py | 2 +- homeassistant/components/omnilogic/switch.py | 12 ++++++------ 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/homeassistant/components/omnilogic/common.py b/homeassistant/components/omnilogic/common.py index 645c24ac676..a4e8d4f491e 100644 --- a/homeassistant/components/omnilogic/common.py +++ b/homeassistant/components/omnilogic/common.py @@ -176,3 +176,5 @@ def check_guard(state_key, item, entity_setting): for guard_key, guard_value in guard_condition.items() ): return True + + return False diff --git a/homeassistant/components/omnilogic/sensor.py b/homeassistant/components/omnilogic/sensor.py index 24cbe82e17b..60ca685a2f8 100644 --- a/homeassistant/components/omnilogic/sensor.py +++ b/homeassistant/components/omnilogic/sensor.py @@ -136,7 +136,7 @@ class OmniLogicPumpSpeedSensor(OmnilogicSensor): self._unit = PERCENTAGE state = pump_speed elif pump_type == "DUAL": - self._unit = "" + self._unit = None if pump_speed == 0: state = "off" elif pump_speed == self.coordinator.data[self._item_id].get( diff --git a/homeassistant/components/omnilogic/switch.py b/homeassistant/components/omnilogic/switch.py index ef4d2b32cc5..b6fec2e9f25 100644 --- a/homeassistant/components/omnilogic/switch.py +++ b/homeassistant/components/omnilogic/switch.py @@ -57,7 +57,7 @@ async def async_setup_entry(hass, entry, async_add_entities): class OmniLogicSwitch(OmniLogicEntity, SwitchEntity): - """Define an Omnilogic Base Switch entity which will be instantiated through specific switch type entities.""" + """Define an Omnilogic Base Switch entity to be extended.""" def __init__( self, @@ -108,7 +108,7 @@ class OmniLogicRelayControl(OmniLogicSwitch): """Turn on the relay.""" self._state = True self._last_action = time.time() - self.async_schedule_update_ha_state() + self.async_write_ha_state() await self.coordinator.api.set_relay_valve( int(self._item_id[1]), @@ -121,7 +121,7 @@ class OmniLogicRelayControl(OmniLogicSwitch): """Turn off the relay.""" self._state = False self._last_action = time.time() - self.async_schedule_update_ha_state() + self.async_write_ha_state() await self.coordinator.api.set_relay_valve( int(self._item_id[1]), @@ -167,7 +167,7 @@ class OmniLogicPumpControl(OmniLogicSwitch): """Turn on the pump.""" self._state = True self._last_action = time.time() - self.async_schedule_update_ha_state() + self.async_write_ha_state() on_value = 100 @@ -185,7 +185,7 @@ class OmniLogicPumpControl(OmniLogicSwitch): """Turn off the pump.""" self._state = False self._last_action = time.time() - self.async_schedule_update_ha_state() + self.async_write_ha_state() if self._pump_type != "SINGLE": if "filterSpeed" in self.coordinator.data[self._item_id]: @@ -213,7 +213,7 @@ class OmniLogicPumpControl(OmniLogicSwitch): ) if success: - self.async_schedule_update_ha_state() + self.async_write_ha_state() else: raise OmniLogicException(