Skip to content

add detection of tado generation#143

Closed
karlbeecken wants to merge 5 commits intoerwindouna:mainfrom
karlbeecken:tadox
Closed

add detection of tado generation#143
karlbeecken wants to merge 5 commits intoerwindouna:mainfrom
karlbeecken:tadox

Conversation

@karlbeecken
Copy link
Contributor

Proposed Changes

implements basic detection if the home is a V3 or X home, including tests and a new get_home function

Related Issues

part of #136

@erwindouna erwindouna added the enhancement Enhancement of the code, not introducing new features label Feb 18, 2026
@karlbeecken
Copy link
Contributor Author

My main question would be how we want to handle the slight differences between the V3 and X API going forward. Here I did something like this:

 async def get_home(self) -> Home:
        """Get the home."""
        response = await self._request(f"homes/{self._home_id}")
        obj = orjson.loads(response)

        # For Tado X, enrich the home payload from hops.tado.com.
        # The X payload provides roomCount, which maps to zonesCount in our model.
        if obj.get("generation") == TadoLine.LINE_X.value:
            try:
                x_response = await self._request(
                    f"homes/{self._home_id}",
                    endpoint=TADO_X_URL,
                )
                x_obj = orjson.loads(x_response)

                if "roomCount" in x_obj:
                    obj["zonesCount"] = x_obj["roomCount"]
                if "isHeatPumpInstalled" in x_obj:
                    obj["isHeatPumpInstalled"] = x_obj["isHeatPumpInstalled"]
                if "supportsFlowTemperatureOptimization" in x_obj:
                    obj["supportsFlowTemperatureOptimization"] = x_obj[
                        "supportsFlowTemperatureOptimization"
                    ]
            except TadoError as err:
                _LOGGER.debug(
                    "Failed to enrich Tado X home data from hops endpoint: %s",
                    err,
                )

        return Home.from_dict(obj)

But I am not sure if that is the optimal way, as I feel it could add a lot of boilerplate. Any thoughts on this?

@wmalgadey

This comment was marked as resolved.

@karlbeecken

This comment was marked as resolved.

Comment on lines +398 to +418
if obj.get("generation") == TadoLine.LINE_X.value:
try:
x_response = await self._request(
f"homes/{self._home_id}",
endpoint=TADO_X_URL,
)
x_obj = orjson.loads(x_response)

if "roomCount" in x_obj:
obj["zonesCount"] = x_obj["roomCount"]
if "isHeatPumpInstalled" in x_obj:
obj["isHeatPumpInstalled"] = x_obj["isHeatPumpInstalled"]
if "supportsFlowTemperatureOptimization" in x_obj:
obj["supportsFlowTemperatureOptimization"] = x_obj[
"supportsFlowTemperatureOptimization"
]
except TadoError as err:
_LOGGER.debug(
"Failed to enrich Tado X home data from hops endpoint: %s",
err,
)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

on one hand it will create a lot of extra code for every method and for every change in the api. I am naturally more a fan of abstraction here, but adding the complete overhead we added in PyTado seems also not the right way to solve it.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if we put this "enricher" code into its own class and then call only an "EnricherFactory" within it, which would then call the actual enricher class based on the "generation" and simply modify the current object?

Then the code is separated, we can call the enricher wherever we need it, and we don't clutter up our methods so much!

Could be a main enricher we create on first contact, because this "generation" won't change for the complete api of this home!

@wmalgadey
Copy link
Collaborator

@karlbeecken should we close this PR? in Favor of #151?

@karlbeecken
Copy link
Contributor Author

@wmalgadey we could, although iirc #151 doesn't auto-detect what the tado line of the user is, so that would be needed again. I can add that to the other PR though, I guess that'll be cleaner than trying to use this PR for that

@wmalgadey
Copy link
Collaborator

@wmalgadey we could, although iirc #151 doesn't auto-detect what the tado line of the user is, so that would be needed again. I can add that to the other PR though, I guess that'll be cleaner than trying to use this PR for that

I totally agree. so we close this PR

@wmalgadey wmalgadey closed this Mar 7, 2026
@github-actions github-actions bot locked and limited conversation to collaborators Mar 8, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

enhancement Enhancement of the code, not introducing new features

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants