Pushover refers to the missing type Object

I’ve got some rules that send warnings over pushover.
I’ve just noticed this generate some errors (openhab.log) when I save the rule in OH2.:

2017-10-12 13:50:32.814 [INFO ] [el.core.internal.ModelRepositoryImpl] - Validation issues found in configuration model 'inbraak.rules', using it anyway:                                                          
The field Tmp_inbraakRules.last_pushover refers to the missing type Object                                                                                                                                         
The field Tmp_inbraakRules.last_pushover refers to the missing type Object                                                                                                                                         
2017-10-12 13:50:32.815 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'inbraak.rules'                                                                                                             
2017-10-12 13:50:33.317 [INFO ] [el.core.internal.ModelRepositoryImpl] - Validation issues found in configuration model 'inbraak.rules', using it anyway:                                                          
The field Tmp_inbraakRules.last_pushover refers to the missing type Object                                                                                                                                         
The field Tmp_inbraakRules.last_pushover refers to the missing type Object                                                                                                                                         
2017-10-12 13:50:33.342 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model 'inbraak.rules'                                                                                                          
2017-10-12 13:50:33.964 [INFO ] [el.core.internal.ModelRepositoryImpl] - Validation issues found in configuration model 'inbraak.rules', using it anyway:                                                          
The field Tmp_inbraakRules.last_pushover refers to the missing type Object                                                                                                                                         
The field Tmp_inbraakRules.last_pushover refers to the missing type Object                                                                                                                                         
2017-10-12 13:50:33.981 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model 'inbraak.rules' 

My rules (inbraak.rules) contains following:

var string last_pushover = null
                                                                                                                                                                                                                   
rule "Activeer alarm bij het openen van een deur/venster..."                                                                                                                                                       
        when                                                                                                                                                                                                       
                Item Poort_Werkplaats changed to ON or                                                                                                                                                             
                Item Poort_Atelier changed to ON or                                                                                                                                                                
                Item Deur_Inkom changed to ON or                                                                                                                                                                  
                Item Deur_Hal changed to ON or                                                                                                                                                                     
                Item Venster_Hal changed to ON or                                                                                                                                                                  
                ...
        then                                                                                                                                                                                                       
                if (AlarmMode.state == "RED") {                                                                                                                                                                    
                        val String act_pushover=ALL_entries.members.sortBy[lastUpdate].last.name.replace('_', ' ')                                                                                                 
                        if (act_pushover != last_pushover) {                                                                                                                                                       
                                last_pushover = act_pushover                                                                                                                                                       
                                logInfo("Alarm", "De " + act_pushover + " werd geopend in alarmmodus, wordt het nog gedeactiveerd?")                                                                               
                                Thread::sleep(30000) // Een halve minuut wachten
                        if (AlarmMode.state == "RED") {      
                         ........

I’ve tried to follow another topic regarding a similar error. But couldn’t find solution.

Any suggestion how to solve this ‘warning’?

Well, this isn’t the whole rule, is it?
How to determine the error, when there isn’t all the code?

I would recommend to isolate the rule (if not yet done) to an empty file and to reduce the code to a minimum for locating the bug.
Please try to avoid Thread::sleep() for a long time (more than 100msec), this can easily be done through a timer or the expire binding.
If using strings in a comparison, please consider that both parts are strings, i.e. use

if (AlarmMode.state.toString == "RED")

but afaik this mistake is silently corrected by openHAB.

It seems the problem is with the last_pushover variable. What happens if you define it as

var String last_pushover

or

var String last_pushover = ""

Is indeed (I think) an issue with the last_pushover variable.

When I put

var string last_pushover = ""

Result:

2017-10-12 20:49:02.133 [INFO ] [el.core.internal.ModelRepositoryImpl] - Validation issues found in configuration model 'inbraak.rules', using it anyway:
The field Tmp_inbraakRules.last_pushover refers to the missing type Object
The field Tmp_inbraakRules.last_pushover refers to the missing type Object
2017-10-12 20:49:02.139 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'inbraak.rules'
2017-10-12 20:49:02.641 [INFO ] [el.core.internal.ModelRepositoryImpl] - Validation issues found in configuration model 'inbraak.rules', using it anyway:
The field Tmp_inbraakRules.last_pushover refers to the missing type Object
The field Tmp_inbraakRules.last_pushover refers to the missing type Object
2017-10-12 20:49:02.676 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model 'inbraak.rules'
2017-10-12 20:49:03.495 [INFO ] [el.core.internal.ModelRepositoryImpl] - Validation issues found in configuration model 'inbraak.rules', using it anyway:
The field Tmp_inbraakRules.last_pushover refers to the missing type Object
The field Tmp_inbraakRules.last_pushover refers to the missing type Object
2017-10-12 20:49:03.516 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model 'inbraak.rules'

When I put (or NULL)

var string last_pushover = null

Result

2017-10-12 20:51:13.607 [INFO ] [el.core.internal.ModelRepositoryImpl] - Validation issues found in configuration model 'inbraak.rules', using it anyway:
The field Tmp_inbraakRules.last_pushover refers to the missing type Object
The field Tmp_inbraakRules.last_pushover refers to the missing type Object
2017-10-12 20:51:13.608 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'inbraak.rules'
2017-10-12 20:51:14.203 [INFO ] [el.core.internal.ModelRepositoryImpl] - Validation issues found in configuration model 'inbraak.rules', using it anyway:
The field Tmp_inbraakRules.last_pushover refers to the missing type Object
The field Tmp_inbraakRules.last_pushover refers to the missing type Object
2017-10-12 20:51:14.222 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model 'inbraak.rules'
2017-10-12 20:51:14.539 [INFO ] [el.core.internal.ModelRepositoryImpl] - Validation issues found in configuration model 'inbraak.rules', using it anyway:
The field Tmp_inbraakRules.last_pushover refers to the missing type Object
The field Tmp_inbraakRules.last_pushover refers to the missing type Object
2017-10-12 20:51:14.546 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model 'inbraak.rules

And with

var string last_pushover

Result:

2017-10-12 20:51:53.278 [INFO ] [el.core.internal.ModelRepositoryImpl] - Validation issues found in configuration model 'inbraak.rules', using it anyway:
The field Tmp_inbraakRules.last_pushover refers to the missing type Object
The field Tmp_inbraakRules.last_pushover refers to the missing type Object
2017-10-12 20:51:53.278 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'inbraak.rules'
2017-10-12 20:51:53.565 [INFO ] [el.core.internal.ModelRepositoryImpl] - Validation issues found in configuration model 'inbraak.rules', using it anyway:
The field Tmp_inbraakRules.last_pushover refers to the missing type Object
The field Tmp_inbraakRules.last_pushover refers to the missing type Object
2017-10-12 20:51:53.573 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model 'inbraak.rules'
2017-10-12 20:51:53.847 [INFO ] [el.core.internal.ModelRepositoryImpl] - Validation issues found in configuration model 'inbraak.rules', using it anyway:
The field Tmp_inbraakRules.last_pushover refers to the missing type Object
The field Tmp_inbraakRules.last_pushover refers to the missing type Object
2017-10-12 20:51:53.851 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model 'inbraak.rules'

For reference, the complete rule:

var string last_pushover = null

rule "Activeer alarm bij het openen van een deur/venster..."
        when
                Item Poort_Werkplaats changed to ON or
                Item Poort_Atelier changed to ON or
                Item Deur_Inkom changed to ON or
                Item Deur_Hal changed to ON or
                Item Deur_Atelier changed to ON or
                Item Deur_Bureau changed to ON or
                Item Deur_Hobbitaire changed to ON or
                Item Venster_Bibliotheek changed to ON or
                Item Venster_V_Leefruimte changed to ON or
                Item Venster_Keuken changed to ON or
                Item Venster_L_Leefruimte changed to ON or
                Item Venster_Dressing changed to ON or
                Item Venster_Kinderkamer changed to ON or
                Item Venster_Hal changed to ON or
                Item Venster_L_Ouderkamer changed to ON or
                Item Venster_R_Ouderkamer changed to ON or
                Item Venster_Bureau changed to ON or
                Item Venster_Hobbykamer changed to ON
        then
		              if (AlarmMode.state == "RED") {
                        val String act_pushover=ALL_entries.members.sortBy[lastUpdate].last.name.replace('_', ' ')
                        if (act_pushover != last_pushover) {
                                last_pushover = act_pushover
                                logInfo("Alarm", "De " + act_pushover + " werd geopend in alarmmodus, wordt het nog gedeactiveerd?")
                                Thread::sleep(30000) // Een halve minuut wachten
                        if (AlarmMode.state == "RED") {
                                        logInfo("Alarm", "De " + act_pushover + " werd geopend in alarmmodus, even een signaaltje sturen")
                                        sendCommand ( Light_WO_HalGang, ON )
                                        Thread::sleep (2000)
                                        sendCommand ( Light_WO_HalGang, OFF)
                                        Thread::sleep (2000)
                                        sendCommand ( Light_WO_HalGang, ON )
                                        Thread::sleep (2000)
                                        sendCommand ( Light_WO_HalGang, OFF)
                                        Thread::sleep (2000)
                                        sendCommand ( Light_WO_HalGang, ON )
                                        Thread::sleep (2000)
                                        sendCommand ( Light_WO_HalGang, OFF)
                                        Sirene_Atelier_Set.sendCommand(1281)
                                        Sirene_Ouderkamer_Set.sendCommand(1281)
                                        sendCommand( Sirene_Atelier, ON )
                                        sendCommand( Sirene_Ouderkamer, ON )
                                        Thread::sleep(2000) // Enkele secondjes wachten
                                        sendCommand( Sirene_Atelier, OFF )
                                        sendCommand( Sirene_Ouderkamer, OFF )
                                        Thread::sleep(60000) // Nog een minuutje respijt?
                                        if (AlarmMode.state == "RED") {
                                                pushover ("De " + act_pushover + " werd geopend in alarmmodus!!!")
                                                logInfo("Alarm", "De " + act_pushover + " werd geopend in alarmmodus, alarm actief")
                                                Sirene_Atelier_Set.sendCommand(514)
                                                Sirene_Ouderkamer_Set.sendCommand(514)
                                                sendCommand( Sirene_Atelier, ON )
                                                sendCommand( Sirene_Ouderkamer, ON )
                                                Thread::sleep(60000)
                                                sendCommand( Sirene_Atelier, OFF )
                                                sendCommand( Sirene_Ouderkamer, OFF )
                                                }
                                        }
                                }
                        }
			end

One thing to mention is, you used discrete triggers. While that seems logical because the group trigger will trigger multiple times, the downside is, if a second contact changes to ON, the rule would also fire, because you did not take care of this. As a effect, the rule would be started maybe hundreds of times in parallel, which will end in a hanging system.

I’m pretty sure you should split the rule into following, by using a proxy item:

Group:Switch:OR(ON,OFF) ALL_entries
Switch Alarm
String AlarmItem   //set persistence for this item
Number AlarmStage

rules:

var Timer tAlarm1 = null
var Timer tAlarm2 = null
var Timer tAlarm3 = null
var Timer tAlarm4 = null
var int iCount = 7

rule "Alarm"
when
    Item ALL_entries changed to ON           // at least one alarm contact was triggered
//    Item ALL_entries received update       // uncomment if you want every alarm trigger to be logged 
then
    if(AlarmMode.state.toString == "RED") {  //Armed?
        if(Alarm.state!=ON) 
            Alarm.postUpdate(ON)             //start Alarm sequence
        if(AlarmItem.state.toString!=ALL_entries.members.sortBy[lastUpdate].last.name.replace('_', ' '))
            AlarmItem.postUpdate(ALL_entries.members.sortBy[lastUpdate].last.name.replace('_', ' ')) //get Name of Alarm Item
    }
end

rule "log alarm"
when
    Item AlarmItem changed or
    Item AlarmStage changed
then
    switch(AlarmStage.state) {
        case 1 :                   //wait for disarm
            logInfo("Alarm", "De {} werd geopend in alarmmodus, wordt het nog gedeactiveerd?",AlarmItem.state.toString)  
        case 2 :                   //disarming takes long
            logInfo("Alarm", "De {} werd geopend in alarmmodus, even een signaaltje sturen",AlarmItem.state.toString)    
        case 3 : {                 //alarm
            logInfo("Alarm", "De {} werd geopend in alarmmodus, alarm actief",AlarmItem.state.toString)                       
            pushover ("De {} werd geopend in alarmmodus!!!",AlarmItem.state.toString)
        }
    }
end

rule "Alarm off"
when
    Item AlarmMode changed
then
    if(AlarmMode.state.toString != "RED") {        //get prepared 
        Sirene_Atelier.sendCommand(OFF)            //switch sirene OFF in case of active
        Sirene_Ouderkamer.sendCommand(OFF)         //switch sirene OFF in case of active
        Sirene_Atelier_Set.sendCommand(1281)       //set Warn tone active
        Sirene_Ouderkamer_Set.sendCommand(1281)    //set Warn tone active
        Alarm.postUpdate(OFF)                      //rearm Alarm rule
        AlarmStage.postUpdate(0)                   //reset Alarm stage
        AlarmItem.postUpdate("")                   //delete Alarm Item
        tAlarm1.cancel                             //cancel running timers
        tAlarm2.cancel
        tAlarm3.cancel
        tAlarm4.cancel
        iCount = 7                                 //reset counter
    }
end

rule "Alarm stages"
when
    Item Alarm changed to ON                            //triggered once
then
    AlarmStage.postUpdate(1)
    tAlarm1 = createTimer(now.plusSeconds(30),[|        //wait for disarm
        AlarmStage.postUpdate(2)
        Light_WO_HalGang.sendCommand(ON)
        tAlarm2 = createTimer(now.plusSeconds(2),[|     //disarming takes long,
            tCount=tCount-1                             //count down from 7, every 2 seconds
            if(tCount > 2) {                            //light show
                Light_WO_HalGang.sendCommand(if(Light_WO_HalGang.state != OFF) OFF else ON)
                tAlarm2.reschedule(now.plusSeconds(2))
            }
            else if(tCount > 0) {                       //last chance, but with noise
                Light_WO_HalGang.sendCommand(OFF)
                Sirene_Atelier.sendCommand(if(Sirene_Atelier.state != ON) ON els OFF)
                Sirene_Ouderkamer.sendCommand(if(Sirene_Ouderkamer.state != ON) ON els OFF)
                tAlarm2.reschedule(now.plusSeconds(2))
            }
            else {                                      
                tAlarm3 = createTimer(now.plusSeconds(60),[| //the very last chance
                    AlarmStage.postUpdate(3)                 //alarm, now other noise
                    Sirene_Atelier_Set.sendCommand(514)
                    Sirene_Ouderkamer_Set.sendCommand(514)
                    Sirene_Atelier.sendCommand(ON)
                    Sirene_Ouderkamer.sendCommand(ON)
                    tAlarm4 = createTimer(now.plusSeconds(60),[| // but not too long...
                        Sirene_Atelier.sendCommand(OFF)
                        Sirene_Ouderkamer.sendCommand(OFF)
                    ])
                ])
            }
        ])
    ])
end

Maybe the rule “Alarm” gets triggered 20 times, the “Alarm stages” rule will only be triggered one time. If the Alarm is disarmed, the rule “Alarm off” restores all settings and stops triggered stages.
The “log alarm” rule takes care of the logging, if AlarmItem or AlarmStage changed, it will log a line.

Maybe it’s worth to overthink the whole rule, because of the mass of timers, but timers are way better than Thread::sleep()

Wtf, a little rewrite of my rule. :wink:
I’ll certainly try to test this next week (I’ll be gone for the weekend).

And I’ll try to break it down in pieces. I’ve got other rules as well with the same pushover way, and they also throw me a little warning when I save them.

ps we [=openhab (newly) users] could use a nice place with different example/templates/reference… :blush:
fe burglar alert, fire or water alarm, timebased rules…

Tutorials and Examples? :grinning:

Maybe I’ll start a war here, but that part isn’t very clear. :blush:
And we go a bit off-topic, but I’m not talking of forum topics to discuss.
When I look in there, a lot of info, a lot of text (=discussion, Q&A…), …

I was thinking of a kind of ‘database’ with fe:

  • Simple, clear, explained, working rules, items, sitemaps, configs…
  • Well organized (fe items for knx (shutter, dimmer, heating…), zwave (buttons, dimmer, sensors…), …)
  • Things that can be used to build own things.
  • Would be nice that everybody can attribute their ‘special’ things, but that somebody (like Udo in my topic here) validate (moderate?) the technical part?
  • Others can give status? fe working in OH1, OH2…
  • People can give points to it? This way, we can try some favorite rules…

ps if a moderator want to split this topic, feel free. Could maybe be a nice discussion?

1 Like

There are tons of it in this forum … and in Tutorials and Examples … and in https://github.com/openhab/openhab-distro/tree/master/features/distro-resources/src/main/resources … and in the specific bindings pages in the docs.

How would you do that with about 200 bindings and a whole bunch of different devices in each binding?

Actually that is what people here are trying to do. I must admit that sometimes it is more in depth and sometimes not, but most threads come to a solution.

Everything what was working in openHAB1 should also be working in openHAB2. For the differences see the Migration tutorial.

Just hit the like button :grinning:

I gave it a try, but seems some small errors are detected. :blush:

[71,4]: missing '}' at 'else'
[76,4]: missing '}' at 'else'

I’ve added a ‘}’ before the else, and the errors seems to went away.

Next thing to do, test it a bit. Hope I can try it this evening when I’m home… :wink:

Oops…
I’ve corrected this in my original posting.

1 Like