We have moved at community.getvera.com

Author Topic: Newbie...door notification code structure  (Read 3066 times)

Offline Intrepid

  • Hero Member
  • *****
  • Posts: 536
  • Karma: +4/-0
Newbie...door notification code structure
« on: May 05, 2011, 09:43:06 pm »
I have 4 HRDS1 sensors.  I have prowl notifications for each door opened or closed, so 8 scenes.

I was able to get that cut in half using the following one scene for opened or closed (event triggers: door opened or door closed):

Code: [Select]

local  Door1status= luup.variable_get("urn:micasaverde-com:serviceId:SecuritySensor1", "Tripped", 28)

if (Door1status == "1")  then

luup.inet.wget("https://prowl.weks.net/publicapi/add?apikey=12345678&application=Vera&event=front_door&description=opened&priority=-1")

else luup.inet.wget("https://prowl.weks.net/publicapi/add?apikey=12345678&application=Vera&event=front_door&description=closed&priority=-1")

 
end

How can I do all 4 doors, opened or closed, with one scene?   Newbie-friendly help, please!  ;-)


Offline oTi@

  • Community Beta
  • Master Member
  • ******
  • Posts: 4041
  • Karma: +32/-6
  • UI what ?!
Re: Newbie...door notification code structure
« Reply #1 on: May 05, 2011, 10:10:42 pm »
How can I do all 4 doors, opened or closed, with one scene?   Newbie-friendly help, please!  ;-)
Set up an event for each case.

Front door closed:
Events -> Device: pick the the front door sensor -> Trigger: An armed sensor is tripped -> Tripped? No
Back to Events
Luup event:
Code: [Select]
luup.inet.wget("https://prowl.weks.net/publicapi/add?apikey=12345678&application=Vera&event=front_door&description=closed&priority=-1")

Front door opened:
Events -> Device: pick the the front door sensor -> Trigger: An armed sensor is tripped -> Tripped? Yes
Back to Events
Luup event:
Code: [Select]
luup.inet.wget("https://prowl.weks.net/publicapi/add?apikey=12345678&application=Vera&event=front_door&description=opened&priority=-1")

Add additional events for other doors.

(Note: tested the above with Aeon sensor, not Hawking.)



« Last Edit: May 05, 2011, 10:19:56 pm by oTi@ »
Dezwaved at the moment...

Offline Intrepid

  • Hero Member
  • *****
  • Posts: 536
  • Karma: +4/-0
Re: Newbie...door notification code structure
« Reply #2 on: May 06, 2011, 09:39:02 pm »
Yep, that does it.  I did not realize until recently that (1) you could have multiple OR triggers per scene, or that (2) you could assign a script to each trigger.

But, for future reference, how would a single nested if/then/else look to do something like this task?