Compare commits
4 Commits
610c2b68e2
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
798b0321c1 | ||
|
|
dd12a0a5d0 | ||
|
|
d03a5e8a19 | ||
|
|
699d314862 |
@@ -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
39
apps/media_button.py
Normal 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')
|
||||||
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user