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.
This commit is contained in:
djtimca 2021-05-14 04:02:54 -04:00 committed by GitHub
parent 207ee39d00
commit 7ea23533cf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 7 deletions

View file

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

View file

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

View file

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