eclipse-archived / smarthome

Eclipse SmartHome™ project
https://www.eclipse.org/smarthome/
Eclipse Public License 2.0
864 stars 782 forks source link

Group function not properly working for groups with dimensions #5671

Closed wborn closed 6 years ago

wborn commented 6 years ago

When using groups with dimensions the group function computes an UNDEF result when creating a group containing other groups. This does work properly for groups without dimensions.

I've tested this with openHAB 2.4.0-SNAPSHOT and it is reproducible with these files (I've added a .txt extension to be able to upload them):

These are the items with dimensions from test.items:

Group:Number:Power:SUM D_SUM "Groups Sum [%d W]" <poweroutlet_us>

Group:Number:Power:SUM D_G1_SUM "Group 1 Sum [%d W]" <water> (D_SUM)
Group:Number:Power:SUM D_G2_SUM "Group 2 Sum [%d W]" <oil> (D_SUM)

Number:Power D_G1_I1 "Group 1 Item 1 [%d W]" <water> (D_G1_SUM)
Number:Power D_G1_I2 "Group 1 Item 2 [%d W]" <water> (D_G1_SUM)

Number:Power D_G2_I1 "Group 2 Item 1 [%d W]" <oil> (D_G2_SUM)
Number:Power D_G2_I2 "Group 2 Item 2 [%d W]" <oil> (D_G2_SUM)

As you can see in this screenshot the D_SUM item is not computed:

test

The D_SUM item remains undefined, see also this logging:

14:51:43.120 [INFO ] [del.core.internal.ModelRepositoryImpl] - Loading model 'test.items'
14:51:43.916 [INFO ] [del.core.internal.ModelRepositoryImpl] - Loading model 'test.rules'
14:51:43.964 [INFO ] [rthome.model.lsp.internal.ModelServer] - Started Language Server Protocol (LSP) service on port 5007
14:51:44.043 [INFO ] [del.core.internal.ModelRepositoryImpl] - Loading model 'test.sitemap'
14:51:44.385 [INFO ] [.basic.internal.servlet.WebAppServlet] - Started Basic UI at /basicui/app
14:51:44.405 [INFO ] [marthome.ui.paper.internal.PaperUIApp] - Started Paper UI at /paperui
14:51:44.437 [INFO ] [bpanel.internal.HABPanelDashboardTile] - Started HABPanel at /habpanel
14:51:50.349 [INFO ] [smarthome.event.ItemStateChangedEvent] - N_G1_I1 changed from NULL to 1
14:51:50.353 [INFO ] [smarthome.event.ItemStateChangedEvent] - N_G1_I2 changed from NULL to 2
14:51:50.354 [INFO ] [smarthome.event.ItemStateChangedEvent] - N_G2_I1 changed from NULL to 3
14:51:50.355 [INFO ] [home.event.GroupItemStateChangedEvent] - N_G2_SUM changed from NULL to 3 through N_G2_I1
14:51:50.356 [INFO ] [smarthome.event.ItemStateChangedEvent] - N_G2_I2 changed from NULL to 4
14:51:50.356 [INFO ] [home.event.GroupItemStateChangedEvent] - N_G1_SUM changed from NULL to 3 through N_G1_I1
14:51:50.357 [INFO ] [home.event.GroupItemStateChangedEvent] - N_G1_SUM changed from NULL to 3 through N_G1_I2
14:51:50.360 [INFO ] [home.event.GroupItemStateChangedEvent] - N_SUM changed from NULL to 10 through N_G1_SUM
14:51:50.363 [INFO ] [home.event.GroupItemStateChangedEvent] - N_G2_SUM changed from 3 to 7 through N_G2_I2
14:51:50.363 [INFO ] [smarthome.event.ItemStateChangedEvent] - D_G1_I1 changed from NULL to 1 W
14:51:50.364 [INFO ] [home.event.GroupItemStateChangedEvent] - D_G1_SUM changed from NULL to 1 W through D_G1_I1
14:51:50.364 [INFO ] [home.event.GroupItemStateChangedEvent] - D_SUM changed from NULL to UNDEF through D_G1_SUM
14:51:50.364 [INFO ] [smarthome.event.ItemStateChangedEvent] - D_G1_I2 changed from NULL to 2 W
14:51:50.364 [INFO ] [smarthome.event.ItemStateChangedEvent] - D_G2_I1 changed from NULL to 3 W
14:51:50.365 [INFO ] [smarthome.event.ItemStateChangedEvent] - D_G2_I2 changed from NULL to 4 W
14:51:50.365 [INFO ] [home.event.GroupItemStateChangedEvent] - D_G2_SUM changed from NULL to 7 W through D_G2_I1
14:51:50.365 [INFO ] [home.event.GroupItemStateChangedEvent] - D_G1_SUM changed from 1 W to 3 W through D_G1_I2
openhab> items list
N_SUM (Type=GroupItem, BaseType=NumberItem, Members=2, State=10, Label=Groups Sum, Category=smiley)
N_G1_SUM (Type=GroupItem, BaseType=NumberItem, Members=2, State=3, Label=Group 1 Sum, Category=water, Groups=[N_SUM])
N_G2_SUM (Type=GroupItem, BaseType=NumberItem, Members=2, State=7, Label=Group 2 Sum, Category=oil, Groups=[N_SUM])
N_G1_I1 (Type=NumberItem, State=1, Label=Group 1 Item 1, Category=water, Groups=[N_G1_SUM])
N_G1_I2 (Type=NumberItem, State=2, Label=Group 1 Item 2, Category=water, Groups=[N_G1_SUM])
N_G2_I1 (Type=NumberItem, State=3, Label=Group 2 Item 1, Category=oil, Groups=[N_G2_SUM])
N_G2_I2 (Type=NumberItem, State=4, Label=Group 2 Item 2, Category=oil, Groups=[N_G2_SUM])
D_SUM (Type=GroupItem, BaseType=NumberItem, Members=2, State=UNDEF, Label=Groups Sum, Category=poweroutlet_us)
D_G1_SUM (Type=GroupItem, BaseType=NumberItem, Members=2, State=3 W, Label=Group 1 Sum, Category=water, Groups=[D_SUM])
D_G2_SUM (Type=GroupItem, BaseType=NumberItem, Members=2, State=7 W, Label=Group 2 Sum, Category=oil, Groups=[D_SUM])
D_G1_I1 (Type=NumberItem, State=1 W, Label=Group 1 Item 1, Category=water, Groups=[D_G1_SUM])
D_G1_I2 (Type=NumberItem, State=2 W, Label=Group 1 Item 2, Category=water, Groups=[D_G1_SUM])
D_G2_I1 (Type=NumberItem, State=3 W, Label=Group 2 Item 1, Category=oil, Groups=[D_G2_SUM])
D_G2_I2 (Type=NumberItem, State=4 W, Label=Group 2 Item 2, Category=oil, Groups=[D_G2_SUM])
openhab>                                                                                     

When I remove the dimension from D_SUM the value is again computed.

sjsf commented 6 years ago

Indeed, thanks for the thorough bug report!