APEXIS IP CAM , HSP02

Hi mates
Newbe from France here :slight_smile:

My first script is very simple , I’d like to arm my APEXIS CAM for 90sec , when my sensor is triggered.
Here is my script ,seems wrong :

local SENSOR = 7 – The door/window sensor device number

local SES_SID = “urn:micasaverde-com:serviceId:SecuritySensor1”

local Tripped = luup.variable_get(SES_SID, “Tripped”, SENSOR)

if (Tripped == “1”) – Si le detecteur detecte qque chose alors
then

luup.inet.wget(‘http://192.168.1.9:80/set_alarm.cgi?motion_armed=1&mail=1&user=USER&pwd=MYPASSWORD’)

end

local SENSOR = 7 – The door/window sensor device number

local SES_SID = “urn:micasaverde-com:serviceId:SecuritySensor1”

local period = 90 – Duree de desactivation cam

function checkLastTrip()
local LastTrip = luup.variable_get (SES_SID, “LastTrip”, SENSOR) or os.time()
if (os.difftime (os.time(), tonumber (LastTrip)) >= period) then
luup.inet.wget(‘http://192.168.1.9:80/set_alarm.cgi?motion_armed=0&mail=0&user=USER&pwd=MYPASSWORD’) --Arret surveillance CAM

else
	luup.call delay ("checkLastTrip", period) ? Check when the sensor was last tripped every <period> seconds
	end
end

luup.call_delay (“checkLastTrip”, period)

return true

Getting mad on this script :cry:

Any help appreciated

SENSOR = 7
SES_SID = "urn:micasaverde-com:serviceId:SecuritySensor1"
period = 90

function checkLastTrip()
    local LastTrip = luup.variable_get (SES_SID, "LastTrip", SENSOR) or os.time()
    if (os.difftime (os.time(), tonumber (LastTrip)) >= period) then
        luup.inet.wget('http://192.168.1.9:80/set_alarm.cgi?motion_armed=0&mail=0&user=USER&pwd=MYPASSWORD')
    else
        luup.call_delay ("checkLastTrip", period)
    end
end

local Tripped = luup.variable_get(SES_SID, "Tripped", SENSOR)
if (Tripped == "1") then
    luup.inet.wget('http://192.168.1.9:80/set_alarm.cgi?motion_armed=1&mail=1&user=USER&pwd=MYPASSWORD') 
end
luup.call_delay ("checkLastTrip", period)
return true

Thank you very much Richard !! You re very quick !!

I got no errors now testing in “test luup code” , but it seems it has no effect on the camera.
The URL command is ok , I tested it in browser (any)…

Any idea ? I got FOSCAM too ,but none is working at the moment (still in the box)…
Regards
RIKE

You can add a luup.log(“I Made it”)
just before or after the Web call.

The see if get there in the log.

You can monitor the log with:

http://Your.Vera.IP.Address/cgi-bin/cmh/log.sh?Device=LuaUPnP

BINGO !!

I made a mistake : there are two LUUP tab , one in the trigger you use to start a scene ,and another one at the top of the page : “device triggers luup advanced”
I tried each time to place my luup code in the last one ,then realise ,there was another tab called luup event.

I dont really know the meaning of all this ,but now ,my vera is less useless ;D

Thanx again Richard , you saved my holiday :wink:

If you only have one trigger … it does not matter which one you put it in.

The Sequence of events for running a Scene:

  1. If Trigger …
    If Trigger has LUA Code
    If LUA code returns false … Stop here!
  2. If Scene has LUA Code
    If LUA code returns false … Stop here!
  3. Run all of the immediate actions for the Scene.
  4. If there are delayed actions … Sleep then run the delayed actions … do this for all delays.