Author Topic: Conditional Scene Execution: Some Examples  (Read 117244 times)

Offline kiethr

  • Full Member
  • ***
  • Posts: 103
  • Karma: +0/-2
Re: Conditional Scene Execution: Some Examples
« Reply #30 on: February 25, 2014, 02:51:06 pm »
Just the status of the light switch, I do not have a motion sensor.......yet.

Thank you I will give that a try and report back!
« Last Edit: February 25, 2014, 03:01:03 pm by kiethr »

Offline parkerc

  • Sr. Hero Member
  • ******
  • Posts: 2177
  • Karma: +29/-38
  • Life Moves Pretty Fast....
    • Node Central
Re: Conditional Scene Execution: Some Examples
« Reply #31 on: February 25, 2014, 03:38:34 pm »
You've got me thinking about ways of checking if someone is still in the room.

If the 'work' you are referring to involves the use of a networked PC in that room, then you could also look to add the Ping Sensor as a method for telling you if someone is there and working.

If you have a music player in there too. E.g like a Sonos, you could look to see if it is being used (status as Playing) as another way of checking  occupancy.

Offline kiethr

  • Full Member
  • ***
  • Posts: 103
  • Karma: +0/-2
Re: Conditional Scene Execution: Some Examples
« Reply #32 on: February 25, 2014, 07:52:34 pm »
No actually i was painting the hallway.  The kids kept coming and going and that darn light would shut off after 5 minutes every time they left :)

Offline kiethr

  • Full Member
  • ***
  • Posts: 103
  • Karma: +0/-2
Re: Conditional Scene Execution: Some Examples
« Reply #33 on: February 25, 2014, 07:58:54 pm »

@RexBeckett

First thank you for attempting to help me!

The code you supplied did change what time the trigger started to run, so that  part is working just fine.  However the timer still runs when the light is on.  I'm not really sure where the problem is within the code.

Sent from my iPad using Tapatalk HD

Offline parkerc

  • Sr. Hero Member
  • ******
  • Posts: 2177
  • Karma: +29/-38
  • Life Moves Pretty Fast....
    • Node Central
Re: Conditional Scene Execution: Some Examples
« Reply #34 on: February 26, 2014, 02:18:18 am »
No actually i was painting the hallway.

 :) Considering the way the Internet of Things (IoT) is going, it's probably only a matter of time before you'll have an IP address for our paint brushes  8)

Offline RexBeckett

  • Master Member
  • *******
  • Posts: 3888
  • Karma: +475/-10
Re: Conditional Scene Execution: Some Examples
« Reply #35 on: February 26, 2014, 09:04:36 am »
Quote
The code you supplied did change what time the trigger started to run, so that  part is working just fine.  However the timer still runs when the light is on.  I'm not really sure where the problem is within the code.
When you say the timer still runs, do you mean that the scene actions are still being executed even if the light is on? Do you have an instant action to turn the light on and a delayed one to turn it off?

Where did you place the Lua code - in the scene Luup tab or in the trigger Luup event? Is there just one trigger for the scene? Will you re-post your current code in case a typo crept in?

Offline kiethr

  • Full Member
  • ***
  • Posts: 103
  • Karma: +0/-2
Re: Conditional Scene Execution: Some Examples
« Reply #36 on: February 26, 2014, 10:03:32 pm »
I created the scene in the following way: I have Aeon labs hidden door sensor on the front door. When the sensor is triggered (from sunset until  2359) it triggers the hallway light (controlled by a GE/JASCO wall switch) to come on.  Then I set a delay to turn the hallway light off 5 minutes later.  I entered the code contained below in the scene under the LUUP tab. 

local minute = math.floor((ssTime % 3600) / 60)
 
local startTime = hour * 100 + minute
 
hour = tonumber( endTime:sub( endTime:find("%d+") ) )
minute = tonumber(endTime:sub(-2))
 
if hour and minute then
    endTime = hour * 100 + minute
else
    luup.log("ERROR: invalid end time")
    return false
end
 
local currentTime = os.date("*t")
currentTime = currentTime.hour * 100 + currentTime.min
 
luup.log("startTime = " .. startTime .. "; currentTime = " .. currentTime .. "; endTime = " .. endTime)
 
if startTime <= endTime then
    -- Both the start time and the end time are in the same day:
    -- if the current time is in the given interval, run the scene.
    if startTime <= currentTime and currentTime <= endTime then
        return true
    end
else
    -- The start time is before midnight, and the end time is after midnight:
    -- if the current time is not outside the given interval, run the scene.
    if not (endTime < currentTime and currentTime < startTime) then
        return true
    end
end
 
return false

Offline RexBeckett

  • Master Member
  • *******
  • Posts: 3888
  • Karma: +475/-10
Re: Conditional Scene Execution: Some Examples
« Reply #37 on: February 27, 2014, 12:40:32 am »
@kiethr, that isn't the code I posted. The first part is missing. When you change the code, make sure you click the Save lua button at the bottom before clicking Confirm changes.

Offline kiethr

  • Full Member
  • ***
  • Posts: 103
  • Karma: +0/-2
Re: Conditional Scene Execution: Some Examples
« Reply #38 on: February 27, 2014, 07:29:19 am »
@RexBeckett

Thanks, I would be lying if I said that has never happened to me before.  The SAVE button is off my laptop screen and I do forget to click that sucker every now and then!! I'll throw the code in and give it a try when i get home.

Also i stumbled across your PLEG Basics manual, its good reading.  Thanks for putting it together!

Sent from my iPad

Offline kiethr

  • Full Member
  • ***
  • Posts: 103
  • Karma: +0/-2
Re: Conditional Scene Execution: Some Examples
« Reply #39 on: February 27, 2014, 07:13:41 pm »
Hello @RexBeckett

I did add the updated code to my veralite.  The light that would normally trigger will not trigger.  If the light that is being triggered is already on when triggered it doesn't go off after the delay in the scene is reached.

Any thoughts?


Sent from my iPad using Tapatalk HD

Offline kiethr

  • Full Member
  • ***
  • Posts: 103
  • Karma: +0/-2
Re: Conditional Scene Execution: Some Examples
« Reply #40 on: February 27, 2014, 07:15:55 pm »
Hello @RexBeckett

I did add the updated code to my veralite.  The light that would normally trigger will not trigger.  If the light that is being triggered is already on when triggered it doesn't go off after the delay in the scene is reached.

Any thoughts?


Sent from my iPad using Tapatalk HD

Offline RexBeckett

  • Master Member
  • *******
  • Posts: 3888
  • Karma: +475/-10
Re: Conditional Scene Execution: Some Examples
« Reply #41 on: February 27, 2014, 07:27:27 pm »
Hello @RexBeckett

I did add the updated code to my veralite.  The light that would normally trigger will not trigger.  If the light that is being triggered is already on when triggered it doesn't go off after the delay in the scene is reached.
Any thoughts?
Sorry @kiether, I don't understand what your problem is. Are you saying that the scene does not now turn on the light at all? Even when the door is opened during the specified time period?

Quote
If the light that is being triggered is already on when triggered it doesn't go off after the delay in the scene is reached.
Isn't that what you wanted to happen?

Maybe I don't understand what you want to happen. Can you explain how you want it to work?

Offline kiethr

  • Full Member
  • ***
  • Posts: 103
  • Karma: +0/-2
Re: Conditional Scene Execution: Some Examples
« Reply #42 on: February 27, 2014, 07:30:40 pm »
I guess i was trying to give to much information.  You are correct the trigger to turn on the light when the door is open is not working after i added the code. 



Sent from my iPad using Tapatalk HD

Offline RexBeckett

  • Master Member
  • *******
  • Posts: 3888
  • Karma: +475/-10
Re: Conditional Scene Execution: Some Examples
« Reply #43 on: February 28, 2014, 12:38:13 am »
Quote
You are correct the trigger to turn on the light when the door is open is not working after i added the code.
Is the light using a regular Z-Wave switch or is it a dimmer? Some dimmers don't update SwitchPower1 Status in which case you may need to check LoadLevelStatus instead.

Offline kiethr

  • Full Member
  • ***
  • Posts: 103
  • Karma: +0/-2
Re: Conditional Scene Execution: Some Examples
« Reply #44 on: February 28, 2014, 05:13:37 pm »
It a straight up GE/JASCO single pole on/off zwave switch


Sent from my iPhone