Author Topic: Scene runs immediately when door/window is left open  (Read 281 times)

Offline Kositch

  • Sr. Newbie
  • *
  • Posts: 28
  • Karma: +0/-0
Scene runs immediately when door/window is left open
« on: June 26, 2018, 01:12:56 am »
Hello,

I have a scene which works like a burglar disturbing - in night mode when door/windows (contact sensors on door/windows) is opened it lights up red all lights in house. This scene is active only in night mode (night mode activates at 10PM). My problem is when I leave open window for a night (in summer most often) it lights up all lights immediately when mode changes to night - it detects window opened and it runs scene. How can I prevent it - I want to run scene only when the window/door is opened during night, not to run scene when the window is already opened before scene is active.

Is it possible somehow to change this behavior?

Thanks!

Offline rafale77

  • Hero Member
  • *****
  • Posts: 1407
  • Karma: +71/-24
Re: Scene runs immediately when door/window is left open
« Reply #1 on: June 26, 2018, 02:39:52 am »
Yes this is doable.

I would recommend adding a conditional through luup code to your scene on the LastTrip variable.
Something like this:
(Replace with your sensor device id)

Code: [Select]
local last = luup.variable_get("urn:micasaverde-com:serviceId:SecuritySensor1","LastTrip",##sensordeviceid##)
return(os.difftime(os.time(),last))<=1)
openLuup (97 devices, 134 scenes, 20 apps) controlling HomeAss + VeraPlus (138 zwave nodes, 8 Zigbee nodes, 205 devices, 20 scenes , 2 app) Bridged to Homekit and Alexa. VeraPlus ExtRooted!

Offline Kositch

  • Sr. Newbie
  • *
  • Posts: 28
  • Karma: +0/-0
Re: Scene runs immediately when door/window is left open
« Reply #2 on: June 26, 2018, 07:15:07 am »
Thanks a lot, but I have one scene for 3 sensor devices. I am not quite familiar with luup code, where exactly I should put this code and how to modify it for all 3 sensors? Isnt there easier way to do that?

Sorry for me being newbie, but I really enjoy Vera system  :)
« Last Edit: June 26, 2018, 09:23:50 am by Kositch »

Offline RichardTSchaefer

  • Master Member
  • *******
  • Posts: 10091
  • Karma: +764/-142
Re: Scene runs immediately when door/window is left open
« Reply #3 on: July 01, 2018, 12:52:42 pm »
You can do this in PLEG ... using the Sequence operator to handle the logic for ordering the events (i.e. Opened AFTER Dark).