Tripped Sensor Lua Code Help!!

I’m trying to get a PUSH Message to my iPhone when i get home.

I’ve installed the ping plugin and have set it up to respond to my iPhones ip address. This then trips the virtual sensor which now exists in my Vera 2 and works great. iPhone wifi on sensor tripped, iPhone wifi off sensor goes back to armed state.

I’ve the created a scene to respond to the virtual sensor and added the following lua code in the appropriate section of that scene

–iPhone

local lul_tmp = luup.variable_get(“urn:schemas-micasaverde-com:device:MotionSensor:1”,“Status”,30)

if (lul_tmp==“Tripped”) then

luup.inet.wget(“https://prowl.weks.net/publicapi/add?apikey=5b07921d1411b191a3a1654321ef833e531dej38&application=Vera&event=Message&description=Welcome+Home&priority=-1”)

end

not sure if my uup.variable_get is correct?

i have other PUSH Messages sent to my phone for weather events so i know that part works

Any help will be greatly received. ( i’ve altered the push code so above is not mine or anyone else’s)

Cheers

m0jon

You need to use a URN with the :serviceId: in it, not :device:

It’s similar to the problem that was going on here (just with a different Device and Service being used)
http://forum.micasaverde.com/index.php?topic=4907.0

From this list:
http://wiki.micasaverde.com/index.php/Luup_UPNP_Files

You want:

[ul][li]serviceId -> [tt]urn:micasaverde-com:serviceId:SecuritySensor1[/tt][/li]
[li]variable -> [tt]Tripped[/tt][/li][/ul]

Thanks guessed for your help, which has got me back on the right path.

Just having that well documented trouble with a Virtual Sensor, which is being Tripped but not triggering a scene!!!

Will keep at it and thanks again

m0jon

I am also trying to use the ping sensor.
I have it working, but do not really see how to use it in an event.
I can schedule a 1 minute timer, this works good.
But I would like to have something to happen ‘immediately’; not having to verify every minute (that delay is too big).
When creating a new scene; the ‘ping sensor device’ is not listed in the device list when selecting to add an event.

Any advice = very welcome!!! )

Ok, managed to use it now in an event! No help needed anymore (for now) :stuck_out_tongue:

Hi pepebel4

How did you get the ping sensor to trigger a scene. It just won’t work for me!!!

I modifed the D_PingSensor.xml.
I added after the devicetype :

urn:schemas-micasaverde-com:device:MotionSensor:1
D_MotionSensor1.json

Adding this line enables the device to be selected when creating a scene.
Hope that works out for you too.
Tested this evening; works perfect! When I come home in the evening with my iPad; my home welcomes
me with turning on the lights:) Cheaper then a motion sensor (taken into account you already have an iphone/ipad :stuck_out_tongue: :stuck_out_tongue: )

Thanks a lot pepebel4 that extra line of code did the trick and the sensor is now triggering scenes.

Cheers

M0jon

This solution is now working.
Thanks for sharing this info

Marco

Can someone point me into the right direction. I really appropriate it.

I have create 2 ping sensors and 2 scenes. Ip adresses are stated to the computers at our office.

When the ping sensor is tripped ( this mean the computer is turn on) , a event is trigger and will enable the printers and heating at the office. This works really good.

Now I want a step further. When both pc’s are not used and turned off I want to shut even shut down the printers.

So would it be possible to create a luup code witch is checking both computers at the office of there are present at the network. When both are not present( i will amuse the are powered off ) then send a off command to the printers.

something like this :

-ping sensor 1 is not tripped AND -ping sensor 2 is not tripped
Then power off printers.

[sup]local lul_tmp = luup.variable_get(“urn:schemas-micasaverde-com:serviceId:MotionSensor:1”,“Status”,1)

if (lul_tmp==“Tripped”) then goto end

else
local lul_tmp = luup.variable_get(“urn:schemas-micasaverde-com:serviceId:MotionSensor:1”,“Status”,2)
if (lul_tmp==“Tripped”) then goto end
else “Power down printers”

Endif[/sup]

Many thanks in advance
Marco

[sub]local lul_tmp = luup.variable_get(“urn:schemas-micasaverde-com:serviceId:MotionSensor:1”,“Status”,1)

if (lul_tmp==“Tripped”)
then
else
local lul_tmp = luup.variable_get(“urn:schemas-micasaverde-com:serviceId:MotionSensor:1”,“Status”,2)

	if (lul_tmp=="Tripped") 
	then
	else 
		luup.call_action("urn:upnp-org:serviceId:SwitchPower1","SetTarget",{ newTargetValue="0" },7)

end[/sub]

IS this correct …?
Regards Marco

See my post above, and check the exact ServiceId used. It’s important. :wink:

Hi Guessed,

Thanks for the very quick response.

See picture , i suppose the ServiceID would be the Id nr…?
correct ?

Regards,
Marco

That’s a Device Type, not a Service Id. A device has one Device Type, but can have (implement) multiple Serviced Id’s.

You’ll want to read my post 2nd from the top, it lists the exact Service Id to use.

Hi Guessed,

Can you help me please into the right direction.
I have read you’re post ( before you pointed me) and i don’t get this.

Normally when you have a device , the have a 1 device type and 1 service ID

What I suspect would be something like this :
[sub]local lul_tmp = luup.variable_get(“urn:schemas-micasaverde-com:serviceId:MotionSensor1”,“Status”,62)[/sub]

Thanks
Marco

Normally, yes, but that’s a degenerate case. Imagine a remote-controlled power board, with three individually-controllable appliance switches in it. One device, three on-off services. Each service would have a “Status” variable, so how would your program get the status of switch #3?

The way it’s done is that each switch has its own Service ID. Same Service type, different Service ID:

  • Switch 1: Service type urn:schemas-upnp-org:service:SwitchPower:1, Service ID urn:upnp-org:serviceId:SwitchPower1
  • Switch 2: Service type urn:schemas-upnp-org:service:SwitchPower:1, Service ID urn:upnp-org:serviceId:SwitchPower2
  • Switch 3: Service type urn:schemas-upnp-org:service:SwitchPower:1, Service ID urn:upnp-org:serviceId:SwitchPower3

That’s why you need to provide the Service ID of the variable that you’re interested in. If you like, you can think of the ServiceID and VariableName as a two-part primary key. Both are needed to get or set a variable uniquely.

Go back to the Advanced tab in UI4 and hover the mouse pointer over the variable name (“Status”). Up pops some hover text. That’s the service ID, and it’s needed to query or set that variable’s value.

Hi Fuzzle,

That make sense to me , so this is a little step further.

Only looking for the “hover text” and there is nothing pops up within a text in the advance screen.
(see picture).

Can you help me with direction i must take a look …?

Many thanks in advance
Marco

[quote=“mversluis, post:17, topic:167050”]Only looking for the “hover text” and there is nothing pops up within a text in the advance screen.
(see picture).[/quote]

Scroll to the bottom where the true Luup variables are. Put the mouse pointer right on top of one of the words on the left.

This may be browser-dependent; I am using Firefox 3.6.

Oke found,

Thanks for pointed me that way. [sub]( Its a little mess code , there are 3 or 4 different serviceid used for the pingsensor)[/sub]
I will need to have the Tripped variable and that will use SecuritySensor1

Other question , to check of I will get the way of work :

[System variable] [serviceId] [status],[Device id]
local lul_tmp = luup.variable_get(“urn:schemas-micasaverde-com:serviceId:SecuritySensor1”,“Tripped”,62)

Is This correct :

Tripped return a value with the current state of te device.
with error levels can those have :
0 = sensor not tripped
1= sensor Tripped

Am I correct …?

What about “Status” , with values will be return by that funtion ?
What about “Armed” , with value will be return by that …?

Many thanks in advance
Marco

For ‘Armed’ see http://wiki.micasaverde.com/index.php/Luup_Scenes_Events#Arm_motion_sensor_.237 and http://wiki.micasaverde.com/index.php/Luup_Scenes_Events#Disarm_motion_sensor_.237.

‘Status’ for switches: 0 or 1

‘Status’ for locks: ?