Compare commits
2 Commits
d03a5e8a19
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
798b0321c1 | ||
|
|
dd12a0a5d0 |
@@ -10,6 +10,9 @@ gone:
|
|||||||
- light.h6076
|
- light.h6076
|
||||||
- light.h6076_2
|
- light.h6076_2
|
||||||
|
|
||||||
blue-button:
|
media-buttons:
|
||||||
module: media_button
|
module: media_button
|
||||||
class: Button
|
class: Button
|
||||||
|
buttons:
|
||||||
|
- sensor.blue_lamp_button_action
|
||||||
|
- sensor.aqara1_action
|
||||||
|
|||||||
@@ -13,17 +13,18 @@ class ButtonPress(str, Enum):
|
|||||||
class Button(Hass):
|
class Button(Hass):
|
||||||
def initialize(self):
|
def initialize(self):
|
||||||
self.set_log_level('DEBUG')
|
self.set_log_level('DEBUG')
|
||||||
self.listen_state(
|
for ent in self.args['buttons']:
|
||||||
self.handle_button,
|
self.listen_state(
|
||||||
entity_id='sensor.blue_lamp_button_action',
|
self.handle_button,
|
||||||
new=lambda s: s.strip() != '',
|
entity_id=ent,
|
||||||
)
|
new=lambda s: s.strip() != '',
|
||||||
|
)
|
||||||
|
|
||||||
def handle_button(self, entity: str, attribute: str, old: Any, new: Any, **kwargs: Any) -> None:
|
def handle_button(self, entity: str, attribute: str, old: Any, new: Any, **kwargs: Any) -> None:
|
||||||
match new:
|
match new:
|
||||||
case ButtonPress.SINGLE:
|
case ButtonPress.SINGLE:
|
||||||
self.log('Single press')
|
self.log('Single press')
|
||||||
self.call_service('media_player/media_play_pause', entity_id='media_player.living_room_tv')
|
self.call_service('media_player/media_play_pause', entity_id='media_player.living_room_tv_2')
|
||||||
case ButtonPress.DOUBLE:
|
case ButtonPress.DOUBLE:
|
||||||
self.log('Double')
|
self.log('Double')
|
||||||
self.call_service(
|
self.call_service(
|
||||||
|
|||||||
Reference in New Issue
Block a user