Group aggregation OR(ON,OFF) has state NULL

Running openHAB2.5 on openHABian buster (RPi3B+).

I want to use Group:Switch:OR(ON,OFF) group aggregation to check whether a fire alarm has any alarm set (e.g., heat alarm, smoke alarm, tamper alarm, system alarm, low battery level).

According to the Group item documentation, the state of the group defined this way can only be one of:

  1. ON if at least 1 of the group items has state ON
  2. OFF in all other situations

However, my sitemap tells me otherwise. The textual representation of the aggregation group state is ā€˜-ā€™ (which happens to be NULL) which is unexpected.

Is this a bug or an undocumented behaviour?

Hereā€™s one fire alarm (Fibaro Smoke Alarm 3) item definition:

// Group item containing all items relating to the fire alarm at AT_Attic:
Group AT_Attic_SmokeAlarm (gSmokeAlarms)
// The following line is the group aggregation that should only be ON or OFF:
Group:Switch:OR(ON,OFF) AT_Attic_SmokeAlarm_Alarm "Attic Hall Smoke Alarm [%s]" <alarm>
// The individual items linked to this fire alarm sensor are defined below:
Number:Temperature AT_Attic_SmokeAlarm_Temperature "Attic Temperature [%.1f %unit%]" <temperature> (AT_Attic_SmokeAlarm, gHome_AT_Attic, gPersist_everyChange) {
    channel="zwave:device:controller:node13:sensor_temperature"
}
Switch             AT_Attic_SmokeAlarm_Alarm_Heat    "Heat alarm"       <my_alarm> (AT_Attic_SmokeAlarm, AT_Attic_SmokeAlarm_Alarm, gHome_AT_Attic, gPersist_everyChange) {
    channel="zwave:device:controller:node13:alarm_heat"
}
Switch             AT_Attic_SmokeAlarm_Alarm_Smoke   "Smoke alarm"      <my_alarm> (AT_Attic_SmokeAlarm, AT_Attic_SmokeAlarm_Alarm, gHome_AT_Attic, gPersist_everyChange) {
    channel="zwave:device:controller:node13:alarm_smoke"
}
Switch             AT_Attic_SmokeAlarm_Alarm_System   "Hardware failure alarm"      <my_alarm> (AT_Attic_SmokeAlarm, AT_Attic_SmokeAlarm_Alarm, gHome_AT_Attic, gPersist_everyChange) {
    channel="zwave:device:controller:node13:alarm_system"
}
Switch             AT_Attic_SmokeAlarm_Alarm_Tamper   "Tamper alarm"      <my_alarm> (AT_Attic_SmokeAlarm, AT_Attic_SmokeAlarm_Alarm, gHome_AT_Attic, gPersist_everyChange) {
    channel="zwave:device:controller:node13:alarm_tamper"
}
Switch             AT_Attic_SmokeAlarm_Alarm_Battery   "Battery Low"      <lowbattery> (AT_Attic_SmokeAlarm, AT_Attic_SmokeAlarm_Alarm, gHome_AT_Attic, gPersist_everyChange, gBatteryLow) {
    channel="zwave:device:controller:node13:alarm_battery"
}
Number              AT_Attic_SmokeAlarm_Battery          "Attic Smoke Alarm: Battery Level [%.1f %%]" <battery>     (AT_Attic_SmokeAlarm, gHome_AT_Attic, gPersist_everyChange, gBattery, gBatteryLevel, gBatteryType_CR123A) {
    channel="zwave:device:controller:node13:battery-level"
}

On my sitemap I define:

	Frame label="Fire Alarms" icon="alarm" {
		Text item=AT_Attic_SmokeAlarm_Alarm icon="my_alarm"
		Default item=AT_Attic_SmokeAlarm_Alarm icon="my_alarm" labelcolor=[
			"ON"="red", "OFF"="green", "NULL"="orange", "UNDEF"="#777"
		]
	}

I have the following custom dynamic icons stored in $OPENHAB_CONF/icons/classic:

openhabian@openhab:/etc/openhab2/icons/classic$ ls -l my_alarm*
-rw-rw-r-- 1 openhabian openhabian 8510 Jan 29 16:56 my_alarm-null.png
-rw-rw-r-- 1 openhabian openhabian 3239 Jan 29 17:00 my_alarm-null.svg
-rw-rw-r-- 1 openhab    openhab    5094 Mar 11  2016 my_alarm-off.png
-rw-rw-r-- 1 openhab    openhab     261 Mar  7  2016 my_alarm-off.svg
-rw-rw-r-- 1 openhab    openhab    3256 Mar 10  2016 my_alarm-on.png
-rw-rw-r-- 1 openhab    openhab     691 Mar  7  2016 my_alarm-on.svg
-rw-rw-r-- 1 openhab    openhab    1502 Jan 29 15:55 my_alarm.png
-rw-rw-r-- 1 openhab    openhab    1299 Jan 29 15:36 my_alarm.svg
-rw-rw-r-- 1 openhab    openhab    8957 Jan 29 16:58 my_alarm-undef.png
-rw-rw-r-- 1 openhab    openhab    3239 Jan 29 16:58 my_alarm-undef.svg

Hereā€™s a screenshot of the reported states:


And here are the custom dynamic icons:

Icon State File name (dynamic icon)
my_alarm (default / fall-back) my_alarm
my_alarm-on ON my_alarm-on (Source: Wikimedia)
my_alarm-off OFF my_alarm-off (Source: Wikimedia)
my_alarm-null NULL my_alarm-null (Source: Wikimedia)
my_alarm-undef UNDEF my_alarm_undef (Source: Wikimedia - changed color in Inkscape)

No bug.
All Items, including Groups, begin life at boot time with a state NULL.
Thatā€™s the way it stays until something happens.

In the case of a group, one of the members needs to change to trigger the group aggregation function to calculate.

There is also state UNDEF which I think can be imposed on a group with a nonsense type/members/function combination.

As you hopefully donā€™t expect fire alarms to trigger very often, and battery zwave devices might not even report OFF daily, you can narrow down your interest in group state to be ā€œON or not-ONā€.
Rules, icons, texts etc. can all be set up to work in that way.

So you would rather use the following group aggregator then?

Group:Switch:OR(ON,NULL) AT_Attic_SmokeAlarm_Alarm "Attic Hall Smoke Alarm [%s]" <alarm>

Note: probably I shoud use Contact items rather than Switch items, as in:

Group:Contact:OR(OPEN,NULL) AT_Attic_SmokeAlarm_Alarm "Attic Hall Smoke Alarm [%s]" <alarm>

Itā€™s your decision,do what you like. But no, I wouldnā€™t use that rather odd aggregation. Iā€™d leave it as it was.

Example, Iā€™d have custom icons
my_alarm = green tick. Nothingā€™s ON, all is good
my_alarm-on = red warning. Eek, a fire
and maybe
my_alarm-undef= question mark. Because I wasnā€™t expecting that and itā€™s probably me that messed up.

Technically this kind of thing is best represented as a Contact i.e. ā€œsensor onlyā€. But many bindings struggle with the type, itā€™s not always practical.

I see.

However I find it strange that some bindings have difficulties with Contact items. Maybe because their states are of type OpenClosedType instead of OnOffType?

Since the smoke sensors Iā€™m using are Fibaro FGSD-002 Z-Wave devices (firmware version 3.3), Iā€™d like to know if @chris can tell whether it is okay to define the alarm items as Contact instead of Switch.

The device supports the following items -:

The alarm is defined as a Switch so you need to use this.

Okay. Iā€™ll define them as Switch then.

I wonder whether in the future these should be defined as Contact as the values are read-only.

Probably I should be using proxy items in this case.

Donā€™t forget breaking things for existing users without really good cause is frowned upon.
The weight of history is against you.

Having said that, it is technically possible for bindings to offer channels for the same data in more than one type.
Or we could imagine a channel profile that allowed type conversions.

For info, Iā€™ve opened an enhancement to introduce a base BooleanType to all of these types. This should (I think :sunglasses:) allow bindings to provide channel data in a more abstract type and allow users a bit more flexibility to choose the item type.

1 Like