Compare commits

..

5 Commits
6.2.6 ... 6.2.9

Author SHA1 Message Date
Jean-Marc Collin
c4b03f8c1e Update manifest.json 2024-07-07 16:49:22 +02:00
Paulo Ferreira de Castro
ac206a949f Fix Home Assistant deprecation warnings (EventType, helpers.service) (#484)
* Type hints: Replace deprecated helpers.typing.EventType with core.Event

* Replace deprecated use of hass.helpers.service.async_register_admin_service
2024-07-07 16:47:30 +02:00
Jean-Marc Collin
4bccb746b8 Release 6.2.8 2024-07-02 05:18:29 +00:00
Jean-Marc Collin
e999705286 Issue 474 - TPI in AC mode is wrong 2024-07-02 05:17:14 +00:00
Jean-Marc Collin
b4873bfd27 FIX issue_479 (#480)
Co-authored-by: Jean-Marc Collin <jean-marc.collin-extern@renault.com>
2024-07-02 07:04:47 +02:00
7 changed files with 51 additions and 57 deletions

View File

@@ -13,6 +13,7 @@ from homeassistant.const import SERVICE_RELOAD, EVENT_HOMEASSISTANT_STARTED
from homeassistant.config_entries import ConfigEntry, ConfigType from homeassistant.config_entries import ConfigEntry, ConfigType
from homeassistant.core import HomeAssistant, CoreState, callback from homeassistant.core import HomeAssistant, CoreState, callback
from homeassistant.helpers.service import async_register_admin_service
from .base_thermostat import BaseThermostat from .base_thermostat import BaseThermostat
@@ -115,7 +116,8 @@ async def async_setup(
else: else:
hass.bus.async_listen_once(EVENT_HOMEASSISTANT_STARTED, _async_startup_internal) hass.bus.async_listen_once(EVENT_HOMEASSISTANT_STARTED, _async_startup_internal)
hass.helpers.service.async_register_admin_service( async_register_admin_service(
hass,
DOMAIN, DOMAIN,
SERVICE_RELOAD, SERVICE_RELOAD,
_handle_reload, _handle_reload,

View File

@@ -22,7 +22,6 @@ from homeassistant.components.climate import ClimateEntity
from homeassistant.helpers.restore_state import RestoreEntity from homeassistant.helpers.restore_state import RestoreEntity
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.helpers.device_registry import DeviceInfo, DeviceEntryType from homeassistant.helpers.device_registry import DeviceInfo, DeviceEntryType
from homeassistant.helpers.typing import EventType as HASSEventType
from homeassistant.helpers.event import ( from homeassistant.helpers.event import (
async_track_state_change_event, async_track_state_change_event,
@@ -737,37 +736,37 @@ class BaseThermostat(ClimateEntity, RestoreEntity, Generic[T]):
) )
need_write_state = True need_write_state = True
# try to acquire window entity state # try to acquire window entity state
if self._window_sensor_entity_id: if self._window_sensor_entity_id:
window_state = self.hass.states.get(self._window_sensor_entity_id) window_state = self.hass.states.get(self._window_sensor_entity_id)
if window_state and window_state.state not in ( if window_state and window_state.state not in (
STATE_UNAVAILABLE, STATE_UNAVAILABLE,
STATE_UNKNOWN, STATE_UNKNOWN,
): ):
self._window_state = window_state.state == STATE_ON self._window_state = window_state.state == STATE_ON
_LOGGER.debug( _LOGGER.debug(
"%s - Window state have been retrieved: %s", "%s - Window state have been retrieved: %s",
self, self,
self._window_state, self._window_state,
) )
need_write_state = True need_write_state = True
# try to acquire motion entity state # try to acquire motion entity state
if self._motion_sensor_entity_id: if self._motion_sensor_entity_id:
motion_state = self.hass.states.get(self._motion_sensor_entity_id) motion_state = self.hass.states.get(self._motion_sensor_entity_id)
if motion_state and motion_state.state not in ( if motion_state and motion_state.state not in (
STATE_UNAVAILABLE, STATE_UNAVAILABLE,
STATE_UNKNOWN, STATE_UNKNOWN,
): ):
self._motion_state = motion_state.state self._motion_state = motion_state.state
_LOGGER.debug( _LOGGER.debug(
"%s - Motion state have been retrieved: %s", "%s - Motion state have been retrieved: %s",
self, self,
self._motion_state, self._motion_state,
) )
# recalculate the right target_temp in activity mode # recalculate the right target_temp in activity mode
await self._async_update_motion_temp() await self._async_update_motion_temp()
need_write_state = True need_write_state = True
if self._presence_on: if self._presence_on:
# try to acquire presence entity state # try to acquire presence entity state
@@ -1389,7 +1388,7 @@ class BaseThermostat(ClimateEntity, RestoreEntity, Generic[T]):
if self._motion_state == STATE_ON if self._motion_state == STATE_ON
else self._no_motion_preset else self._no_motion_preset
) )
if motion_preset in self._presets: if motion_preset in self._presets:
return self._presets[motion_preset] return self._presets[motion_preset]
else: else:
@@ -1654,7 +1653,7 @@ class BaseThermostat(ClimateEntity, RestoreEntity, Generic[T]):
_LOGGER.debug("%s - Motion delay condition is satisfied", self) _LOGGER.debug("%s - Motion delay condition is satisfied", self)
self._motion_state = new_state.state self._motion_state = new_state.state
if self._attr_preset_mode == PRESET_ACTIVITY: if self._attr_preset_mode == PRESET_ACTIVITY:
new_preset = ( new_preset = (
self._motion_preset self._motion_preset
if self._motion_state == STATE_ON if self._motion_state == STATE_ON
@@ -1790,7 +1789,7 @@ class BaseThermostat(ClimateEntity, RestoreEntity, Generic[T]):
_LOGGER.error("Unable to update external temperature from sensor: %s", ex) _LOGGER.error("Unable to update external temperature from sensor: %s", ex)
@callback @callback
async def _async_power_changed(self, event: HASSEventType[EventStateChangedData]): async def _async_power_changed(self, event: Event[EventStateChangedData]):
"""Handle power changes.""" """Handle power changes."""
_LOGGER.debug("Thermostat %s - Receive new Power event", self.name) _LOGGER.debug("Thermostat %s - Receive new Power event", self.name)
_LOGGER.debug(event) _LOGGER.debug(event)
@@ -1816,9 +1815,7 @@ class BaseThermostat(ClimateEntity, RestoreEntity, Generic[T]):
_LOGGER.error("Unable to update current_power from sensor: %s", ex) _LOGGER.error("Unable to update current_power from sensor: %s", ex)
@callback @callback
async def _async_max_power_changed( async def _async_max_power_changed(self, event: Event[EventStateChangedData]):
self, event: HASSEventType[EventStateChangedData]
):
"""Handle power max changes.""" """Handle power max changes."""
_LOGGER.debug("Thermostat %s - Receive new Power Max event", self.name) _LOGGER.debug("Thermostat %s - Receive new Power Max event", self.name)
_LOGGER.debug(event) _LOGGER.debug(event)
@@ -1843,9 +1840,7 @@ class BaseThermostat(ClimateEntity, RestoreEntity, Generic[T]):
_LOGGER.error("Unable to update current_power from sensor: %s", ex) _LOGGER.error("Unable to update current_power from sensor: %s", ex)
@callback @callback
async def _async_presence_changed( async def _async_presence_changed(self, event: Event[EventStateChangedData]):
self, event: HASSEventType[EventStateChangedData]
):
"""Handle presence changes.""" """Handle presence changes."""
new_state = event.data.get("new_state") new_state = event.data.get("new_state")
_LOGGER.info( _LOGGER.info(
@@ -1905,7 +1900,7 @@ class BaseThermostat(ClimateEntity, RestoreEntity, Generic[T]):
or self._attr_preset_mode != PRESET_ACTIVITY or self._attr_preset_mode != PRESET_ACTIVITY
): ):
return return
new_preset = ( new_preset = (
self._motion_preset self._motion_preset
if self._motion_state == STATE_ON if self._motion_state == STATE_ON
@@ -1916,13 +1911,13 @@ class BaseThermostat(ClimateEntity, RestoreEntity, Generic[T]):
self, self,
new_preset, new_preset,
) )
# We do not change the preset which is kept to ACTIVITY but only the target_temperature # We do not change the preset which is kept to ACTIVITY but only the target_temperature
# We take the presence into account # We take the presence into account
await self._async_internal_set_temperature( await self._async_internal_set_temperature(
self.find_preset_temp(new_preset) self.find_preset_temp(new_preset)
) )
_LOGGER.debug( _LOGGER.debug(
"%s - regarding motion, target_temp have been set to %.2f", "%s - regarding motion, target_temp have been set to %.2f",
self, self,

View File

@@ -14,6 +14,6 @@
"quality_scale": "silver", "quality_scale": "silver",
"requirements": [], "requirements": [],
"ssdp": [], "ssdp": [],
"version": "6.2.6", "version": "6.2.9",
"zeroconf": [] "zeroconf": []
} }

View File

@@ -70,9 +70,9 @@ class PropAlgorithm:
if hvac_mode == HVACMode.COOL: if hvac_mode == HVACMode.COOL:
delta_temp = current_temp - target_temp delta_temp = current_temp - target_temp
delta_ext_temp = ( delta_ext_temp = (
ext_current_temp ext_current_temp - target_temp
if ext_current_temp is not None if ext_current_temp is not None
else 0 - target_temp else 0
) )
else: else:
delta_temp = target_temp - current_temp delta_temp = target_temp - current_temp

View File

@@ -3,13 +3,12 @@
import logging import logging
from datetime import timedelta, datetime from datetime import timedelta, datetime
from homeassistant.core import HomeAssistant, State, callback from homeassistant.core import Event, HomeAssistant, State, callback
from homeassistant.helpers.event import ( from homeassistant.helpers.event import (
async_track_state_change_event, async_track_state_change_event,
async_track_time_interval, async_track_time_interval,
EventStateChangedData, EventStateChangedData,
) )
from homeassistant.helpers.typing import EventType as HASSEventType
from homeassistant.components.climate import ( from homeassistant.components.climate import (
HVACAction, HVACAction,
HVACMode, HVACMode,
@@ -600,7 +599,7 @@ class ThermostatOverClimate(BaseThermostat[UnderlyingClimate]):
) )
@callback @callback
async def _async_climate_changed(self, event: HASSEventType[EventStateChangedData]): async def _async_climate_changed(self, event: Event[EventStateChangedData]):
"""Handle unerdlying climate state changes. """Handle unerdlying climate state changes.
This method takes the underlying values and update the VTherm with them. This method takes the underlying values and update the VTherm with them.
To avoid loops (issues #121 #101 #95 #99), we discard the event if it is received To avoid loops (issues #121 #101 #95 #99), we discard the event if it is received

View File

@@ -2,12 +2,11 @@
""" A climate over switch classe """ """ A climate over switch classe """
import logging import logging
from homeassistant.core import callback from homeassistant.core import Event, callback
from homeassistant.helpers.event import ( from homeassistant.helpers.event import (
async_track_state_change_event, async_track_state_change_event,
EventStateChangedData, EventStateChangedData,
) )
from homeassistant.helpers.typing import EventType as HASSEventType
from homeassistant.components.climate import HVACMode from homeassistant.components.climate import HVACMode
from .const import ( from .const import (
@@ -212,7 +211,7 @@ class ThermostatOverSwitch(BaseThermostat[UnderlyingSwitch]):
) )
@callback @callback
def _async_switch_changed(self, event: HASSEventType[EventStateChangedData]): def _async_switch_changed(self, event: Event[EventStateChangedData]):
"""Handle heater switch state changes.""" """Handle heater switch state changes."""
new_state = event.data.get("new_state") new_state = event.data.get("new_state")
old_state = event.data.get("old_state") old_state = event.data.get("old_state")

View File

@@ -8,8 +8,7 @@ from homeassistant.helpers.event import (
async_track_time_interval, async_track_time_interval,
EventStateChangedData, EventStateChangedData,
) )
from homeassistant.helpers.typing import EventType as HASSEventType from homeassistant.core import Event, HomeAssistant, callback
from homeassistant.core import HomeAssistant, callback
from homeassistant.components.climate import HVACMode from homeassistant.components.climate import HVACMode
from .base_thermostat import BaseThermostat, ConfigData from .base_thermostat import BaseThermostat, ConfigData
@@ -149,7 +148,7 @@ class ThermostatOverValve(BaseThermostat[UnderlyingValve]): # pylint: disable=a
) )
@callback @callback
async def _async_valve_changed(self, event: HASSEventType[EventStateChangedData]): async def _async_valve_changed(self, event: Event[EventStateChangedData]):
"""Handle unerdlying valve state changes. """Handle unerdlying valve state changes.
This method just log the change. It changes nothing to avoid loops. This method just log the change. It changes nothing to avoid loops.
""" """