This feels like something I shouldn’t ask a web community about, it feels much more like something I should ‘man up’ and learn about before asking for help. But I’ve really struggled to find the resources that can help me understand this one.
OK. I’ve got all my items set up now. Working as they should be. I’m super happy and excited that openHAB is so cool.
And now I’m trying to write my first rule. And I’m stuck.
What I’ve been trying to do for about 3 years is control my lights based on the state of my alarm. It’s a pretty rock solid measure of ‘presence’!
So, I thought I’d start off by writing a rule to send me an email whenever the ‘armed’ state of my alarm changes. Just so I can see how and if it’s working. And then I’ll modify the rule to get it to actually do something once I’m convinced it’s working right.
So, I have this at the moment:
> import org.openhab.core.library.types.DecimalType
> import org.openhab.core.library.types.*
> import org.openhab.model.script.actions.*
> import java.lang.Math
> rule "Alarm Armed"
> when Item PARTITION1_ARM_MODE received update
> then
> if(PARTITION1_ARM_MODE==0) {
> logInfo("Alarm","Partition Ready")
> val message = "Alarm change of state\n\nReady\n\nRegards,\n\nopenHab"
> sendMail("something@gmail.com", "Alarm Change of State", message)
> }
>
> if(PARTITION1_ARM_MODE==1) {
> logInfo("Alarm","Partition Armed AWAY")
> val message = "Alarm change of state\n\nArmed Away\n\nRegards,\n\nopenHab"
> sendMail("something@gmail.com", "Alarm Change of State", message)
> }
> if(PARTITION1_ARM_MODE==2) {
> logInfo("Alarm","Partition Armed STAY")
> val message = "Alarm change of state\n\nArmed Stay\n\nRegards,\n\nopenHab"
> sendMail("something@gmail.com", "Alarm Change of State", message)
> }
> if(PARTITION1_ARM_MODE==3) {
> logInfo("Alarm","Partition Armed AWAY no delay")
> val message = "Alarm change of state\n\nArmed Stay\n\nRegards,\n\nopenHab"
> sendMail("something@gmail.com", "Alarm Change of State", message)
> }
> if(PARTITION1_ARM_MODE==4) {
> logInfo("Alarm","Partition Armed STAY no delay")
> val message = "Alarm change of state\n\nArmed Stay\n\nRegards,\n\nopenHab"
> sendMail("something@gmail.com", "Alarm Change of State", message)
> }
> end
I can’t seem to find any decent documentation on imports, so I’m firing into the dark there. When I change the state of the alarm I get no logging, no errors, no email. Despite the log saying Loading model 'alarm.rules'
on startup.
So I’m clearly missing something major here, and I’m getting a sore head from scratching. I’d love to even see an error!
Thanks for reading.