Skip to content

Commit

Permalink
Changes to be committed:
Browse files Browse the repository at this point in the history
	modified:   custom_components/programmable_thermostat/climate.py
	modified:   custom_components/programmable_thermostat/const.py

Fixed additional deprecated constant and substitute self.async_update_ha_state with self.async_write_ha_state
  • Loading branch information
MapoDan committed Jan 9, 2024
1 parent 3e97956 commit aa8ebe3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
10 changes: 5 additions & 5 deletions custom_components/programmable_thermostat/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ async def _async_turn_on(self, mode=None):
if not self._is_device_active_function(forced=False) and self.is_active_long_enough(mode=mode):
self._set_hvac_action_on(mode=mode)
await self.hass.services.async_call(HA_DOMAIN, SERVICE_TURN_ON, data)
await self.async_update_ha_state()
await self.async_write_ha_state()

async def _async_turn_off(self, mode=None, forced=False):
"""Turn heater toggleable device off."""
Expand All @@ -293,7 +293,7 @@ async def _async_turn_off(self, mode=None, forced=False):
if self._is_device_active_function(forced=forced) and self.is_active_long_enough(mode=mode):
self._set_hvac_action_off(mode=mode)
await self.hass.services.async_call(HA_DOMAIN, SERVICE_TURN_OFF, data)
await self.async_update_ha_state()
await self.async_write_ha_state()

async def async_set_hvac_mode(self, hvac_mode):
"""Set hvac mode."""
Expand All @@ -320,7 +320,7 @@ async def async_set_temperature(self, **kwargs):
return
self._target_temp = float(temperature)
await self.control_system_mode()
await self.async_update_ha_state()
await self.async_write_ha_state()

async def _async_sensor_changed(self, event):
"""Handle temperature changes."""
Expand All @@ -329,7 +329,7 @@ async def _async_sensor_changed(self, event):
return
self._async_update_temp(new_state.state)
await self.control_system_mode()
await self.async_update_ha_state()
await self.async_write_ha_state()

async def _async_target_changed(self, event):
"""Handle temperature changes in the program."""
Expand All @@ -340,7 +340,7 @@ async def _async_target_changed(self, event):
if self._hvac_mode == HVACMode.HEAT_COOL:
self._async_restore_program_temp()
await self.control_system_mode()
await self.async_update_ha_state()
await self.async_write_ha_state()

async def _async_control_thermo(self, mode=None):
"""Check if we need to turn heating on or off."""
Expand Down
10 changes: 3 additions & 7 deletions custom_components/programmable_thermostat/const.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
"""Programmable thermostat's constant """
from homeassistant.components.climate.const import (
HVAC_MODE_COOL,
HVAC_MODE_HEAT,
HVAC_MODE_OFF,
HVAC_MODE_HEAT_COOL)
from homeassistant.components.climate import HVACMode

#Generic
VERSION = '8.3'
Expand All @@ -25,8 +21,8 @@
#Others
MAX_HVAC_OPTIONS = 8
AUTO_MODE_OPTIONS = ['all', 'heating', 'cooling']
INITIAL_HVAC_MODE_OPTIONS = ['', HVAC_MODE_COOL, HVAC_MODE_HEAT, HVAC_MODE_OFF, HVAC_MODE_HEAT_COOL]
INITIAL_HVAC_MODE_OPTIONS_OPTFLOW = ['null', HVAC_MODE_COOL, HVAC_MODE_HEAT, HVAC_MODE_OFF, HVAC_MODE_HEAT_COOL]
INITIAL_HVAC_MODE_OPTIONS = ['', HVACMode.COOL, HVACMode.HEAT, HVACMode.OFF, HVACMode.HEAT_COOL]
INITIAL_HVAC_MODE_OPTIONS_OPTFLOW = ['null', HVACMode.COOL, HVACMode.HEAT, HVACMode.OFF, HVACMode.HEAT_COOL]
REGEX_STRING = r'((?P<hours>\d+?):(?=(\d+?:\d+?)))?((?P<minutes>\d+?):)?((?P<seconds>\d+?))?$'

#Attributes
Expand Down

0 comments on commit aa8ebe3

Please sign in to comment.