sleep setter update
This commit is contained in:
@@ -18,7 +18,7 @@ class SleepSetter(hass.Hass):
|
||||
|
||||
def handle_state(self, entity, attribute, old, new, kwargs):
|
||||
self.log(f'{entity}: {old} -> {new}')
|
||||
if self.state and self.sun_elevation < -10:
|
||||
if self.state and self.sun_elevation < float(self.args['elevation_limit']):
|
||||
self.all_off()
|
||||
self.turn_on(self.scene)
|
||||
|
||||
@@ -68,7 +68,15 @@ class SleepSetter(hass.Hass):
|
||||
self.log(f'Ignoring event because sun elevation {elev} > 0')
|
||||
|
||||
def all_off(self):
|
||||
self.log(f'Turning off')
|
||||
self.log(f'Deactivating apps')
|
||||
for app_name in self.args['off_apps']:
|
||||
try:
|
||||
self.get_app(app_name).deactivate()
|
||||
except:
|
||||
self.log(f'Failed to deactivate {app_name}')
|
||||
continue
|
||||
|
||||
self.log(f'Turning off entities')
|
||||
for entity in self.args['off_entities']:
|
||||
try:
|
||||
self.turn_off(entity)
|
||||
|
||||
@@ -1,17 +1,18 @@
|
||||
sleep:
|
||||
module: sleep
|
||||
class: SleepSetter
|
||||
elevation_limit: -10
|
||||
scene: in_bed
|
||||
variable: input_boolean.sleeping
|
||||
button:
|
||||
- Bedroom Button 1
|
||||
- Bedroom Button 2
|
||||
- Living Room Button
|
||||
off_apps:
|
||||
- bedroom
|
||||
- bedroom2
|
||||
- living_room
|
||||
- kitchen
|
||||
- bathroom
|
||||
off_entities:
|
||||
- light.living_room
|
||||
- light.bathroom
|
||||
- light.patio
|
||||
- light.closet
|
||||
- light.kitchen
|
||||
- light.couch_corner
|
||||
- light.globe
|
||||
|
||||
Reference in New Issue
Block a user