appd - Simple automations for outside and decoration lights
This commit is contained in:
parent
e578fdabe6
commit
9609e9c627
30
appdaemon/apps/timed_lights.py
Normal file
30
appdaemon/apps/timed_lights.py
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
from entities import Entities
|
||||||
|
|
||||||
|
class OutsideLights(Entities):
|
||||||
|
def initialize(self):
|
||||||
|
super().initialize()
|
||||||
|
for l in self.args['lights']:
|
||||||
|
self.register_entity(l, l)
|
||||||
|
|
||||||
|
self.listen_event(self.update, 'TOD_TOD')
|
||||||
|
self.listen_event(self.update, 'TOD_DARK')
|
||||||
|
self.run_in(lambda *_: self.update(None, None, None), 2)
|
||||||
|
|
||||||
|
def update(self, event, data, kwarg):
|
||||||
|
state = self.get_app('timeofday').dark
|
||||||
|
if self.get_app('timeofday').tod == 'night':
|
||||||
|
state = False
|
||||||
|
|
||||||
|
self.log(f"OUTSIDE LIGHTS - Turning lights {state}")
|
||||||
|
for l in self.e:
|
||||||
|
self.e[l].state = state
|
||||||
|
self.e[l].push()
|
||||||
|
|
||||||
|
class DecorativeLights(OutsideLights):
|
||||||
|
def update(self, event, data, kwarg):
|
||||||
|
state = self.get_app('timeofday').dark
|
||||||
|
self.log(f"DECOATIVE LIGHTS - Turning lights {state}")
|
||||||
|
for l in self.e:
|
||||||
|
self.e[l].state = state
|
||||||
|
self.e[l].push()
|
||||||
|
|
23
appdaemon/apps/timed_lights.yaml
Normal file
23
appdaemon/apps/timed_lights.yaml
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
outside_lights:
|
||||||
|
module: timed_lights
|
||||||
|
class: OutsideLights
|
||||||
|
global_dependencies:
|
||||||
|
- entities
|
||||||
|
dependencies:
|
||||||
|
- timeofday
|
||||||
|
lights:
|
||||||
|
- light.ute_framsidan
|
||||||
|
|
||||||
|
|
||||||
|
decorative_lights:
|
||||||
|
module: timed_lights
|
||||||
|
class: DecorativeLights
|
||||||
|
global_dependencies:
|
||||||
|
- entities
|
||||||
|
dependencies:
|
||||||
|
- timeofday
|
||||||
|
lights:
|
||||||
|
- light.deko_vardagsrum
|
||||||
|
- light.skotbord
|
||||||
|
- light.trappbelysning
|
||||||
|
- light.kontor_fonster
|
Loading…
x
Reference in New Issue
Block a user