Chart does not show group value

Hi,

I’m struggling with the handling of charts to show the power consumption over a day. For this purpose I want to use my Shellys. I’ve defined some groups for that and each matching shelly item contains a reference to the specific group.

But: The resulting chart does not show the trend of the aggregated value; it shows the trend for each shelly item. Now I’ve multiple series in the chart, but my idea was to have only one series (by the group).

Here is an shortened example config:

Items:

Group:Number:SUM gPowerInWattsSum "Shelly (Sum) [%.1f W]" <energy>
Group:Number:SUM gPowerInWattsSumShelly1PM "Shelly 1PM (Sum) [%.1f W]" <energy> (gPowerInWattsSum)
Group:Number:SUM gPowerInWattsSumShelly25 "Shelly 2.5 (Sum) [%.1f W]" <energy> (gPowerInWattsSum)

Number entrance_light_outdoor_north_info_watt "Entrance Power [%.1f W]" <energy> (Lights, gPowerInWattsMaxShelly1PM, gPowerInWattsSumShelly1PM, gPowerInWattsAvgShelly1PM) { channel="mqtt:topic:shelly_entrance_light_outdoor_north:watt" }
Number dining_light_mesh_info_watt "Dining Power [%.1f W]" <energy> (Lights, gPowerInWattsMaxShelly1PM, gPowerInWattsSumShelly1PM, gPowerInWattsAvgShelly1PM) { channel="mqtt:topic:shelly_dining_light_mesh:watt" }
...

Now the chart shows the series for each item, e.g. 1x entrance_light_outdoor_north_info_watt, 1x dining_light_mesh_info_watt, etc.

Does I misunderstand the behaviour of groups and functions together with charts or have I make a design bug in my configs?

Thanks in advance for ideas and hints!

Before you can chart, you’ll have to persist the Group state - don’t think that happens by default.

How are you making charts? In the sitemap syntax, asking for a Group plots a chart of all members.

The chart syntax in my sitemap:

Chart item=gPowerInWattsSumShelly1PM label="Shelly 1PM [%.1f W]" period=D legend=true

I’ve assumed that the chart simply takes the sum value(s), quite similar as when I use a text item to display the current value of that group.

Nope, when a sitemap Chart widget is given a Group type Item, it individually plots member Items for a multi-chart.
Some alternatives here -

Thank you for that hint!

I’ve tried the alternative way via virtual resp. proxy item, which should be updated via rule based on the group item. But that didn’t work. Therefore I’ve to change to another type of charts or to use another workaround - or to skip it. Maybe I simply use that chart only for habpanel (on usual monitor/tablet); the sitemap chart (with all the series) is too small for smartphone.

There’s not much to go wrong, but your details cannot be seen from here.

Yes. Because I did not get it running, I’ve removed this workaround from my files (without committing them into my git repo). But: It was solved like that:

  • Added a virtual item virtual_gPowerInWattsSumShelly1PM as proxy for the group gPowerInWattsSumShelly1PM
  • Added a new rule file with a rule to react on changes/updates on gPowerInWattsSumShelly1PM. The rule code copies the value from gPowerInWattsSumShelly1PM to virtual_gPowerInWattsSumShelly1PM
  • Changed the chart item in sitemap to virtual_gPowerInWattsSumShelly1PM

The problem was that nothing happened with that. The log file didn’t contain any errors regarding the changed items, rule and sitemap files.

After that, I’ve added a log entry into that rule. But even this log entry did not occur, i.e. the rule was never called (even when I tap on the light buttons on the wall to trigger value changes). I’ve tried it with a rule for “on update” and “on change” event. But all without success.

Well, if you show us the broken rule there may be some help to be had.
And perhaps your events.log of the Group Item changing that you expected to trigger it.

event.log is empty, but nevertheless it became interesting. I opened openhab.log with an another editor (cause of its size due to another problem). It contains some entries to the point in time where I was working on that:

2022-02-26 19:20:56.297 [INFO ] [enhab.core.model.script.helper.rules] - [helper] Copy value gPowerInWattsSumShelly1PM (Type=GroupItem, BaseType=NumberItem, Members=11, State=69.26, Label=Shelly 1PM (Sum), Category=energy, Groups=[gPowerInWattsSum])
2022-02-26 19:20:56.298 [ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID 'helper-2' failed: An error occurred during the script execution: Cannot assign a value in null context. in helper

The first entry is from loginfo in my .rule file. The second one is caused by an error in that file.

I could not recover the origin .rule file, but it was like this:

rule "blabla"
when Item gPowerInWattsSumShelly1PM changed
then
   logInfo("...")
   virtual_gPowerInWattsSumShelly1PM = gPowerInWattsSumShelly1PM
end

I’ve also tried it with another trigger (“received update” instead of “changed”).

Both items, i.e. virtual_gPowerInWattsSumShelly1PM and gPowerInWattsSumShelly1PM are declared in the corresponding items. files

events.log
If that is not a typo mistake, I would advise sorting the logging out ASAP or you won’t be able to deal with issues.

Alright, let’s see this new try. There’s not much point in showing us a half-remembered rule with several errors. We’re getting to the end of the “twenty questions”.