Apologies. I seem to have posted in the wrong section by mistake. Please move to the Beginners section.
I’m using OpenHAB2. I currently have the room temperature displayed for each room. I would like to be able to track the average temperature during the days and weeks and use charts to display them. Where do I start?
Edit: Just thought I’d add that I’ve had a look at the demo settings for the outside temperature but can’t actually understand how to turn the temperature reading under “bedroom” to display the current temperature but also act as a button to a sub-menu where I can see the min, max and chart.
There are several approaches depending on what you want to use for charting. To use the built in OH charting mechanism you need to:
create an Item to store the average
create a rule that triggers whenever any of the other temperatures change and recalculate the average, posting the result to the new Item
put all the temperatures in the same group
chart the group
Given the following Items:
Group gAllTemps
Number BedroomTemp (gAllTemps)
Number KitchenTemp (gAllTemps)
...
Number AverageTemp (gAllTemps)
Your rule will look something like:
rule "Update Average"
when
Item gAllTemps received update
then
val Number sum = gAllTemps.members.map[t|t.state as Number].reduce[sum, t| sum + t]
val Number avg = sum / gAllTemps.size
AverageTemps.postUpdate(avg)
end
NOTE: I just typed in the above. I’m not 100% certain I got the map/reduce right.
Note, as someone who has lived with home automation for quite some time, might I recommend a flatter and more functional arrangement on your sitemap. If you have to dig down that deep to turn off a light this would be a home automation fail in my book. Also, I find that when I want to see charts and status of devices, I care about more than one room at a time so having them all on the same “page” in the sitemap works way better.
In general, from a usability perspective, if it takes more than two clicks/taps to get to a control or a screen it is not user friendly.
Thanks @rlkoshak. While this worked, the other items that belong to the group (first floor) have disappeared. I could manually add (Bedroom, Coridor etc) but that means I would have to not only add the individual rooms on that floor but also all the items within them. Is there a way to simply modify just one of the sub items such as the bedroom temperature?
Nope. If you use Groups you only get the default settings as defined on that Item and the default icons. If you want to modify any one parameter or insert another element (e.g. a Chart) you have to list all the Items individually on the sitemap.
It is one of the primary reasons I find using Groups on the sitemap to be relatively unuseful.