added patio light
This commit is contained in:
@@ -14,13 +14,13 @@ scene_detect:
|
|||||||
module: scene_detect
|
module: scene_detect
|
||||||
class: MotionCanceller
|
class: MotionCanceller
|
||||||
scene: bedsport
|
scene: bedsport
|
||||||
app: bedroom_motion
|
room: bedroom
|
||||||
|
|
||||||
scene_detect2:
|
scene_detect2:
|
||||||
module: scene_detect
|
module: scene_detect
|
||||||
class: MotionCanceller
|
class: MotionCanceller
|
||||||
scene: in_bed
|
scene: in_bed
|
||||||
app: bedroom_motion
|
room: bedroom
|
||||||
|
|
||||||
leaving:
|
leaving:
|
||||||
module: leaving
|
module: leaving
|
||||||
@@ -32,3 +32,12 @@ leaving:
|
|||||||
- kitchen
|
- kitchen
|
||||||
- bathroom
|
- bathroom
|
||||||
- closet
|
- closet
|
||||||
|
|
||||||
|
patio:
|
||||||
|
module: patio
|
||||||
|
class: Patio
|
||||||
|
door: binary_sensor.back_contact
|
||||||
|
light: light.patio
|
||||||
|
state:
|
||||||
|
brightness: 150
|
||||||
|
color_temp: 400
|
||||||
|
|||||||
27
apps/patio.py
Normal file
27
apps/patio.py
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
from appdaemon.entity import Entity
|
||||||
|
from appdaemon.plugins.hass.hassapi import Hass
|
||||||
|
|
||||||
|
|
||||||
|
class Patio(Hass):
|
||||||
|
def initialize(self):
|
||||||
|
self.door.listen_state(callback=self.handle_door_open, new='on')
|
||||||
|
self.door.listen_state(callback=self.handle_door_close, new='off')
|
||||||
|
self.log(f'Patio light initialized for {self.door.friendly_name}')
|
||||||
|
self.log(f'Sun angle: {self.AD.sched.location.solar_elevation():.1f}')
|
||||||
|
|
||||||
|
@property
|
||||||
|
def door(self) -> Entity:
|
||||||
|
return self.get_entity(self.args['door'])
|
||||||
|
|
||||||
|
@property
|
||||||
|
def light(self) -> Entity:
|
||||||
|
return self.get_entity(self.args['light'])
|
||||||
|
|
||||||
|
def handle_door_open(self, entity: str, attribute: str, old: str, new: str, kwargs: dict):
|
||||||
|
self.log('Door open')
|
||||||
|
if self.AD.sched.location.solar_elevation() <= 0:
|
||||||
|
self.light.turn_on(**self.args['state'])
|
||||||
|
|
||||||
|
def handle_door_close(self, entity: str, attribute: str, old: str, new: str, kwargs: dict):
|
||||||
|
self.log('Door close')
|
||||||
|
self.run_in(callback=lambda *args: self.light.turn_off(), delay=30.0)
|
||||||
Reference in New Issue
Block a user