Luup code problem

I’m newbie in Vera & Z-Wave and i have few questions

I create network which contains of lights(fgs 221, schneider modules), switches(fgs 221, aeon smart switch), aeon sensors( 4 in 1, door sensor), everspring st814

  1. I’m starting writing a luup code. Example :

[code]local hum = luup.variable_get(“urn:schemas-micasaverde-com:device:ComboDevice:1”,“CurrentLevel”, 45)

if ( tonumber(hum) > 35 ) then
return true
else
return false
end
[/code]

On dashboard i have humidity at 22 %. I logged to Vera2 by SSH and i have error like this

LuaInterface::CallFunction-3 Scene 5 failed [string “function scene_5()…”]:4: attempt to compare number with nil <0x803>

  1. Polling by vera doesn’t work properly. Sometimes i have wait few hours to update temp on dashboard. I don’t know how vera manage but i think that someone did it very wrong - few devices and delays grows rapidly.

Thanks for help

P.S sorry for my english

"urn:schemas-micasaverde-com:device:ComboDevice:1"

This is a device type not a service ID needed by the luup.variable_get method.

You can use the Program Logic Event Generator plugin to allow you to access Vera triggers and Device variables without having to learn LUUP and how all the uPNP names for service variables work.

[hr]
PLEG Input:
Using device Property, Select the appropriate humidity device current humidity value using menu selection. Give it a name like Humidity
PLEG Condition:
HighHumidity = Humidity >35
PLEG Action:
for condition HighHumidity add what ever commands you need.

@dzakens,

Welcome!

What’s the minimum poll interval set to for the device in question? The default may be 10800 seconds / 3 hours.

I have my ST814’s set to auto-report on a change in temperature / humidity.

Could you write how do you do that?

There should be some hints here on the forum. You have to configure parameters 6, 7 and/or 8 I believe. These are mentioned in the instructions for the device. See also this post perhaps.

Thanks :slight_smile:

I have one more question - how can i get proper serviceID? There is no serviceID in Advanced tab? In my Vera 2 I searched everything and I found in Mios Developers tab Luup files when there are xml files connected with particular devices - but when i use serviceID’s from them i get errors like this one before:

LuaInterface::CallFunction-3 Scene 5 failed [string "function scene_5()..."]:4: attempt to compare number with nil <0x803>

You should be able to identify the correct Service by either of the commands below:

http://Vera_IP/port_3480/data_request?id=user_data&output_format=xml
http://Vera_IP:3480/data_request?id=lu_invoke

Replace Vera_IP with the correct IP address of your unit.

Thanks again

I have one more question ;D I have mono-stable switch and i want make it bi-stable by luup code. In scene i make event turn on by switching mono-stable button connected with fibaro fgs221. Light bulb is connected with another fgs 221 ( in network device 32). I don’t use luup.variable_get because vera don’t update is enough often to relay on variable status from advanced tab. So i poll it first to get proper status, but it don’t update either.

local device = 32

local light_status = {}

luup.call_action(“urn:upnp-org:serviceId:SwitchPower1”,“Poll”,{},device)

light_status = luup.variable_get(“urn:upnp-org:serviceId:SwitchPower1”,“Status”,device)

if (light_status == 0) then

luup.call_action(“urn:upnp-org:serviceId:SwitchPower1”,“SetTarget”,{newTargetValue = “1”},device)

else

luup.call_action(“urn:upnp-org:serviceId:SwitchPower1”,“SetTarget”,{newTargetValue = “0”},device)

end

edit:

i have another question - how works events to start scene ? if i set running scene by button (option device is turn on or off) it have to be pushed during time of scene?

Try replacing your poll device with:

luup.call_action(“urn:micasaverde-com:serviceId:HaDevice1”, “Poll”, {}, device)

thanks Brientim, strange effect. If lamp if turn off, i push button - no effect. When turn it on from dashboard and then push button lamp turn off as it should. Conlusion is simple - there are two possibilities - command from luup script doesn’t effect in polling or polling in this way doesen’t update lamp status

Change:

if (light_status == 0) then

To:

if (light_status == "0") then

Or:

if (tonumber(light_status) == 0) then

Or Shorten as:

local device = 20
local Svs = "urn:upnp-org:serviceId:SwitchPower1"
local luup.call_action(Svs, "Poll", {}, device)
local light_status = luup.variable_get(Svs,"Status",device)
local args = {newTargetValue = tostring((tonumber(light_status) + 1)  % 2)}
luup.call_action(Svs, "SetTarget", args, device)

Sorry for such a late reply - i finally managed what i’ve wanted. Thanks all for help. I’m adding code which works on my vera 2.

[quote=“RichardTSchaefer, post:12, topic:174237”][code]

local device = 20
local Svs = “urn:upnp-org:serviceId:SwitchPower1”
local luup.call_action(Svs, “Poll”, {}, device)
local light_status = luup.variable_get(Svs,“Status”,device)
local args = {newTargetValue = tostring((tonumber(light_status) + 1) % 2)}
luup.call_action(Svs, “SetTarget”, args, device)
[/code][/quote]

i’m not sure but i got errors when after calling a function i declared some variables - it could be a problem but my not sure if other issues had influence on this

my code :


local device  = 32
local light_status = {}
local Svs = "urn:upnp-org:serviceId:SwitchPower1"

luup.call_action(Svs,"Poll",{},device)
light_status = luup.variable_get(Svs,"Status",device)

if (light_status == "0") then

luup.call_action(Svs,"SetTarget",{newTargetValue = "1"},device)

else

luup.call_action(Svs,"SetTarget",{newTargetValue = "0"},device)

end

it works pretty slow by vera 2 - unfortunately this is bad way to make mono-stable switch bi-stable