Open
Conversation
# Conflicts: # pyfritzhome/devicetypes/fritzhomeunitbase.py
Also switch to REST for some APIs while preserving aha compat using that facility.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Incomplete because I don't own a lot of devices for testing. I left out light bulbs and blinds for now, but also templates and triggers.
I hope the general architecture is alright. Retrofitting AHA-API was a slight pain but I think I got it. On the downside, the output may be different depending on the API, but I hope it's not too mich of a concern as long as you can force AHA for any given device. I did not attempt to fully unify output and class members because I anticipate that AHA API will be dropped eventually (in a few years). I wouldn't wand to severely cripple REST API support just because of ongoing AHA support.
However, I do try unify things where it's simple and worthwhile to do, especially for things that are used by HA.
The REST api does not expose flat devices anymore. Devices are comprised of one or more units, and units are comprised of one or more interfaces, although typically a device is also a (single) unit with numerous interfaces. I tried to reflect this in the code base to make future maintenance easier and less surprising. At the end of the day, most of the interesting stuff is in the interfaces.
So in a nutshell:
unchanged classes:
FritzhomeDevice* (except FritzhomeDeviceBase)
FritzhomeTrigger
FritzhomeTetmplate
modified classes:
FritzhomeDevice
FritzhomeDeviceBase
FritzhomeEntityBase
new classes
FritzhomeDeviceAHA
FritzhomeDeviceREST
FritzhomeInterface
FritzhomeMixin
FritzhomeUnit
FritzhomeUnitBase
For AHA the class hierarchy is largely unchanged, except it starts with FritzhomeDeviceAHA at the bottom.
For REST the class hierarchy does not include any of the FritzhomeDevice* classes anymore. Instead,
the hierarchy includes FritzhomeUnit and Fritzhome*Interface classes. I created the REST hierarchy first (basically from scratch). When reintegrating AHA support I figured it would be easiest to keep the related code unchanged (AHA API in FRITZ!OS is very unlikely to change and new endpoints are going to be REST-exclusive (see thermostat offset control).
Further complication comes from the two REST namespaces, overview and configuration. On the one hand, "overview" allows to get the big picture of all devicesin a single REST request. But on the other hand, only "configuration" gives full access. In the overview the "interfaces" nodes lack lack several fields (such as temperature offset).
As I said, this is very incomplete and many controls to not work yet. I want to get some general feedback on the general feedback before infesting more time.