Compare commits

...

6 Commits

Author SHA1 Message Date
John Lancaster
798b0321c1 refactored buttons 2025-12-30 18:11:04 -06:00
John Lancaster
dd12a0a5d0 udpated media button target 2025-12-29 18:42:26 -06:00
John Lancaster
d03a5e8a19 adjusted stages for stairs 2025-12-20 21:16:59 -06:00
John Lancaster
699d314862 added the blue button app 2025-12-15 22:12:12 -06:00
John Lancaster
610c2b68e2 updated patio stages 2025-12-12 17:42:51 -06:00
John Lancaster
27db3be4a0 rename 2025-12-12 17:42:42 -06:00
6 changed files with 62 additions and 8 deletions

View File

@@ -9,3 +9,10 @@ gone:
- light.bar - light.bar
- light.h6076 - light.h6076
- light.h6076_2 - light.h6076_2
media-buttons:
module: media_button
class: Button
buttons:
- sensor.blue_lamp_button_action
- sensor.aqara1_action

39
apps/media_button.py Normal file
View File

@@ -0,0 +1,39 @@
from enum import Enum
from typing import Any
from appdaemon.plugins.hass import Hass
class ButtonPress(str, Enum):
SINGLE = 'single'
DOUBLE = 'double'
HOLD = 'hold'
class Button(Hass):
def initialize(self):
self.set_log_level('DEBUG')
for ent in self.args['buttons']:
self.listen_state(
self.handle_button,
entity_id=ent,
new=lambda s: s.strip() != '',
)
def handle_button(self, entity: str, attribute: str, old: Any, new: Any, **kwargs: Any) -> None:
match new:
case ButtonPress.SINGLE:
self.log('Single press')
self.call_service('media_player/media_play_pause', entity_id='media_player.living_room_tv_2')
case ButtonPress.DOUBLE:
self.log('Double')
self.call_service(
'scene/apply',
entities={
'light.bar': {'state': 'on', 'brightness': 10},
'light.living_room_stick': {'state': 'on', 'brightness': 100},
'light.server_lamp': {'state': 'on', 'brightness': 25},
},
)
case ButtonPress.HOLD:
self.log('Hold down')

View File

@@ -1,8 +1,8 @@
bar_lights: main_floor:
module: light module: light
class: StagedLight class: StagedLight
activate-at-start: true activate-at-start: true
# transition: 3 transition: 3
stages: stages:
- start: '03:00 am' - start: '03:00 am'
scene: scene:

7
apps/stages/patio.py Normal file
View File

@@ -0,0 +1,7 @@
from light import StagedLight
class Patio(StagedLight):
def initialize(self):
super().initialize()
self.run_daily(lambda **kwargs: self.turn_on('light.patio', brightness=100), start='sunset - 31s')

View File

@@ -1,8 +1,8 @@
patio: patio:
module: light module: patio
class: StagedLight class: Patio
activate-at-start: true activate-at-start: true
transition: 5 transition: 30
stages: stages:
- start: '01:00 am' - start: '01:00 am'
scene: scene:

View File

@@ -1,6 +1,7 @@
upper_stairs: upper_stairs:
module: light module: light
class: StagedLight class: StagedLight
activate-at-start: True
stages: stages:
- start: '04:00' - start: '04:00'
scene: scene:
@@ -31,14 +32,14 @@ upper_stairs:
light.spire: light.spire:
state: "on" state: "on"
color_temp_kelvin: 2202 color_temp_kelvin: 2202
brightness: 60 brightness: 180
- start: '11:00 pm' - start: '11:00 pm'
scene: scene:
light.bathroom_stairs: light.bathroom_stairs:
state: "on" state: "on"
color_temp_kelvin: 2202 color_temp_kelvin: 2202
brightness: 40 brightness: 60
light.spire: light.spire:
state: "on" state: "on"
color_temp_kelvin: 2202 color_temp_kelvin: 2202
brightness: 40 brightness: 60