Wh1terat / cleverspa-component

CleverSpa Home Assistant Integration
1 stars 2 forks source link

[Todo] Implement "cool down" timer for heater #2

Open Wh1terat opened 3 years ago

Wh1terat commented 3 years ago

The filter needs to be circulating for a short time after disabling the heater in order to cool the heater down. Need to implement some kind of timer to prevent the filter from being disabled too soon.

Wh1terat commented 3 years ago

Kinda implemented - bit of a hack. Still need to find a good way to stop users being able to turn off the filter until the cool down has completed.

    async def async_turn_off(self):
        """Turn heater off and filter 30 secs later."""
        await self.hass.async_add_executor_job(
            self.coordinator.client.set_data,
            self.coordinator.device_id,
            self.info_type[CONF_COMMAND_OFF]
        )
        # Not sure if this is 'naughty' or not
        self.hass.loop.call_later(
            COOLDOWN_TIME,
            self.hass.async_add_executor_job,
            self.coordinator.client.set_data,
            self.coordinator.device_id,
            {MAP_KEYS_INV['filter']: 0}
        )
        await self.coordinator.async_request_refresh()