Skip to content

Commit

Permalink
changes to make tado x devices compatible with old tado devices
Browse files Browse the repository at this point in the history
  • Loading branch information
wmalgadey committed Dec 28, 2024
1 parent 71849f4 commit 6c0a938
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions PyTado/interface/api/hops_tado.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import logging
from typing import Any

from PyTado.const import TYPE_HEATING

from ...exceptions import TadoNotSupportedException
from ...http import Action, Domain, Http, Mode, TadoRequest, TadoXRequest
from ...logger import Logger
Expand Down Expand Up @@ -81,6 +83,13 @@ def get_devices(self):
request.device = serial_number
device.update(self._http.request(request))

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

if "otherDevices" in rooms_and_devices:
devices.append(rooms_and_devices["otherDevices"])

Expand Down Expand Up @@ -111,7 +120,12 @@ def get_zone_states(self):
request = TadoXRequest()
request.command = "rooms"

return self._http.request(request)
rooms_ = self._http.request(request)

# make response my.tado.com compatible
zone_states = {"zoneStates": {"id": room["id"], "name": room["name"]} for room in rooms_}

return {**zone_states, **rooms_}

def get_state(self, zone):
"""
Expand All @@ -124,12 +138,17 @@ def get_state(self, zone):

return data

@not_supported("This method is not currently supported by the Tado X API")
def get_capabilities(self, zone):
"""
Gets current capabilities of zone.
"""
pass

_LOGGER.warning(
"get_capabilities is not supported by Tado X API. "
"We currently always return type heating."
)

return {"type": TYPE_HEATING}

def get_climate(self, zone):
"""
Expand Down

0 comments on commit 6c0a938

Please sign in to comment.