Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

das interessiert mich #1

Open
HaikoKurt opened this issue Nov 27, 2023 · 7 comments
Open

das interessiert mich #1

HaikoKurt opened this issue Nov 27, 2023 · 7 comments

Comments

@HaikoKurt
Copy link

Hallo Jörg, eine Python Bibliothek zum Ansprechen der lokalen REST API von free@home fände ich sehr spannend. hast Du schon einen Plan für die Funktionalität? Wenn ich kann, unterstütze ich gerne. Viele Grüße

@derjoerg
Copy link
Owner

Hi,
ja einen habe ich :) Ich merke nur gerade auf der Arbeit, dass wieder das Jahresende vor der Tür steht und somit alles mögliche noch fertig werden muss. Und dann hätte ich noch zwei kranke Kinder im Angebot ...
Meinen Plan skizziere ich mal in einem eigenem Kommentar in Englisch, falls auch noch ein paar "Auswärte" Interesse haben

@derjoerg
Copy link
Owner

I'm pretty new to the python programming language but have a good knowledge in programming in general and in OOP.

My inspiration for the upcoming free@home local API comes from https://github.com/frenck/python-wled.

From a python perspective I want to set everything up in an async-manner, from an OOP perspective I plan to use the principle of least knowledge and the factory pattern. So what does this mean (at least from my point of view):

  • A SysAP object consists of Devices, a Device object consists of Channels, a Channel object consists of Inputs and Outputs

  • By pulling the complete configuration through the REST-API, the initial information helps to create a SysAP object identified by its ID (normally 0000-000-...).

  • The SysAP object only knows that it has Devices, so it iterates over all Devices and "feed" a DeviceFactory with each device config.

  • The DeviceFactory is responsible to instantiate the Device object (identified by serialnumber) and can be used to sort out unwanted/unneeded Devices from being created (e.g. Hue, Sonos, ...).

  • The Device object only knows that it has Channels, so it iterates over all Channels and "feed" a ChannelFactory, with each channel config.

  • The ChannelFactory is responsible to instantiate the specific Channel object (identified by channel-number) based on the FunctionId (e.g. Switch, Dimmer, Weatherstation, ...). As with the DeviceFactory the ChannelFactory can be used to sort out unwanted/unneeded channels.

  • The Channel object only knows that it has Inputs and Outputs and it holds the information, which Input to activate to e.g. turn a switch on, so it iterates over all Inputs/Outputs and "feed" a DatapointFactory, with each datapoint config.

  • The DatapointFactory (perhaps separated in Input and Output) is responsible to instantiate the specific Datapoint object (identified by datapoint-number) based on the PairingId. As with all the other Factory classes it can be used to sort out unwanted/unneeded datapoints.

  • The base class of all Input objects will hold the necessary logic to construct the REST-API call for modifying a value and put this in a queue.

  • The base freeathome object listens to this queue and execute each call against the SysAP Host.

Also the freeathome object opens a websocket to listen to all change events from the SysAP and forward all messages to the SysAP, which will forward it to the specific Device, which will forward it to the specific Channel, which will forward it to the specific Output datapoint.

That is - at least for now - my plan, which I hope to start soon with. For sure the SysAP also has a floorplan, but this is "easy".

I have the expectation, that through the use of the Factory classes, especially the development should be simplified as it should be possible to concentrate on specific use cases (e.g. only Weatherstation, only Switch).

For now I still have two "big" questionmarks:

  • What does paramID means and what it is used for?
  • How to interact with a Trigger-Channel (functionID 45)?

If this sounds wrong or if someone has a better idea I'm happy to discuss.

@HaikoKurt
Copy link
Author

This is a very good and ambitious plan. I try to implement a rather minimalistic bottom-up approach in my own repository. Maybe we can benefit each other. Here is the link to my repository: HaikoKurt/sysap (just beginning and work in progress)

@HaikoKurt
Copy link
Author

What does paramID means and what it is used for?

Do you mean the pairingID?

@derjoerg
Copy link
Owner

derjoerg commented Dec 6, 2023

What does paramID means and what it is used for?

Do you mean the pairingID?

No. Each device and channel also has a field called "parameters" and there are parXXXX key-value pairs in them. In general I understand the meaning when looking at https://github.com/Busch-Jaeger/node-free-at-home/blob/master/src/parameterIds.ts, but some "descriptions" are not really intuitive and I e.g. don't know if they are changeable through the REST-API and so on

@HaikoKurt
Copy link
Author

I understand this in such a way that some devices have additional parameters that can be set from the outside. For example, the brightness of the lamps in the switches. Which parameters are present depends on device.

@alexxx113
Copy link

A very interesting idea with the implementation of RestAPI. if it was possible to try https://github.com/derjoerg/ha_freeathome_local . That would be cool! Please do it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants