Author Topic: Code help needed  (Read 1679 times)

Offline JOD

  • Hero Member
  • *****
  • Posts: 1973
  • Karma: +4/-0
Code help needed
« on: September 25, 2011, 06:49:14 pm »
How would the below code get converted to monitor the arm/bypass state of 2 Ping Sensors?

Code: [Select]
local Switch1 = 147
local Switch2 = 157
 
local  Light1State= luup.variable_get("urn:upnp-org:serviceId:SwitchPower1","Status", Switch1)
 
local  Light2State= luup.variable_get("urn:upnp-org:serviceId:SwitchPower1","Status", Switch2)
 
if (Light1State == "1") or (Light2State == "1")
then
    return false
else

JOD.
I'm sorry, my responses are limited. You must ask the right questions.

Offline oTi@

  • Master Member
  • *******
  • Posts: 4041
  • Karma: +32/-6
  • UI what ?!
Re: Code help needed
« Reply #1 on: September 25, 2011, 07:06:33 pm »
How would the below code get converted to monitor the arm/bypass state of 2 Ping Sensors?

Have you played with the following, taken from the wiki?

Code: [Select]
...
local SS_SID = "urn:micasaverde-com:serviceId:SecuritySensor1" -- Security Sensor Service ID
local armed = luup.variable_get (SS_SID, "Armed", deviceNo)
if (armed == "1") then
...
« Last Edit: September 25, 2011, 07:08:49 pm by oTi@ »
Dezwaved at the moment...

Offline JOD

  • Hero Member
  • *****
  • Posts: 1973
  • Karma: +4/-0
Re: Code help needed
« Reply #2 on: September 25, 2011, 07:16:42 pm »
I've tried so many combinations I'm more confused now than when I started.

I need: When two sensors are in bypass, don't run the scene.

JOD.
I'm sorry, my responses are limited. You must ask the right questions.

Offline oTi@

  • Master Member
  • *******
  • Posts: 4041
  • Karma: +32/-6
  • UI what ?!
Re: Code help needed
« Reply #3 on: September 25, 2011, 07:30:42 pm »
I've tried so many combinations I'm more confused now than when I started.

:) Have you attempted something along the following untested lines?

Code: [Select]
local SS_SID = "urn:micasaverde-com:serviceId:SecuritySensor1"
local armedState1 = luup.variable_get (SS_SID, "Armed", <dev1>)
local armedState2 = luup.variable_get (SS_SID, "Armed", <dev2>)
if (armedState1 == "0") and (armedState2 == "0") then
  return false
else
  return true
end
Dezwaved at the moment...

Offline JOD

  • Hero Member
  • *****
  • Posts: 1973
  • Karma: +4/-0
Re: Code help needed
« Reply #4 on: September 25, 2011, 07:34:17 pm »
That worked.

Thanks oTi@

JOD.
« Last Edit: September 25, 2011, 07:48:48 pm by JOD »
I'm sorry, my responses are limited. You must ask the right questions.