stefan-kaestle / openhab2-addons

Add-ons for openHAB 2.x
Eclipse Public License 2.0
16 stars 1 forks source link

Create common "Service" classes that can be reused #8

Closed coeing closed 4 years ago

coeing commented 4 years ago

As I already mentioned I developed some functions inside the ShutterControlHandler that might be useful for other handlers as well.

As far as I see it, the Bosch developers separated their API by "services" instead of devices, so we should probably use the same separation to have an easy time to access the API.

For example there is a service "TemperatureLevel" which is the same for the devices "Thermostat", "Wall Thermostat" and "Climate Control". It would be bad coding to duplicate the logic in multiple handlers. So I would suggest to have one handler per device/thing and those handlers access the services the device supports. The state getting and setting happens inside the services.

As I am starting with the handler for the Thermostat, I would like to try this architecture if you support the idea. If it works out well we can use this architecture for the other handlers as well :)

coeing commented 4 years ago

The ThermostatHandler uses the new service and service state class architecture. We should use it for all future handlers as well and migrate the old handlers to it over time. This way we have a consistent way for all handlers.