We have moved at community.getvera.com

Author Topic: Simple Scene...or so I thought  (Read 2440 times)

Offline aboyer

  • Sr. Newbie
  • *
  • Posts: 45
  • Karma: +0/-0
Simple Scene...or so I thought
« on: October 07, 2013, 01:04:32 pm »
I was trying to set up a scene so that when I came home after dark and opened the front door, the living room light would turn on. But it seems that whenever I open the door, it will turn on the light regardless of time of day.

After searching the forums, I have read where people are using PLEG to do this. This seems like it should be simple and doable right from the VeraLite without any additional plugins.

Is this possible or do I need some plugin to make this work correctly.

Thanks,

Offline Crismaison

  • Sr. Member
  • ****
  • Posts: 451
  • Karma: +2/-0
Re: Simple Scene...or so I thought
« Reply #1 on: October 07, 2013, 01:13:24 pm »
Install the day and night plugin, then the pleg one.
Then create 2 triggers based on the day/night and one when the dooropen.
Create a condition:

night and dooropen

Attach an action which switch the light on
Vera lite - Everspring smoke & flood detectors - Fibaro doorsensors - 2 Foscams - Greenwave 6 node smartplug - Several Switches -Netatmo - PLEG - Twilio - DropBoxuploader - FindmyIphone user

Offline RichardTSchaefer

  • Community Beta
  • Master Member
  • ******
  • Posts: 10091
  • Karma: +764/-143

Offline Z-Waver

  • Master Member
  • *******
  • Posts: 4437
  • Karma: +249/-120
Re: Simple Scene...or so I thought
« Reply #3 on: October 07, 2013, 01:25:57 pm »
While I won't argue against the excellent PLEG, or even the Day Night plugin, neither is actually needed in this case.

Simply click the wrench on your scene, then click the LUUP tab. Paste this into the box and click Save LUA
Code: [Select]
return luup.is_night() == trueThen click Confirm changes and finally Save. Now the scene will only run between sunset and sunrise.

Offline a-lurker

  • Hero Member
  • *****
  • Posts: 872
  • Karma: +66/-8
Re: Simple Scene...or so I thought
« Reply #4 on: October 07, 2013, 08:33:31 pm »
Or:

Code: [Select]
return luup.is_night()

Offline Z-Waver

  • Master Member
  • *******
  • Posts: 4437
  • Karma: +249/-120
Re: Simple Scene...or so I thought
« Reply #5 on: October 07, 2013, 11:04:36 pm »
Or:

Code: [Select]
return luup.is_night()
Hmm. The budding Perl programmer?

IMHO verbosity, in this case, improves readability/understanding.

Offline a-lurker

  • Hero Member
  • *****
  • Posts: 872
  • Karma: +66/-8
Re: Simple Scene...or so I thought
« Reply #6 on: October 08, 2013, 12:17:45 am »
Verbosity - yes I agree with you there - readability is a very important aspect. I used to be regularly criticized for using long winded variable names in loop structures instead of i and j. Compilers generally optimizes this sort of stuff anyway - we hope that is. :D

Offline aboyer

  • Sr. Newbie
  • *
  • Posts: 45
  • Karma: +0/-0
Re: Simple Scene...or so I thought
« Reply #7 on: October 08, 2013, 10:45:11 am »
Thanks for all of the responses.

I will have to try these tonight when I get home.

I will try all of these just to see how they vary from each other.

By the way, what does LUUP and LUA stand for?

Thanks

Offline RichardTSchaefer

  • Community Beta
  • Master Member
  • ******
  • Posts: 10091
  • Karma: +764/-143
Re: Simple Scene...or so I thought
« Reply #8 on: October 08, 2013, 11:47:49 am »
I do not know why one would think that:

return luup.is_night() == true

is easier to understand than:

return luup.is_night()

Now if some did:
local n = luup.is_night

return n()

I would agree with you.




Offline Z-Waver

  • Master Member
  • *******
  • Posts: 4437
  • Karma: +249/-120
Re: Simple Scene...or so I thought
« Reply #9 on: October 08, 2013, 01:12:39 pm »
Thanks for all of the responses.

I will have to try these tonight when I get home.

I will try all of these just to see how they vary from each other.

By the way, what does LUUP and LUA stand for?
Lua is a scripting(programming) language that was used to create Vera. LUUP is Vera's Lua and Universal Plug and Play(UPnP) extentions.



I do not know why one would think that:

return luup.is_night() == true

is easier to understand than:

return luup.is_night()

Now if some did:
local n = luup.is_night

return n()

I would agree with you.

Your superhuman programming skills far exceed my own abilities. I struggle with what is seemingly easy to you.

Offline aboyer

  • Sr. Newbie
  • *
  • Posts: 45
  • Karma: +0/-0
Re: Simple Scene...or so I thought
« Reply #10 on: October 08, 2013, 08:27:24 pm »
While at work, I did some more reading and found the Day Night Plugin. Since I have another application that I was thinking of, I decided to try this plug in. I also added the following in the LUUP section of the scene that I found in another post:

local dID = 45
local itsday = luup.variable_get("urn:rts-services-com:serviceId:DayTime","Status",dID)
return itsday == "0"

I came home from work tonight before night time and everything worked as I hoped. Opening the front door did not trigger the light to come one. I waited until after dark and opened the front door again and the light came on. I think I will just leave this as is (if it isn't broken, don't fix it).

Thanks for the suggestions and for the definitions of LUUP and LUA.