We have moved at community.getvera.com

Author Topic: Tripped Sensor Lua Code Help!!  (Read 13451 times)

Offline futzle

  • Beta Testers
  • Master Member
  • *****
  • Posts: 3260
  • Karma: +192/-9
Re: Tripped Sensor Lua Code Help!!
« Reply #15 on: December 24, 2010, 06:05:05 am »
Normally when you have a device , the have a 1 device type and 1 service ID

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.

Offline mversluis

  • Jr. Member
  • **
  • Posts: 51
  • Karma: +0/-0
Re: Tripped Sensor Lua Code Help!!
« Reply #16 on: December 24, 2010, 06:38:33 am »
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
An optimist is a person who sees only the lights in the picture,
 Whereas a pessimist sees only the shadows.  An idealist, however is one who sees the light and the shadows, but in addition sees something else:  the possibility of changing the picture, of making the light prevail over shadows.

Offline futzle

  • Beta Testers
  • Master Member
  • *****
  • Posts: 3260
  • Karma: +192/-9
Re: Tripped Sensor Lua Code Help!!
« Reply #17 on: December 24, 2010, 03:31:56 pm »
Only looking for the "hover text" and there is nothing pops up within a text in the advance screen.
(see picture).

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.

Offline mversluis

  • Jr. Member
  • **
  • Posts: 51
  • Karma: +0/-0
Re: Tripped Sensor Lua Code Help!!
« Reply #18 on: December 25, 2010, 03:47:26 am »
Oke found,

Thanks for pointed me that way. ( Its a little mess code , there are 3 or 4 different serviceid used for the pingsensor)
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
An optimist is a person who sees only the lights in the picture,
 Whereas a pessimist sees only the shadows.  An idealist, however is one who sees the light and the shadows, but in addition sees something else:  the possibility of changing the picture, of making the light prevail over shadows.

Offline Ap15e

  • Beta Testers
  • Hero Member
  • *****
  • Posts: 1998
  • Karma: +12/-0

Offline mversluis

  • Jr. Member
  • **
  • Posts: 51
  • Karma: +0/-0
Re: Tripped Sensor Lua Code Help!!
« Reply #20 on: December 26, 2010, 08:58:24 am »
Totally lost  ???

I just followed everything here is stated to make the ping sensor work in a luup code.
But nothing will work.

Now I have used this code :

local lul_tmp = luup.variable_get("urn:schemas-micasaverde-com:serviceId:SecuritySensor1","Tripped",62)

if (lul_tmp=="0")

then luup.call_action("urn:upnp-org:serviceId:SwitchPower1","SetTarget",{newTargetValue="0"},61)
end


And still no result.

Is there some misspelt into my code , or just something other ..?

Many Thanks for you're help.
Marco
An optimist is a person who sees only the lights in the picture,
 Whereas a pessimist sees only the shadows.  An idealist, however is one who sees the light and the shadows, but in addition sees something else:  the possibility of changing the picture, of making the light prevail over shadows.

Offline Ap15e

  • Beta Testers
  • Hero Member
  • *****
  • Posts: 1998
  • Karma: +12/-0
Re: Tripped Sensor Lua Code Help!!
« Reply #21 on: December 26, 2010, 10:29:59 am »
urn:micasaverde-com:serviceId:SecuritySensor1

Offline mversluis

  • Jr. Member
  • **
  • Posts: 51
  • Karma: +0/-0
Re: Tripped Sensor Lua Code Help!!
« Reply #22 on: January 03, 2011, 04:05:38 pm »
Totally confused.
I hope someone is able to help me ....... ???

I use this code :
local lul_tmp = luup.variable_get("urn:micasaverde-com:serviceId:SecuritySensor1","Tripped",62)

if (lul_tmp=="0")

then local lul_tmp1 = luup.variable_get("urn:micasaverde-com:serviceId:SecuritySensor1","Tripped",63)

if (lul_tmp1=="0")

then luup.call_action("urn:upnp-org:serviceId:SwitchPower1","SetTarget",{newTargetValue="0"},61)

end

end


When both pc running at the office are powered down , the ping sensor is not tripped.
When I run the scene manual , the switch will go off . So I will assume the scene is working.

I have added a timer , witch is running every hour to check the pc's are not running any more and will switch off the printers. ( like i tested manual ) .

This will not working  :o :o

Can you please point me into the right direction ..?
Many thanks in advance

best regards,
Marco
An optimist is a person who sees only the lights in the picture,
 Whereas a pessimist sees only the shadows.  An idealist, however is one who sees the light and the shadows, but in addition sees something else:  the possibility of changing the picture, of making the light prevail over shadows.

Offline Henk

  • Hero Member
  • *****
  • Posts: 820
  • Karma: +3/-0
Re: Tripped Sensor Lua Code Help!!
« Reply #23 on: June 04, 2011, 01:52:39 pm »
Totally confused.
I hope someone is able to help me ....... ???

I use this code :
local lul_tmp = luup.variable_get("urn:micasaverde-com:serviceId:SecuritySensor1","Tripped",62)

if (lul_tmp=="0")

then local lul_tmp1 = luup.variable_get("urn:micasaverde-com:serviceId:SecuritySensor1","Tripped",63)

if (lul_tmp1=="0")

then luup.call_action("urn:upnp-org:serviceId:SwitchPower1","SetTarget",{newTargetValue="0"},61)

end

end


When both pc running at the office are powered down , the ping sensor is not tripped.
When I run the scene manual , the switch will go off . So I will assume the scene is working.

I have added a timer , witch is running every hour to check the pc's are not running any more and will switch off the printers. ( like i tested manual ) .

This will not working  :o :o

Can you please point me into the right direction ..?
Many thanks in advance

best regards,
Marco

@mversluis
If you are still following this thread, triggering a scene was a problem for many people until @pepebel4 came up with the json code add for the D_PingSensor.xml

Have you ever checked that codesnippet was in your xml?
| Vera2 @ UI4 1.1.1350 / 3.20 | Vera Lite @ UI5 | Vera 3 @ UI5 | 2x Merten  504519 | 1x Duewi  064374 | 1x Everspring SM103 doorbell mod |1 Y-cam IP cam | various LUUP plugins |