eclipse-archived / smarthome

Eclipse SmartHomeā„¢ project
https://www.eclipse.org/smarthome/
Eclipse Public License 2.0
862 stars 783 forks source link

Concept for providing "derived data" in a generic way #4748

Open kaikreuzer opened 6 years ago

kaikreuzer commented 6 years ago

This week, I came across two discussions (1 and 2) about the very same topic:

There are often situations where you can "add value" to some raw data that is made available by a binding like:

The temptation for every binding developer is to simply include those as additional channels. But effectively, such logic has nothing to do with a given binding and it could be applied to any other binding that provides a location or weather data or whatever as well.

We should therefore think about a way to handle this. One option could be the use of StateProfiles, although they might not be ideal for all cases as they will always only allow a single channel as an input. Another option would be to use rule templates, which offers more flexibility, but the current workflow requires the user to create a target item upfront (so that it can be selected in the template configuration).

ThomDietrich commented 6 years ago

Hey Kai, just to cover this quickly: What about transformation services? Are StateProfiles supposed to be the successor to transformation services?

kaikreuzer commented 6 years ago

Good point - I thought about introducing a TransformationProfile, which would take similar strings as we have in the item files for the transformations. That's imho how good as it gets with the current TransformationServices as we do not have much meta-data about inputs/outputs/configs etc. on them to nicely support UIs. It might be worth to think about moving the TransformationServices into such a direction, though. So yes: We need to find some clear path between Profiles+Rules+Transformations šŸ˜¬

pgfeller commented 6 years ago

In general, how could we provide lookup services in general; e.g. the artist cover and information data lookup would be a candidate as well: https://community.openhab.org/t/lookup-missing-cover-arts-artist-info-from-lastfm/34063

Would be happy to try to help to implement the address lookup and maybe later the artist meta data lookup.

hww3 commented 6 years ago

I've been thinking about this on the derived weather data front, and sort of thought the idea of a MetaBinding might fit the need... a class of binding that could consume updates from other things/items/channels and present its own set (and potentially hiding/masking the channels that it consumes).

Also, this sort of thing might be very useful in other situations. For example, I have a number of Lutron switches that interface through a Wink hub and a binding I wrote for it. The switches themselves and the native wink UI allows it to remember the previous level, so that if you just hit the power switch, it returns to the previous level (a "double click" on the switch turns the light on full). I miss that behavior in OpenHAB and could solve it for my binding (and have, as a proof of concept, but the Paper UI widget assume a switch on means full brightness so the slider bounces back and forth)

I noticed that the z-wave binding may have a sort of hack to provide this, but it would be nice to have it as a universally available option for those that prefer that sort of behavior. I suspect it would also require some enhancements to the UI widget in order to work nicely but it gives an idea that there's a wide range of applicability for such a concept.

Anyhow, I may have gone off topic a bit with my rambling, but thought this MetaBinding concept might have merit in solving problems using a composing technique.