We have moved at community.getvera.com

Author Topic: Who can find a problem here?  (Read 993 times)

Offline Kryckmeister

  • Jr. Member
  • **
  • Posts: 58
  • Karma: +1/-1
Who can find a problem here?
« on: February 28, 2019, 02:10:09 pm »
Being a newbie in programming and wanting to learn I'm playing around rather than just aiming for PLEG. So what I tried to do was creating four scenes triggered by a motion sensor during a certain time frame. Same with all four scenes.

What I then added which differs from all scenes are scripts like this:

local dID = 577 -- Device ID of your light sensor
local lLow = 651 -- Lowest level of range
local lHigh = 750 -- Highest level of range
local dID2 = 546 -- Device ID of your dimmer
local lLow2 = 0 -- Lowest level of range
local lHigh2 = 1 -- Highest level of range
local allow = true -- true runs scene when in range, false blocks it
local lCurrent = tonumber((luup.variable_get("urn:micasaverde-com:serviceId:LightSensor1","CurrentLevel",dID)))
local lCurrent2 = tonumber((luup.variable_get("urn:micasaverde-com:serviceId:DimmableLight1","CurrentLevel",dID2)))
return (((lCurrent >= lLow) and (lCurrent <= lHigh) and (lCurrent2 >= lLow2) and (lCurrent2 <= lHigh2)) == allow)

They are basically identical but ILow and IHigh are different in all of them. Since the different scenes are meant to go off depending on how much light there are in the room and I didn't want a new scene to trigger if the lights were just turned on like some kind of feedback, I added the second part.

The device IDs are correct. Since I'm posting I'm obviously not happy with the result and I have asked more skilled guys than myself with no luck. So, knowing how many very skilled people there are here I'm hoping for someone to help me out.

Thanks in advance!
« Last Edit: February 28, 2019, 03:13:31 pm by Kryckmeister »

Offline a-lurker

  • Hero Member
  • *****
  • Posts: 872
  • Karma: +66/-8
Re: Who can find a problem here?
« Reply #1 on: March 15, 2019, 06:18:06 pm »
Also have a look at the doco here:


and the section:

"Caution - Incorrect usages"