Odd Group Behaviour

Hi All,

Using 2.3 OH stable, when I add two items into a Group, the items then show as NaN in HabPanel

I’m trying to group two items into gPowerUsage.

I can successfully display power usage using this code below when items are NOT in a group but I want to use a Group:Number:SUM function.

Im assuming once the group sum is working, I can use itemValue(‘gPowerUsage’)

<div class="widget">
			<div class="icon off"><svg viewBox="0 0 48 48"><use xlink:href="/static/matrix-theme/squidink.svg#thunder-1"></use></svg></div>
			<div class="name">Power</div>
			<div class="valueGroup">
           <div class="value">{{(itemValue('LivingRoomNum2')*1 + itemValue('KitchenNum2')*1)/10}} kW</div>
        <div class="value">{{itemValue('LivingRoomNum1')}} W (P1)</div>
        <div class="value">{{itemValue('KitchenNum1')}} W (P2)</div>
  </div>

Items:


/* Group Definitions
Group gPowerConsumption
Group gPowerUsage:Number:SUM

/* Reset ZWave Usage
Switch LivingRoomReset  { channel="zwave:device:d4900ba9:node2:meter_reset" }
Switch KitchenReset     { channel="zwave:device:d4900ba9:node4:meter_reset" }

/* ZWave Switches*/
Switch LivingRoomSw1  "Living Room"                                                       { channel="zwave:device:d4900ba9:node2:switch_dimmer1" }
Dimmer LivingRoomDim1 "Living Room [%d %%]"                                               { channel="zwave:device:d4900ba9:node2:switch_dimmer1" }
Number LivingRoomNum1 "Living Room - Current Consumption [%.1f W]"                        { channel="zwave:device:d4900ba9:node2:meter_watts1" }
Number LivingRoomNum2 "Living Room - Usage [%.1f kW]" (gPowerUsage)                       { channel="zwave:device:d4900ba9:node2:meter_kwh1" }

Switch KitchenSw1 "Kitchen"                                                               { channel="zwave:device:d4900ba9:node4:switch_dimmer1" }
Dimmer KitchenDim1 "Kitchen [%d %%]"                                                      { channel="zwave:device:d4900ba9:node4:switch_dimmer1" }
Number KitchenNum1 "Kitchen - Current Consumption [%.1f W]"                               { channel="zwave:device:d4900ba9:node4:meter_watts1" }
Number KitchenNum2 "Kitchen - Usage [%.1f kW]" (gPowerUsage)                              { channel="zwave:device:d4900ba9:node4:meter_kwh1" }


I’ve notice that saving an items file sets the states of the items in the file to NULL, even when using persistence. I don’t recall if the file I saved had items in it or groups (I have them separated). Once values came in, or a restart, everything went back to normal. This is probably a bug that should be reported. I rarely save an items file while OH is running.

Is this what you are reporting, or are you just having trouble with your widget?

I havent really got to the widget state yet, I would just assume that I replace the Item Value sum figures with a group

ie this bit:

{{(itemValue('gPowerUsage*1)/10}} kW


<div class="widget">
			<div class="icon off"><svg viewBox="0 0 48 48"><use xlink:href="/static/matrix-theme/squidink.svg#thunder-1"></use></svg></div>
			<div class="name">Power</div>
			<div class="valueGroup">
           **<div class="value">{{(itemValue('gPowerUsage*1)/10}} kW</div>**
        <div class="value">{{itemValue('LivingRoomNum1')}} W (P1)</div>
        <div class="value">{{itemValue('KitchenNum1')}} W (P2)</div>
  </div>

Reboot solved the issue, seems ill do like you said and ensure OH2 is shutdown when updating.

So, after changing my widget to the below, I get

<div class="widget">
			<div class="icon off"><svg viewBox="0 0 48 48"><use xlink:href="/static/matrix-theme/squidink.svg#thunder-1"></use></svg></div>
			<div class="name">Power</div>
			<div class="valueGroup">
           <div class="value">{{itemsInGroup(gPowerUsage)}} kW</div>
        <div class="value">{{itemValue('LivingRoomNum1')}} W (P1)</div>
        <div class="value">{{itemValue('KitchenNum1')}} W (P2)</div>
  </div>

I take it that’s no good, because the gPowerUsage value is 0? What does {{itemValue(gPowerUsage)}} give you?

I’d remove Habpanel from the equation and look in to one of the other UIs, or check the state in Karaf with smarthome:status gPowerUsage.

It should show the combined Usage total.

openhab> smarthome:status gPowerUsage
Error: Item ‘gPowerUsage’ does not exist.
openhab>

I spotted it… your group definition is no good.

Use Group:Number:SUM gPowerUsage.

1 Like

Nice spotting.

Now I just get this. It should have some usage

Did you restart after saving the file? What does Karaf say? Maybe the group needs a Label?

Seems fixing the Group shows more info now, thank Scott

openhab> smarthome:status gPowerUsage
NULL
openhab>

Null, so that would be why I’m not seeing anything!

My Items file looks like this:


/*Group Definitions*/
Group gPowerConsumption
Group:Number:SUM gPowerUsage

/*Reset ZWave Usage*/
Switch LivingRoomReset  { channel="zwave:device:d4900ba9:node2:meter_reset" }
Switch KitchenReset     { channel="zwave:device:d4900ba9:node4:meter_reset" }

/*ZWave Switches*/
Switch LivingRoomSw1  "Living Room"                                                       { channel="zwave:device:d4900ba9:node2:switch_dimmer1" }
Dimmer LivingRoomDim1 "Living Room [%d %%]"                                               { channel="zwave:device:d4900ba9:node2:switch_dimmer1" }
Number LivingRoomNum1 "Living Room - Current Consumption [%.1f W]"                        { channel="zwave:device:d4900ba9:node2:meter_watts1" }
Number LivingRoomNum2 "Living Room - Usage [%.1f kW]" (gPowerUsage)                       { channel="zwave:device:d4900ba9:node2:meter_kwh1" }

Switch KitchenSw1 "Kitchen"                                                               { channel="zwave:device:d4900ba9:node4:switch_dimmer1" }
Dimmer KitchenDim1 "Kitchen [%d %%]"                                                      { channel="zwave:device:d4900ba9:node4:switch_dimmer1" }
Number KitchenNum1 "Kitchen - Current Consumption [%.1f W]"                               { channel="zwave:device:d4900ba9:node4:meter_watts1" }
Number KitchenNum2 "Kitchen - Usage [%.1f kW]" (gPowerUsage)                              { channel="zwave:device:d4900ba9:node4:meter_kwh1" }


Cool. The group should get a state after one of the items updates its state. Or you could send one through Karaf…

smarthome:send KitchenNum2 value

openhab> smarthome:send KitchenNum2 value
Error: Command ‘value’ is not valid for item ‘KitchenNum2’
Valid command types are:
DecimalType
QuantityType
RefreshType: REFRESH
openhab>

openhab> smarthome:status KitchenNum2
0.02
openhab>

You’ll need to put a value in :wink:

smarthome:send KitchenNum2 0.02

haha!

openhab> smarthome:status KitchenNum2
55
openhab>

Still shows nothing but it could be the widget code now… when I add ’ ’ around the group name I get NaN displaying in HabPanel

<div class="widget">
			<div class="icon off"><svg viewBox="0 0 48 48"><use xlink:href="/static/matrix-theme/squidink.svg#thunder-1"></use></svg></div>
			<div class="name">Power</div>
			<div class="valueGroup">
           <div class="value">{{itemsinGroup(gPowerUsage)}} kW</div>
        <div class="value">{{itemValue('LivingRoomNum1')}} W (Living)</div>
        <div class="value">{{itemValue('KitchenNum1')}} W (Kitchen)</div>
  </div>

I’m not very current with Habpanel, but would think you’d get the group value the same as any other item.

{{itemValue(‘gPowerUsage’)}}

You’re right, I changed ItemsinGroup to ItemValue and now I get the the ‘55’ value as set :slight_smile:

Nice work Scott @5iver now to get my reset switches working correctly.

I assume I can set smarthome:send KitchenNum2 0 and then it will update as per normal?

1 Like

Still seeing some funny values. I have two switches , one reads the Usage fine and the other reads the Watts as Kilowatts.

ie: 9.1watts is showing as 9.1KW which is throwing my usage out.

They are configured the same - the item is LivingRoomNum2 (works) and KitchenNum2 (doesnt work)

openhab> smarthome:status KitchenNum2
9.1
openhab> smarthome:status LivingRoomNum2
0
openhab>

Items:

/*Group Definitions*/
Group gPowerConsumption
Group:Number:SUM gPowerUsage

/*Reset ZWave Usage*/
Switch LivingRoomReset  { channel="zwave:device:d4900ba9:node2:meter_reset" }
Switch KitchenReset     { channel="zwave:device:d4900ba9:node4:meter_reset" }

/*ZWave Switches*/
Switch LivingRoomSw1  "Living Room"                                                       { channel="zwave:device:d4900ba9:node2:switch_dimmer1" }
Dimmer LivingRoomDim1 "Living Room [%d %%]"                                               { channel="zwave:device:d4900ba9:node2:switch_dimmer1" }
Number LivingRoomNum1 "Living Room - Current Consumption [%.1f W]"                        { channel="zwave:device:d4900ba9:node2:meter_watts1" }
Number LivingRoomNum2 "Living Room - Usage [%.1f kW]" (gPowerUsage)                       { channel="zwave:device:d4900ba9:node2:meter_kwh1" }

Switch KitchenSw1 "Kitchen"                                                               { channel="zwave:device:d4900ba9:node4:switch_dimmer1" }
Dimmer KitchenDim1 "Kitchen [%d %%]"                                                      { channel="zwave:device:d4900ba9:node4:switch_dimmer1" }
Number KitchenNum1 "Kitchen - Current Consumption [%.1f W]"                               { channel="zwave:device:d4900ba9:node4:meter_watts1" }
Number KitchenNum2 "Kitchen - Usage [%.1f kW]" (gPowerUsage)                              { channel="zwave:device:d4900ba9:node4:meter_kwh1" }

kris@OpenHAB:/etc/openhab2/items$

Everything looks good to me. Did you get it sorted? If Karaf shows the correct values, you’re issue is in the widget. What does that code look like now?

Karaf doesnt show it correctly.

openhab> smarthome:status KitchenNum2 (INCORRECT)
9.1
openhab> smarthome:status LivingRoomNum2 (CORRECT, because its far less than 1 Kw)
0
openhab>

These Items reference kWh. Theres no way 1 light rated at 30watts can generate 9.1 Kw per hour. It should be 0.03 or something. So, that is throwing off my widget.


/*Group Definitions*/
Group gPowerConsumption
Group:Number:SUM gPowerUsage

/*Reset ZWave Usage*/
Switch LivingRoomReset  { channel="zwave:device:d4900ba9:node2:meter_reset" }
Switch KitchenReset     { channel="zwave:device:d4900ba9:node4:meter_reset" }

/*ZWave Switches*/
Switch LivingRoomSw1  "Living Room"                                                       { channel="zwave:device:d4900ba9:node2:switch_dimmer1" }
Dimmer LivingRoomDim1 "Living Room [%d %%]"                                               { channel="zwave:device:d4900ba9:node2:switch_dimmer1" }
Number LivingRoomNum1 "Living Room - Current Consumption [%.1f W]"                        { channel="zwave:device:d4900ba9:node2:meter_watts1" }
Number LivingRoomNum2 "Living Room - Usage [%.1f kW]" (gPowerUsage)                       { channel="zwave:device:d4900ba9:node2:meter_kwh1" }

Switch KitchenSw1 "Kitchen"                                                               { channel="zwave:device:d4900ba9:node4:switch_dimmer1" }
Dimmer KitchenDim1 "Kitchen [%d %%]"                                                      { channel="zwave:device:d4900ba9:node4:switch_dimmer1" }
Number KitchenNum1 "Kitchen - Current Consumption [%.1f W]"                               { channel="zwave:device:d4900ba9:node4:meter_watts1" }
Number KitchenNum2 "Kitchen - Usage [%.1f kW]" (gPowerUsage)                              { channel="zwave:device:d4900ba9:node4:meter_kwh1" }


See this photo, its the KitchenNum2 that does this. LIvingRoomNum2 works fine. They are kwh channels from Fibaro Dimmers. There are two of them. Identical.