Skip to content

Commit

Permalink
moved methods to base_tado
Browse files Browse the repository at this point in the history
- changed compatibility of tadoX devices
  • Loading branch information
wmalgadey committed Dec 29, 2024
1 parent 53cf209 commit 32cacdc
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 84 deletions.
51 changes: 50 additions & 1 deletion PyTado/interface/api/base_tado.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
"""
Base class for Tado API classes.
"""

import datetime
import enum
import logging
Expand Down Expand Up @@ -147,7 +151,7 @@ def get_historic(self, zone, date):
raise ValueError("Incorrect date format, should be YYYY-MM-DD") from err

request = TadoRequest()
request.command = f"zones/{zone:d}/dayReport?date={day.strftime('%Y-%m-%d')}"
request.command = f"zones/{zone:d}/dayReport?date={day.strftime("%Y-%m-%d")}"
return self._http.request(request)

@abstractmethod
Expand Down Expand Up @@ -393,3 +397,48 @@ def get_running_times(self, date=datetime.datetime.now().strftime("%Y-%m-%d")) -
request.params = {"from": date}

return self._http.request(request)

def get_boiler_install_state(self, bridge_id: str, auth_key: str):
"""
Get the boiler wiring installation state from home by bridge endpoint
"""

request = TadoRequest()
request.action = Action.GET
request.domain = Domain.HOME_BY_BRIDGE
request.device = bridge_id
request.command = "boilerWiringInstallationState"
request.params = {"authKey": auth_key}

return self._http.request(request)

def get_boiler_max_output_temperature(self, bridge_id: str, auth_key: str):
"""
Get the boiler max output temperature from home by bridge endpoint
"""

request = TadoRequest()
request.action = Action.GET
request.domain = Domain.HOME_BY_BRIDGE
request.device = bridge_id
request.command = "boilerMaxOutputTemperature"
request.params = {"authKey": auth_key}

return self._http.request(request)

def set_boiler_max_output_temperature(
self, bridge_id: str, auth_key: str, temperature_in_celcius: float
):
"""
Set the boiler max output temperature with home by bridge endpoint
"""

request = TadoRequest()
request.action = Action.CHANGE
request.domain = Domain.HOME_BY_BRIDGE
request.device = bridge_id
request.command = "boilerMaxOutputTemperature"
request.params = {"authKey": auth_key}
request.payload = {"boilerMaxOutputTemperatureInCelsius": temperature_in_celcius}

return self._http.request(request)
26 changes: 18 additions & 8 deletions PyTado/interface/api/hops_tado.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ def get_devices(self):
devices = [device for room in rooms for device in room["devices"]]

for device in devices:
device["generation"] = "LINE_X"

serial_number = device.get("serialNo", device.get("serialNumber"))
if not serial_number:
continue
Expand All @@ -72,13 +74,21 @@ def get_devices(self):

# compatibility with my.tado.com API
device["shortSerialNo"] = serial_number
device["characteristics"]["capabilities"] = self.get_capabilities(device["serialNo"])
device["name"] = device["roomName"]
device["id"] = device["roomId"]
device["generation"] = "LINE_X"

if "characteristics" not in device:
device["characteristics"] = {"capabilities": {}}

device["characteristics"]["capabilities"] = self.get_capabilities(serial_number)

if "otherDevices" in rooms_and_devices:
devices.append(rooms_and_devices["otherDevices"])
for device in rooms_and_devices["otherDevices"]:
device["generation"] = "LINE_X"

serial_number = device.get("serialNo", device.get("serialNumber"))

devices.append(device)

return devices

Expand All @@ -94,14 +104,14 @@ def get_zones(self):

def get_zone_state(self, zone: int) -> TadoZone:
"""
Gets current state of Zone as a TadoXZone object.
Gets current state of zone/room as a TadoXZone object.
"""

return TadoXZone.from_data(zone, self.get_state(zone))

def get_zone_states(self):
"""
Gets current states of all zones.
Gets current states of all zones/rooms.
"""

request = TadoXRequest()
Expand All @@ -116,7 +126,7 @@ def get_zone_states(self):

def get_state(self, zone):
"""
Gets current state of Zone.
Gets current state of zone/room.
"""

request = TadoXRequest()
Expand All @@ -127,7 +137,7 @@ def get_state(self, zone):

def get_capabilities(self, zone):
"""
Gets current capabilities of zone.
Gets current capabilities of zone/room.
"""

_LOGGER.warning(
Expand All @@ -139,7 +149,7 @@ def get_capabilities(self, zone):

def get_climate(self, zone):
"""
Gets temp (centigrade) and humidity (% RH) for zone.
Gets temp (centigrade) and humidity (% RH) for zone/room.
"""

data = self.get_state(zone)["sensorDataPoints"]
Expand Down
76 changes: 1 addition & 75 deletions PyTado/interface/api/my_tado.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,12 @@
import datetime
from typing import Any

from PyTado.interface.api.base_tado import Presence, TadoBase, Timetable
from PyTado.interface.api.base_tado import TadoBase, Timetable

from ...exceptions import TadoException
from ...http import Action, Domain, Endpoint, Mode, TadoRequest
from ...logger import Logger
from ...zone import TadoZone

_LOGGER = Logger(__name__)


class Tado(TadoBase):
"""Interacts with a Tado thermostat via public my.tado.com API.
Expand Down Expand Up @@ -225,32 +222,6 @@ def get_zone_overlay_default(self, zone: int):

return self._http.request(request)

def set_home(self) -> None:
"""
Sets HomeState to HOME
"""

return self.change_presence(Presence.HOME)

def set_away(self) -> None:
"""
Sets HomeState to AWAY
"""

return self.change_presence(Presence.AWAY)

def change_presence(self, presence: Presence) -> None:
"""
Sets HomeState to presence
"""

request = TadoRequest()
request.command = "presenceLock"
request.action = Action.CHANGE
request.payload = {"homePresence": presence}

self._http.request(request)

def set_child_lock(self, device_id, child_lock) -> None:
"""
Sets the child lock on a device
Expand Down Expand Up @@ -374,48 +345,3 @@ def get_running_times(self, date=datetime.datetime.now().strftime("%Y-%m-%d")) -
request.params = {"from": date}

return self._http.request(request)

def get_boiler_install_state(self, bridge_id: str, auth_key: str):
"""
Get the boiler wiring installation state from home by bridge endpoint
"""

request = TadoRequest()
request.action = Action.GET
request.domain = Domain.HOME_BY_BRIDGE
request.device = bridge_id
request.command = "boilerWiringInstallationState"
request.params = {"authKey": auth_key}

return self._http.request(request)

def get_boiler_max_output_temperature(self, bridge_id: str, auth_key: str):
"""
Get the boiler max output temperature from home by bridge endpoint
"""

request = TadoRequest()
request.action = Action.GET
request.domain = Domain.HOME_BY_BRIDGE
request.device = bridge_id
request.command = "boilerMaxOutputTemperature"
request.params = {"authKey": auth_key}

return self._http.request(request)

def set_boiler_max_output_temperature(
self, bridge_id: str, auth_key: str, temperature_in_celcius: float
):
"""
Set the boiler max output temperature with home by bridge endpoint
"""

request = TadoRequest()
request.action = Action.CHANGE
request.domain = Domain.HOME_BY_BRIDGE
request.device = bridge_id
request.command = "boilerMaxOutputTemperature"
request.params = {"authKey": auth_key}
request.payload = {"boilerMaxOutputTemperatureInCelsius": temperature_in_celcius}

return self._http.request(request)

0 comments on commit 32cacdc

Please sign in to comment.