Rule Error null ? But it was running all the time till reboot

  • Platform information:
    • Hardware: NUC
    • OS: Ubuntu LTS OH is under a Docker Container
    • openHAB version: 2.5

Hi I have an Alexa Echo Binding Rule which I can ask alexa if there are windows open - alexa check if open or not and say yes or no …it was running very good and i dont think i made a config change.

It could be that I upgraded the OH2 Docker container anytime but I dont changed anything in the config. It was running till yesterday - now I got NULL error.

I rebooted the system open and closed any window but still got the error.

rule:

rule "Alexa - Fenster offen"
when
    Member of Amazon_Echos changed to "sind noch fenster offen"
then
val currentEcho = Amazon_Echos.members.sortBy[lastUpdate].last
    val OffeneFenster = Fenster.members.filter[ i | i.state == OPEN ].map[ label ].reduce[ s, label | s + ", " + label ]
      if(Fenster.state == OPEN)   {
currentEcho.sendCommand("Ja, folgende Fenster sind geöffnet. " + OffeneFenster)
        }
      else {
currentEcho.sendCommand("Nein alle Fenster sind zu")
      }
end

items:

//HM-Sec-SCo Tür-/Fensterkontakt optisch
Contact KZ1_Fenster_State            "Hannes Fenster [MAP(window.map):%s]"                      <contact>   (KZ1,Windows,Fenster)     {channel="homematic:HM-Sec-SC-2:NEQ0477510:NEQ1114040:1#STATE"}

// Door Window Sensor WC

Contact Fenster_WC "WC Fenster [MAP(window.map):%s]" <window> (Fenster) { channel="mihome:sensor_magnet_aq2:158d0003120f89:isOpen" }
// minimum 30 seconds
// Number WindowSwitch_AlarmTimer <clock> { channel="mihome:sensor_magnet:<GwID>:<ID>:isOpenAlarmTimer" }
DateTime WindowSwitch_LastOpened "[%1$tY-%1$tm-%1$td  %1$tH:%1$tM]" <clock-on> { channel="mihome:sensor_magnet:<GwID>:<ID>:lastOpened" }
// Number WindowSwitch_Battery <battery> { channel="mihome:sensor_magnet:<GwID>:<ID>:batteryLevel" }
// Switch WindowSwitch_BatteryLow <energy> { channel="mihome:sensor_magnet:<GwID>:<ID>:lowBattery" }

// Door Window Sensor Küche-Hof

Contact Fenster_Kueche_Hof "Kueche Fenster Hof [MAP(window.map):%s]" <window> (Fenster) { channel="mihome:sensor_magnet_aq2:158d0003132f34:isOpen" }
// minimum 30 seconds
// Number WindowSwitch_AlarmTimer <clock> { channel="mihome:sensor_magnet:<GwID>:<ID>:isOpenAlarmTimer" }
DateTime WindowSwitch_LastOpened "[%1$tY-%1$tm-%1$td  %1$tH:%1$tM]" <clock-on> { channel="mihome:sensor_magnet:<GwID>:<ID>:lastOpened" }
// Number WindowSwitch_Battery <battery> { channel="mihome:sensor_magnet:<GwID>:<ID>:batteryLevel" }
// Switch WindowSwitch_BatteryLow <energy> { channel="mihome:sensor_magnet:<GwID>:<ID>:lowBattery" }

// Door Window Sensor Küche-Terrasse

Contact Fenster_Kueche_Ter "Kueche Fenster Terasse [MAP(window.map):%s]" <window> (Fenster) { channel="mihome:sensor_magnet_aq2:158d00031b3464:isOpen" }
// minimum 30 seconds
// Number WindowSwitch_AlarmTimer <clock> { channel="mihome:sensor_magnet:<GwID>:<ID>:isOpenAlarmTimer" }
DateTime WindowSwitch_LastOpened "[%1$tY-%1$tm-%1$td  %1$tH:%1$tM]" <clock-on> { channel="mihome:sensor_magnet:<GwID>:<ID>:lastOpened" }
// Number WindowSwitch_Battery <battery> { channel="mihome:sensor_magnet:<GwID>:<ID>:batteryLevel" }
// Switch WindowSwitch_BatteryLow <energy> { channel="mihome:sensor_magnet:<GwID>:<ID>:lowBattery" }

// Door Window Sensor WZ-Hof

Contact Fenster_WZ_Hof "WZ Fenster Hof [MAP(window.map):%s]" <window> (Fenster) { channel="mihome:sensor_magnet_aq2:158d00032b874f:isOpen" }
// minimum 30 seconds
// Number WindowSwitch_AlarmTimer <clock> { channel="mihome:sensor_magnet:<GwID>:<ID>:isOpenAlarmTimer" }
DateTime WindowSwitch_LastOpened "[%1$tY-%1$tm-%1$td  %1$tH:%1$tM]" <clock-on> { channel="mihome:sensor_magnet:<GwID>:<ID>:lastOpened" }
// Number WindowSwitch_Battery <battery> { channel="mihome:sensor_magnet:<GwID>:<ID>:batteryLevel" }
// Switch WindowSwitch_BatteryLow <energy> { channel="mihome:sensor_magnet:<GwID>:<ID>:lowBattery" }

// Door Window Sensor WZ-Schiebetür

Contact Fenster_WZ_Schiebetuer "WZ Fenster Schiebetuer [MAP(window.map):%s]" <window> (Fenster) { channel="mihome:sensor_magnet_aq2:158d00032b7432:isOpen" }
// minimum 30 seconds
// Number WindowSwitch_AlarmTimer <clock> { channel="mihome:sensor_magnet:<GwID>:<ID>:isOpenAlarmTimer" }
DateTime WindowSwitch_LastOpened "[%1$tY-%1$tm-%1$td  %1$tH:%1$tM]" <clock-on> { channel="mihome:sensor_magnet:<GwID>:<ID>:lastOpened" }
// Number WindowSwitch_Battery <battery> { channel="mihome:sensor_magnet:<GwID>:<ID>:batteryLevel" }
// Switch WindowSwitch_BatteryLow <energy> { channel="mihome:sensor_magnet:<GwID>:<ID>:lowBattery" }

// Door Window Sensor WZ-Tür

Contact Fenster_WZ_Tuer "WZ Fenster Tuer [MAP(window.map):%s]" <window> (Fenster) { channel="mihome:sensor_magnet_aq2:158d000309ba5c:isOpen" }
// minimum 30 seconds
// Number WindowSwitch_AlarmTimer <clock> { channel="mihome:sensor_magnet:<GwID>:<ID>:isOpenAlarmTimer" }
DateTime WindowSwitch_LastOpened "[%1$tY-%1$tm-%1$td  %1$tH:%1$tM]" <clock-on> { channel="mihome:sensor_magnet:<GwID>:<ID>:lastOpened" }
// Number WindowSwitch_Battery <battery> { channel="mihome:sensor_magnet:<GwID>:<ID>:batteryLevel" }
// Switch WindowSwitch_BatteryLow <energy> { channel="mihome:sensor_magnet:<GwID>:<ID>:lowBattery" }


// Door Window Sensor Hannes Fenster Hof
 
Contact Fenster_Hof_Hannes "Hannes Fenster Hof [MAP(window.map):%s]" <window> (hannesfenster,Fenster) { channel="mihome:sensor_magnet_aq2:158d00031344fc:isOpen" }
// minimum 30 seconds
// Number WindowSwitch_AlarmTimer <clock> { channel="mihome:sensor_magnet:<GwID>:<ID>:isOpenAlarmTimer" }
DateTime WindowSwitch_LastOpened "[%1$tY-%1$tm-%1$td  %1$tH:%1$tM]" <clock-on> { channel="mihome:sensor_magnet:<GwID>:<ID>:lastOpened" }
// Number WindowSwitch_Battery <battery> { channel="mihome:sensor_magnet:<GwID>:<ID>:batteryLevel" }
// Switch WindowSwitch_BatteryLow <energy> { channel="mihome:sensor_magnet:<GwID>:<ID>:lowBattery" }

// MAX! Fensterkontakt

Contact maxFensterLuis "Luis Fenster [MAP(window.map):%s]" <window> (Fenster,gMaxLuis,gMaxWindow)                                      {channel="max:shuttercontact:NEQ1540669:OEQ0906849:contact_state"}

window.map:

CLOSED=geschlossen
OPEN=offen
NULL=unbekannt
UNDEF=unbekannt
-=unbekannt

persistence:

Strategies {

everyMinute : “0 * * * * ?”
everyhour : “0 0 0/1 1/1 * ? *”
every15min : “0 0/15 0 ? * * *”
}

Items {

Amazon_Echos* : strategy = restoreOnStartup, everyChange
}

Could anyone help me out or could say how to debug ?

It’s probably not going to help much more, but it would be good practice to show us the actual error. I guess you are finding this in your openhab.log?

Okay, some basics.

When openHAB starts up and creates Items, they all get a state of NULL.
That’s the way they stay until something changes them - a restore, or an update from a binding, etc.

So in the normal course of events, Items linked to battery window sensors may stay at NULL state for a long time after a reboot, until the window is opened and an update happens.

Obviously there are things you can’t do with NULL in rules, like simply adding up for example.

note that Item state NULL is not like null, the empty or void variable value in rules. Pay attention to error messages.

I can’t see an obvious problem in your rule. It filters group members by state==OPEN, so you might end up with an empty list, but that should be dealt with.

My next suspect would be that [lastUpdate]
Is there (yet) a last update to find? Is there a configured default persistence service - you’re relying on that.

If the mystery error message is not forthcoming about where in the rule the problem arises, you can diagnostically add logInfo() to follow rule progess step by step.

1 Like

What Persistence are you using I use mapdb and influxdb

map is for restore at startup

Strategies {
	default = everyChange
}
Items {
	* : strategy = everyChange, restoreOnStartup
}