Day Or Night Plugin

I just released a simple plugin that use’s MCV internal luup.is_night to toggle a virtual Switch to indicate day time or night time. Actually it has it’s own Icons. (Sun and Moon). You can provide an offset from sunrise and sunset so that you can consider day as 19 minutes before sunrise and 21 minutes after sunset if you like.
This can be used to trigger scenes, or in Plugins like Program Logic Event Generator and Program Logic Timer Switch. Since this is a also a switch … and you can change it … you can force or test all of your automation logic in Day and Night modes.

Anything special need to be done to see the new icons? Just looks like a blue button for me.

Try reloading your browser window!

Nothing. I even tried logging into Vera through a completely different browser (Firefox vs Chrome). No change.

I will look into this … I needed MCV help to release this simple plugin … we had problems with the developer side of the App store. I will delete all my files and try a clean install.

Hi, great plugin, how do I need to set the +/-? Is it eg +01::00:: ? Or with only single :?

Single colon … I need to fix the label!

thx, how can I check if I have the Luup.isNight, since whatever I fill it, it keeps on saying it is “Day” in the device. How does it know the sunrise and sunset at my place?

luup.is_night is an internal Vera function.

It does requires that you setup the location of your Vera to operate properly.
Setup tab and Location sub tab at the top of your Vera 3.
You need to set your timezone and city. Should work properly after that.

Thx, works perfect now to switch on my garden light in a scene based on sunset or sunrise. Keep up the good work with the plugins!

Thanks for the plugin. At first I thought it to be superfluous because there is the luup.is_night function. But this combines very well with your PLEG plugin to make conditional schedules.

E.g. I made a setup that turns on the light at 6 in the morning but not if it is 10 min to sunrise. At sunrise the lights are switched of again. It looks stupid to switch on the light 1 min to sunrise and switch it of 1 min later. Or worse: switch in on at 6 after sunrise, and leave the lights on all day…

Now comes the question: could you maybe supply an example LUUP-code to read the status of a night or day device? Maybe you could also show the example on your help-site.

Thanks!

The main reason I did Day or Night is so that you do not need to do LUUP coding.

But if you must … yo do this the same way you access any other device variable.
Find the Device on the UI
Goto the Advanced Tab.
Hover the mouse over the Variable (in this case: Status)
This will show the Service Variable.
Get the Device ID from the Same tab.

in luup:

   local val = luup.get_variable_get("Service", "Variable", tonumber(Device))

I have a scene that is run by a schedule. But I wanted to substitute the luup.is_night condition by checking the status of your plugin because of the possibility to add a 15 min delay. I know I can avoid using luup by using your PLEG plugin but then the schedule doesn’t appear in the schedule list.

I was trying to use the device type (urn:schemas-rts-services-com:device:DayTime:1) instead of the Service Variable. It looked so similar…

Now it is running as intended, thanks!

The Schedule Tab is where you create a schedule to be used by the PLEG device.
This does not show schedules for other scenes.

I just came across this plugin and installed it … interresting since you can add some minutes to sunrise or sunset :slight_smile:

But how do i use it , lets say I have a scene which I only want to run when I activate it and if it is during the night (20 min after sunset and 20 minutes before sunrise).

For the moment I have the LUUP code for night inserted in the LUUP option of a scene, so that has to be deleted , but how do I say to that scene , first look at that “day or night” switch to activate or not.

thanks,
Cor

In your scene … instead of looking at luup.is_night
You would check the status of the day or night switch.
Lot’s of code fragents out there on accessing a device’s variables.

The benefit is that you can test your day and night logic without having to wait for Daytime or Nightine.
My primary motivation for this was to be used by the Program Logic Event Generator and Program Logic Timer Switch plugins … so that you would not need to learn and/or use LUUP code to get something useful done.

Great Plugin

Thanks for making scene creation that little bit easier :slight_smile:

@RichardTSchaefer, ah ja , I get it … I can use this code , you gave me a couple of days ago :slight_smile:

[code]autoscene = luup.variable_get(“urn:upnp-org:serviceId:VSwitch1”,“Status”,32)

if(autoscene==“1”)then

return true
else
return false
end[/code]

where the 32 should be changed now into the device ID of this day-night switch.

1=night
0= day ?

I have just been playing with this plugin , but difficult to check… I cannot get the sun to rise now here at midnight ::slight_smile:
Just to confirm if it is correct with the +/- , I have attached a screenshot.
I want: day = sunrise-20 , night is sunset+20

Is it correct what i inserted?

thanks,
Cor

Maybe I jumped the gun just a little too quick :-/

To begin, I have the time and regions etc set correctly in my Vera 2 unit as I am using other scenes with the sunrise / sunset option with no problem.

I installed the day / night plugin and created a scene, with the help of the dsc alarm plugin, to turn a light on when the front door was opened and turn it off 30 seconds later.

When tested this all worked great - open the door, light turns on and 30 seconds later it switches off. But it was night.

I tested this morning, 9am, local time so def after sunrise, and the light still turns on when the door is opened.

What could I have done wrong? I was of the understanding that you use the day / night plugin in the usual way you do with all other devices when creating a scene - if you want it t run only at night click the night switch at the beginning of the scene creation and vice versa for day.

Any ideas?

@Scottf,

I imagine you are setting the plugin to night during scene creation on the tab with all of the other switches and lights and other associated doodads? What this is doing is setting the plugin to the “night” state. Even if it’s daytime. As RTS has stated, you can simulate the opposite state of the Sun with this plugin for testing purposes… which is what you’re doing. What you want to do is a little more complicated. You want a dependency on the state of the Sun. Not to make the Sun set or rise.