Compare commits
7 Commits
fbd60ab6ac
...
moes-pad
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3ae7c2b8e9 | ||
|
|
01c6faa362 | ||
|
|
56ee0c3d3e | ||
|
|
657d01a724 | ||
|
|
e21eca4f42 | ||
|
|
61d5d99dee | ||
|
|
29759692b2 |
@@ -1,6 +1,5 @@
|
||||
appdaemon:
|
||||
uvloop: True
|
||||
use_dictionary_unpacking: True
|
||||
import_method: expert
|
||||
latitude: 30.250968
|
||||
longitude: -97.748193
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
hello-world:
|
||||
module: hello
|
||||
class: HelloWorld
|
||||
|
||||
gone:
|
||||
module: gone
|
||||
class: Gone
|
||||
entities:
|
||||
- light.bar
|
||||
- light.h6076
|
||||
- light.h6076_2
|
||||
|
||||
27
apps/gone.py
Normal file
27
apps/gone.py
Normal file
@@ -0,0 +1,27 @@
|
||||
from typing import Any
|
||||
|
||||
from appdaemon.plugins.hass import Hass
|
||||
|
||||
|
||||
class Gone(Hass):
|
||||
def initialize(self):
|
||||
people = self.get_state('person')
|
||||
# self.log(json.dumps(people, indent=2))
|
||||
|
||||
self.log(list(people.keys()))
|
||||
for person in self.get_state('person'):
|
||||
self.listen_state(self.handle_state, entity_id=person, new='not_home')
|
||||
|
||||
self.log(f'No one home: {self.no_one_home()}')
|
||||
|
||||
def no_one_home(self) -> bool:
|
||||
return all(state.get('state') != 'home' for state in self.get_state('person', copy=False).values())
|
||||
|
||||
def handle_state(self, entity: str, attribute: str, old: Any, new: Any, **kwargs: Any) -> None:
|
||||
if self.no_one_home():
|
||||
for ent in self.args['entities']:
|
||||
try:
|
||||
self.turn_off(ent)
|
||||
except Exception:
|
||||
self.log(f'Failed to turn off {ent}', level='ERROR')
|
||||
continue
|
||||
@@ -2,7 +2,7 @@ bar_lights:
|
||||
module: light
|
||||
class: StagedLight
|
||||
activate-at-start: true
|
||||
transition: 3
|
||||
# transition: 3
|
||||
stages:
|
||||
- start: '03:00 am'
|
||||
scene:
|
||||
@@ -39,13 +39,31 @@ bar_lights:
|
||||
- start: 'sunset'
|
||||
scene:
|
||||
light.bar:
|
||||
state: on
|
||||
state: "on"
|
||||
color_temp_kelvin: 2202
|
||||
brightness: 100
|
||||
light.server_lamp:
|
||||
state: on
|
||||
state: "on"
|
||||
rgb_color: [255, 112, 86]
|
||||
brightness: 175
|
||||
light.living_room_stick:
|
||||
state: "on"
|
||||
brightness: 150
|
||||
effect: sunset
|
||||
- start: 'sunset + 1:00'
|
||||
scene:
|
||||
light.bar:
|
||||
state: on
|
||||
color_temp_kelvin: 2202
|
||||
brightness: 75
|
||||
light.server_lamp:
|
||||
state: "on"
|
||||
rgb_color: [255, 112, 86]
|
||||
brightness: 175
|
||||
light.living_room_stick:
|
||||
state: "on"
|
||||
brightness: 100
|
||||
effect: sunset
|
||||
- start: '10:00 pm'
|
||||
scene:
|
||||
light.bar:
|
||||
@@ -56,6 +74,10 @@ bar_lights:
|
||||
state: on
|
||||
rgb_color: [255, 112, 86]
|
||||
brightness: 75
|
||||
light.living_room_stick:
|
||||
state: "on"
|
||||
brightness: 175
|
||||
effect: sunset
|
||||
- start: '11:30 pm'
|
||||
scene:
|
||||
light.bar:
|
||||
@@ -63,4 +85,10 @@ bar_lights:
|
||||
color_temp_kelvin: 2202
|
||||
brightness: 30
|
||||
light.server_lamp:
|
||||
state: off
|
||||
state: on
|
||||
rgb_color: [255, 112, 86]
|
||||
brightness: 25
|
||||
light.living_room_stick:
|
||||
state: "on"
|
||||
brightness: 75
|
||||
effect: sunset
|
||||
|
||||
@@ -69,15 +69,15 @@ class StagedLight(Hass):
|
||||
|
||||
### Transitions
|
||||
|
||||
def schedule_transition_checks(self, **kwargs: Any):
|
||||
def schedule_transition_checks(self, **_):
|
||||
now = self.get_now()
|
||||
for stage in self._stages:
|
||||
dt = self.parse_datetime(stage.start, aware=True, today=True)
|
||||
if dt > now:
|
||||
self.log(f'Scehduling transition at: {dt.isoformat()}', level='DEBUG')
|
||||
self.log(f'Scehduling transition at: {dt.strftime("%I:%M %p")}', level='DEBUG')
|
||||
self.run_at(self._check_transition, start=dt)
|
||||
|
||||
def _check_transition(self, **kwargs: Any):
|
||||
def _check_transition(self, **_):
|
||||
self.log('Firing transition event', level='DEBUG')
|
||||
self.fire_event(
|
||||
'stage_control',
|
||||
|
||||
Reference in New Issue
Block a user