Compare commits

...

4 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
3 changed files with 50 additions and 3 deletions

View File

@@ -9,3 +9,10 @@ gone:
- light.bar
- light.h6076
- 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,6 +1,7 @@
upper_stairs:
module: light
class: StagedLight
activate-at-start: True
stages:
- start: '04:00'
scene:
@@ -31,14 +32,14 @@ upper_stairs:
light.spire:
state: "on"
color_temp_kelvin: 2202
brightness: 60
brightness: 180
- start: '11:00 pm'
scene:
light.bathroom_stairs:
state: "on"
color_temp_kelvin: 2202
brightness: 40
brightness: 60
light.spire:
state: "on"
color_temp_kelvin: 2202
brightness: 40
brightness: 60