if you are starting to implement light automations there are a few.
and then over time it grows.
you add a new light and a new automation, and another automation, and …
listing all your automations beneath each other doesnt really give you a good view on things.
i had a view light apps running. and i reused them resulting in something like this in the cfg file:
[lichtuitbuiten1]
module = daily
class = lightsout
days = 1,2,3,4,5,6,7
uur = 1
minuut = 40
total_switches = 1
switch1 = input_boolean.waterloop
[lichtuitbuiten2]
module = daily
class = lightsout
uur = 1
minuut = 41
days = 1,2,3,4,5,6,7
total_switches = 1
switch1 = input_boolean.jacuzzi
[lichtuitkelder]
module = daily
class = lightsout
uur = 1
minuut = 30
days = 1,2,3,4,5,6,7
total_switches = 1
switch1 = input_boolean.aquariums
[lichtuitbinnen]
module = daily
class = lightsout
uur = 20
minuut = 25
days = 5,6
total_switches = 1
switch1 = input_boolean.allesuit
constrain_start_time = sunset - 01:00:00
constrain_end_time = sunrise
[lichtaanbinnen]
module = daily
class = lightson
uur = 0
minuut = 30
days = 6,7
total_switches = 7
switch1 = input_boolean.hboog
switch2 = input_boolean.hbank
switch3 = input_boolean.hhoek
switch4 = input_boolean.eraamhoek
switch5 = input_boolean.epchoek
switch6 = input_boolean.ewandmeubel
switch7 = switch.kachel_9_1
constrain_start_time = sunset
constrain_end_time = sunrise
[dekkiesuit]
module = daily
class = lightsout
days = 1,2,3,4,5,6,7
uur = 7
minuut = 00
total_switches = 1
switch1 = input_boolean.olindedekkie
[dekkieolindeaan]
module = daily
class = lightson
days = 1,2,3,4,7
uur = 23
minuut = 00
total_switches = 1
switch1 = input_boolean.olindedekkie
[dekkieolindeaanweekend]
module = daily
class = lightson
days = 6,7
uur = 0
minuut = 45
total_switches = 1
switch1 = input_boolean.olindedekkie
[lichtaanbuiten1]
module = sunset
class = sunsetlights
offset = 0
aanuit = autobuiten
total_switches = 1
switch1 = input_boolean.jacuzzi
[lichtaanbuiten2]
module = sunset
class = sunsetlights
offset = 60
aanuit = autobuiten
total_switches = 1
switch1 = input_boolean.waterloop
[lichtaanhuiskamer]
module = sunset
class = sunsetlights
offset = -3600
aanuit = autohuiskamer
total_switches = 4
switch1 = input_boolean.hboog
switch2 = input_boolean.hbank
switch3 = input_boolean.hhoek
switch4 = switch.kachel_9_1
[lichtaaneetkamer]
module = sunset
class = sunsetlights
offset = -3300
aanuit = autoeetkamer
total_switches = 3
switch1 = input_boolean.eraamhoek
switch2 = input_boolean.epchoek
switch3 = input_boolean.ewandmeubel
i dont know how you see it, but i lose the overview by reading that.
so i have made a new app. based on a .csv file which i can easy edit in excel (or another spreadsheet programm, or any editor)
and then it looks like this:
suddenly i have an good view again on when my lights go on and off.
you can easy add new lights or other switches to it, group things and rearrange things.
you wanna know about this app?
here it is:
###########################################################################################
# #
# Rene Tode ( [email protected] ) #
# ( with a lot off help from andrew cockburn (aimc) ) #
# 2016/11/28 Germany #
# #
###########################################################################################
import appdaemon.appapi as appapi
import datetime
import time
class switches(appapi.AppDaemon):
def initialize(self):
file_name = self.args["settingsfile"]
try:
settings_file = open(file_name, "r")
for line in settings_file:
splitline = line.split(";")
if not "#" in splitline[0]:
switch = splitline[0]
if splitline[1]!="":
ontime = self.parse_time(splitline[1])
else:
ontime = ""
if splitline[2]!="":
offtime = self.parse_time(splitline[2])
else:
offtime = ""
constraindays = splitline[3]
if type(ontime) is datetime.time:
self.log(switch + " tijd: " + ontime.strftime("%H:%M:%S") + " dag: " + constraindays + " on")
self.run_daily(self.set_lights_on,ontime,constrain_days=constraindays,switch=switch)
if type(offtime) is datetime.time:
self.log(switch + " tijd: " + offtime.strftime("%H:%M:%S") + " dag: " + constraindays + " off")
self.run_daily(self.set_lights_off,offtime,constrain_days=constraindays,switch=switch)
except:
self.log( "error in reading lightsetting file")
def set_lights_on(self, kwargs):
self.log(kwargs["switch"] + " on")
self.turn_on(kwargs["switch"])
def set_lights_off(self, kwargs):
self.log(kwargs["switch"] + " off")
self.turn_off(kwargs["switch"])
and all you need in your cfg file is:
[verlichting]
module = lights
class = switches
settingsfile = C:\Users\rene\AppData\Roaming\.homeassistant\lichtschema.csv
hope you enjoy this
edit: changed dutch in app to english