Group based power consumption

So in a typical home you will have several hundred power consuming devices, but for me at least I am not really interested in each device but rather groups of devices. So at least in Norway these days everyone has a smart energy meter which you can integrate into Openhab either through the Han port on the meter or through an API from your electricity company. This means we have the posibility to get the total power of the home.

So I have been reading this tutorial:

but It looks a bit overkill to create 100+ rules and 100+ Number items.
What I really would like to display is just a simple table like this

Category Items
Lights Down lights, Wall lamps
Heating/HVAC Heating in each room, Ventilation
Cooking Appliances Oven top, Oven, Fridge
Washing Appliances Washer,Dishwasher,Dryer, Robot Cleaner
Shower/Water Hot water boiler, Hair dryer
Media TV,Amplifier, Internet, Smart Speakers
Miscellaneous Tool chargers etc…

So whats the best approach to do this in Openhab? Is it posible to create a one dictionary that contains powers consumption for each device? Or is some kind of group triggers the path to take?

And how can we best display it in the basic UI?

Category Current Last hour Last 24 hours Last 7 Days Last 30 days
Lights x x x x x
Heating/HVAC x x x x x
Cooking Appliances x x x x x
Washing Appliances x x x x x
Shower/Water x x x x x
Media x x x x x
Miscellaneous x x x x x

100 + Number Items, maybe. But the Rules can be made generic. You should have only one set of Rules. Never ever copy, paste, edit to change the Item names in order to add support for a new Item. The Rules can be made generic so all you have to do is add the new Item to a Group.

Yes, you can create a Map using the Item name as the key and anything you want in the value.

Yes, Groups would be the best approach. But you will still have to put the result into a new Number Item. Also note that you may need to deal with threading which might make this a bit complicated. It depends how likely the changes are to occur really close together to the Group. Look at Design Pattern: Associated Items for how you can make a single Rule to handle all of these calculations.

The example you linked to was written before the introduction of the Member of Rule trigger.

You can’t display a chart like that in BasicUI. Your best bet is to save all these values to a database using Persistence and generate a chart like that using Grafana (it does way more than just line charts).

In HABPanel, a custom widget would need to be created.

So the idea is then to ceate a map file like this:

ItemName Watt Group
LL1 6 Light
LL2 6 Light
LL3 6 Light
LL4 6 Light
LL5 6 Light
LL6 6 Light
LL7 6 Light
LL8 6 Light
LL9 6 Light
LL10 6 Light
LL11 6 Light
LL12 6 Light
LL13 6 Light
LL14 6 Light
LL15 6 Light
LL16 6 Light
LL17 6 Light
LL18 6 Light
LL19 6 Light
LL20 6 Light
LL21 6 Light
LL22 6 Light
LL23 6 Light
LL24 6 Light
LL25 6 Light
LL26 6 Light
LL27 6 Light
LL28 6 Light
LL29 6 Light
LL30 6 Light
LL31 6 Light
LL32 6 Light
LL33 6 Light
LL34 6 Light
LL35 6 Light
LL36 6 Light
LL37 6 Light
LL38 6 Light
LL39 6 Light
LL40 6 Light
LL41 6 Light
LL42 6 Light
Livingroom_Light_Wall_Dinner 12 Light
Livingroom_Light_Wall_TV 12 Light
Livingroom_Light_Wall_FirePlace 12 Light
Livingroom_Light_Wall_Fusebox 12 Light
Livingroom_Light_Kitchen 25 Light
Livingroom_Light_Hallway 20 Light
MasterBedroom_Light_Bed 60 Light
Alexa_Bathroom 15 Media
Alexa_Bedroom 15 Media
Alexa_MasterBedroom 15 Media
Amplfier 600 Media
WashingMachine 1200 Washer

So lights are easy to figure out in the rules, they are correct values and have an item to bound to each physically light. The problem is when you only have total power meter to figure out what else is on. I need to think more about this!!