Upgrading the deprecated functions

This commit is contained in:
Erwin Douna
2023-08-05 20:04:20 +00:00
parent 81a0ee5788
commit b3c224c525

View File

@@ -163,12 +163,11 @@ class TadoConnector:
def setup(self): def setup(self):
"""Connect to Tado and fetch the zones.""" """Connect to Tado and fetch the zones."""
self.tado = Tado(self._username, self._password) self.tado = Tado(self._username, self._password, None, True)
self.tado.setDebugging(True)
# Load zones and devices # Load zones and devices
self.zones = self.tado.getZones() self.zones = self.tado.get_zones()
self.devices = self.tado.getDevices() self.devices = self.tado.get_devices()
tado_home = self.tado.getMe()["homes"][0] tado_home = self.tado.get_me()["homes"][0]
self.home_id = tado_home["id"] self.home_id = tado_home["id"]
self.home_name = tado_home["name"] self.home_name = tado_home["name"]
@@ -181,7 +180,7 @@ class TadoConnector:
def update_devices(self): def update_devices(self):
"""Update the device data from Tado.""" """Update the device data from Tado."""
devices = self.tado.getDevices() devices = self.tado.get_devices()
for device in devices: for device in devices:
device_short_serial_no = device["shortSerialNo"] device_short_serial_no = device["shortSerialNo"]
_LOGGER.debug("Updating device %s", device_short_serial_no) _LOGGER.debug("Updating device %s", device_short_serial_no)
@@ -190,7 +189,7 @@ class TadoConnector:
INSIDE_TEMPERATURE_MEASUREMENT INSIDE_TEMPERATURE_MEASUREMENT
in device["characteristics"]["capabilities"] in device["characteristics"]["capabilities"]
): ):
device[TEMP_OFFSET] = self.tado.getDeviceInfo( device[TEMP_OFFSET] = self.tado.get_device_info(
device_short_serial_no, TEMP_OFFSET device_short_serial_no, TEMP_OFFSET
) )
except RuntimeError: except RuntimeError:
@@ -218,7 +217,7 @@ class TadoConnector:
def update_zones(self): def update_zones(self):
"""Update the zone data from Tado.""" """Update the zone data from Tado."""
try: try:
zone_states = self.tado.getZoneStates()["zoneStates"] zone_states = self.tado.get_zone_states()["zoneStates"]
except RuntimeError: except RuntimeError:
_LOGGER.error("Unable to connect to Tado while updating zones") _LOGGER.error("Unable to connect to Tado while updating zones")
return return
@@ -230,7 +229,7 @@ class TadoConnector:
"""Update the internal data from Tado.""" """Update the internal data from Tado."""
_LOGGER.debug("Updating zone %s", zone_id) _LOGGER.debug("Updating zone %s", zone_id)
try: try:
data = self.tado.getZoneState(zone_id) data = self.tado.get_zone_state(zone_id)
except RuntimeError: except RuntimeError:
_LOGGER.error("Unable to connect to Tado while updating zone %s", zone_id) _LOGGER.error("Unable to connect to Tado while updating zone %s", zone_id)
return return
@@ -251,8 +250,8 @@ class TadoConnector:
def update_home(self): def update_home(self):
"""Update the home data from Tado.""" """Update the home data from Tado."""
try: try:
self.data["weather"] = self.tado.getWeather() self.data["weather"] = self.tado.get_weather()
self.data["geofence"] = self.tado.getHomeState() self.data["geofence"] = self.tado.get_home_state()
dispatcher_send( dispatcher_send(
self.hass, self.hass,
SIGNAL_TADO_UPDATE_RECEIVED.format(self.home_id, "home", "data"), SIGNAL_TADO_UPDATE_RECEIVED.format(self.home_id, "home", "data"),
@@ -265,15 +264,15 @@ class TadoConnector:
def get_capabilities(self, zone_id): def get_capabilities(self, zone_id):
"""Return the capabilities of the devices.""" """Return the capabilities of the devices."""
return self.tado.getCapabilities(zone_id) return self.tado.get_capabilities(zone_id)
def get_auto_geofencing_supported(self): def get_auto_geofencing_supported(self):
"""Return whether the Tado Home supports auto geofencing.""" """Return whether the Tado Home supports auto geofencing."""
return self.tado.getAutoGeofencingSupported() return self.tado.get_auto_geofencing_supported()
def reset_zone_overlay(self, zone_id): def reset_zone_overlay(self, zone_id):
"""Reset the zone back to the default operation.""" """Reset the zone back to the default operation."""
self.tado.resetZoneOverlay(zone_id) self.tado.reset_zone_overlay(zone_id)
self.update_zone(zone_id) self.update_zone(zone_id)
def set_presence( def set_presence(
@@ -282,11 +281,11 @@ class TadoConnector:
): ):
"""Set the presence to home, away or auto.""" """Set the presence to home, away or auto."""
if presence == PRESET_AWAY: if presence == PRESET_AWAY:
self.tado.setAway() self.tado.set_away()
elif presence == PRESET_HOME: elif presence == PRESET_HOME:
self.tado.setHome() self.tado.set_home()
elif presence == PRESET_AUTO: elif presence == PRESET_AUTO:
self.tado.setAuto() self.tado.set_auto()
# Update everything when changing modes # Update everything when changing modes
self.update_zones() self.update_zones()
@@ -320,7 +319,7 @@ class TadoConnector:
) )
try: try:
self.tado.setZoneOverlay( self.tado.set_zone_overlay(
zone_id, zone_id,
overlay_mode, overlay_mode,
temperature, temperature,
@@ -340,7 +339,7 @@ class TadoConnector:
def set_zone_off(self, zone_id, overlay_mode, device_type="HEATING"): def set_zone_off(self, zone_id, overlay_mode, device_type="HEATING"):
"""Set a zone to off.""" """Set a zone to off."""
try: try:
self.tado.setZoneOverlay( self.tado.set_zone_overlay(
zone_id, overlay_mode, None, None, device_type, "OFF" zone_id, overlay_mode, None, None, device_type, "OFF"
) )
except RequestException as exc: except RequestException as exc:
@@ -351,6 +350,6 @@ class TadoConnector:
def set_temperature_offset(self, device_id, offset): def set_temperature_offset(self, device_id, offset):
"""Set temperature offset of device.""" """Set temperature offset of device."""
try: try:
self.tado.setTempOffset(device_id, offset) self.tado.set_temp_offset(device_id, offset)
except RequestException as exc: except RequestException as exc:
_LOGGER.error("Could not set temperature offset: %s", exc) _LOGGER.error("Could not set temperature offset: %s", exc)