Turn lights on at sunset, off at 23:00hrs

Turn lights on at sunset, off at 23:00hrs
0

#1

This example shows you how you can automate your home so that your outside lights are turned on every day at sunset, and then turned off at 23h. This is a great idea for automating your porch or your garage lights so they are turned on to welcome all family members when they are arriving home, but then saving energy automatically turning them off at an appropriate time at night.

For this example, I will be using a LIFX smart lightbulb, that can be easily controlled through IFTTT.

Let’s have a look at the different pieces of this smart home logic and how to set them up.

How to create the variable “is-it-light-time”

First, I’m going to create a new boolean variable in Apilio called ‘is-it-light-time’. This variable will be true between sunset and 23h. At this time in the evening, the variable will be set back to false.

When the variable is true, this means that my outside lights must be turned on, and later when the variable turns false, this means that the lights can now be switched off.

Here’s what the variable looks like in Apilio - set it to false if it is not currently sunset yet!

Creating the condition

It is now time to create a condition in Apilio. This condition will check the status of my variable. Remember, although IFTTT is used to change the variables in Apilio, it is the condition - or a combination of conditions - that your logicblock depend upon to generate an action. As a result, this condition step is super-important to get right!

I am calling the condition ‘outside_lights_on’ and using the variable ‘is-it-light-time’ to determine the state of the condition: i.e. if ‘is-it-light-time’ is true (it’s currently between sunset and 23h), the condition ‘outside_lights_on’ will also be true (this means, it is the time to turn the outside lights on).

I don’t need to fill in the optional timestamp restrictions in this case.

Setting my boolean variable to true and false with IFTTT

I’m going to use two IFTTT applets for controlling the state of my variable:

  1. For tracking the sunset, I will use the WeatherUnderground service in IFTTT
  2. For tracking the time, every day at 23 hours, I will use the Date and Time service in IFTTT

This is how I set them up, step-by-step:

To set ‘is-it-light-time’ to true:

  1. The applet I want to create will be: “If it is sunset, then set the Apilio variable ‘is-it-light-time’ to true.”
  2. As the “If this” part, select Weather Underground (Thanks Weather Underground!!) and then the trigger called Sunset. I will then be asked to select my location so I have a more accurate sunset time

  1. As the “then that”, select Apilio, then update a variable to true and select the boolean variable:

  1. This is the finished applet

To set ‘is-it-light-time’ to false:

  1. The applet I want to create will be: “If it is 23h, then set the Apilio variable ‘is-it-light-time’ to false.”
  2. As the “If this” part, I have to select Date and Time, and then the Every day at trigger. I choose 23h as follows:

  1. As the “then that”, select Apilio, then update a variable to false and select the boolean variable that we want to update:

  1. Finish the applet, it should look like this

:

How to create my logicblock

We’re nearly there now… just the most exciting bit left - creating your logicblock!

As shown below I’m going to call the logicblock ‘control_outside_lights’.

It will evaluate the condition ‘outside-lights-on’:

  • If is true (positive action), this means the lights should be turned on, so I will set my action to turn my outside LIFX lights on. This will be done with an IFTTT applet that receives the event “outside_lights_on” from Apilio.
  • If it is false (negative action), this means it is time to turn the lights off, so I will set my action to turn off my outside LIFX lights. This will be achieved with an IFTTT applet that receives the event “outside_lights_off” from Apilio.

Logicblocks can be evaluated from IFTTT or anytime a connected variable changes. For simplicity, I am going to set the logicblock to Automatic evaluation so that any time a connected variable changes, the logicblock outcome will be determined. This means that any time the variable is-it-light-time changes to true or false, the logicblock will be evaluated, the condition will be checked and the corresponding actions will be run.

Setting up my actions with IFTTT

Now, to complete my automation, I will setup IFTTT applets that will take care of my actions when the logicblock tells them to. For this, I am going to use Apilio and LIFX on IFTTT to create two applets:

To turn on my outside lights on:

  1. The applet I want to create will be: If IFTTT receives the event ‘outside_lights_on’ from Apilio, then turn on my LIFX light.
  2. As the “If this” part, select Apilio, and trigger to receive a specific event.
  3. As the “then that”, select LIFX, to turn on the light

To turn my outside lights off:

  1. The applet I want to create will be: If IFTTT receives the event ‘outside_lights_off’ from Apilio, then turn off my LIFX light.
  2. As the “If this” part, select Apilio, and the trigger to receive this specific event
  3. As the “then that”, select LIFX, to turn off the light

And hey… presto! My outside lights will turn on at sunset and off at 23:00hrs.

Any comments or questions? Leave us a message below or open a new topic in the help section of this forum. Thanks!


#2

So, this is what I am looking for except for one small modification. I want to turn the lights on 1/2 hour before sunset. Is that possible? Thank you in advance.


#3

Yes, change the location in the underground weather to match your schedule definitions, meaning, half an hour early.