app changes, including initial tap dial
This commit is contained in:
@@ -1,3 +1,21 @@
|
|||||||
hello_world:
|
hello_world:
|
||||||
module: hello
|
module: hello
|
||||||
class: HelloWorld
|
class: HelloWorld
|
||||||
|
|
||||||
|
my_tap_dial:
|
||||||
|
module: tap_dial
|
||||||
|
class: TapDial
|
||||||
|
entity: sensor.tap_dial_action
|
||||||
|
step_size: 25
|
||||||
|
button1: light.stick_lamp
|
||||||
|
button2: light.wet_bar
|
||||||
|
button3: light.monkey_lamp
|
||||||
|
button4: light.kitchen_candlelabra
|
||||||
|
|
||||||
|
|
||||||
|
piano_button:
|
||||||
|
module: button_switch
|
||||||
|
class: AqaraSwitch
|
||||||
|
button: sensor.button02_action
|
||||||
|
switch: switch.keyboards
|
||||||
|
# action: double
|
||||||
|
|||||||
20
apps/button_switch.py
Normal file
20
apps/button_switch.py
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
from appdaemon.entity import Entity
|
||||||
|
from appdaemon.plugins.hass.hassapi import Hass
|
||||||
|
|
||||||
|
|
||||||
|
class AqaraSwitch(Hass):
|
||||||
|
def initialize(self):
|
||||||
|
self.log(f'Initializing Aqara Switch for {self.switch.friendly_name}')
|
||||||
|
self.button.listen_state(self.handle_button_press, new=self.args.get('action', 'single'))
|
||||||
|
|
||||||
|
@property
|
||||||
|
def switch(self) -> Entity:
|
||||||
|
return self.get_entity(self.args['switch'])
|
||||||
|
|
||||||
|
@property
|
||||||
|
def button(self) -> Entity:
|
||||||
|
return self.get_entity(self.args['button'])
|
||||||
|
|
||||||
|
def handle_button_press(self, entity: str, attribute: str, old: str, new: str, **kwargs):
|
||||||
|
# self.log(f'{new}')
|
||||||
|
self.switch.toggle()
|
||||||
@@ -1,68 +0,0 @@
|
|||||||
living_room:
|
|
||||||
module: room_control
|
|
||||||
class: RoomController
|
|
||||||
# rich: DEBUG
|
|
||||||
off_duration: 00:10:00
|
|
||||||
manual_mode: input_boolean.living_room_manual_mode
|
|
||||||
states:
|
|
||||||
- time: sunrise
|
|
||||||
off_duration: 00:15:00
|
|
||||||
scene:
|
|
||||||
light.living_room_lamps:
|
|
||||||
state: on
|
|
||||||
color_temp: 200
|
|
||||||
brightness: 255
|
|
||||||
light.white05:
|
|
||||||
state: on
|
|
||||||
color_temp: 200
|
|
||||||
brightness: 190
|
|
||||||
light.living_room_floodlights:
|
|
||||||
state: off
|
|
||||||
- time: '18:00:00'
|
|
||||||
off_duration: 01:00:00
|
|
||||||
scene:
|
|
||||||
light.living_room_lamps:
|
|
||||||
state: on
|
|
||||||
color_temp: 300
|
|
||||||
brightness: 190
|
|
||||||
light.living_room_floodlights:
|
|
||||||
state: off
|
|
||||||
- time: '23:00:00'
|
|
||||||
off_duration: 00:00:30
|
|
||||||
scene:
|
|
||||||
light.living_room_lamps:
|
|
||||||
state: on
|
|
||||||
color_temp: 400
|
|
||||||
brightness: 125
|
|
||||||
light.white05:
|
|
||||||
state: off
|
|
||||||
light.living_room_floodlights:
|
|
||||||
state: off
|
|
||||||
# sleep: input_boolean.sleeping
|
|
||||||
# sleep_state:
|
|
||||||
# scene:
|
|
||||||
# light.colorflood05:
|
|
||||||
# state: 'on'
|
|
||||||
# color_name: 'red'
|
|
||||||
# brightness: 10
|
|
||||||
|
|
||||||
# front_door:
|
|
||||||
# module: door
|
|
||||||
# class: Door
|
|
||||||
# app: living_room
|
|
||||||
# door: binary_sensor.front_contact
|
|
||||||
|
|
||||||
living_room_button:
|
|
||||||
module: button
|
|
||||||
class: Button
|
|
||||||
app: living_room
|
|
||||||
manual_mode: input_boolean.living_room_manual_mode
|
|
||||||
button: button01
|
|
||||||
ref_entity: light.color04
|
|
||||||
|
|
||||||
living_room_motion:
|
|
||||||
module: motion
|
|
||||||
class: Motion
|
|
||||||
app: living_room
|
|
||||||
sensor: binary_sensor.living_room_motion
|
|
||||||
ref_entity: light.color04
|
|
||||||
@@ -1,84 +0,0 @@
|
|||||||
mancave:
|
|
||||||
module: room_control
|
|
||||||
class: RoomController
|
|
||||||
# rich: DEBUG
|
|
||||||
off_duration: 00:00:10
|
|
||||||
manual_mode: input_boolean.mancave_manual_mode
|
|
||||||
states:
|
|
||||||
- time: sunrise
|
|
||||||
scene:
|
|
||||||
light.color01:
|
|
||||||
state: on
|
|
||||||
color_temp: 200
|
|
||||||
brightness: 255
|
|
||||||
light.colorflood05:
|
|
||||||
state: off
|
|
||||||
light.color03:
|
|
||||||
state: off
|
|
||||||
light.white08:
|
|
||||||
color_temp: 300
|
|
||||||
brightness: 175
|
|
||||||
light.wled_soundreactive:
|
|
||||||
state: off
|
|
||||||
preset: 'Stream'
|
|
||||||
- time: '18:00:00'
|
|
||||||
scene:
|
|
||||||
light.color01:
|
|
||||||
state: on
|
|
||||||
rgb_color: [255, 193, 193]
|
|
||||||
brightness: 255
|
|
||||||
light.colorflood05:
|
|
||||||
state: on
|
|
||||||
rgb_color: [255, 193, 193]
|
|
||||||
brightness: 170
|
|
||||||
light.color03:
|
|
||||||
state: off
|
|
||||||
light.white08:
|
|
||||||
state: on
|
|
||||||
color_temp: 400
|
|
||||||
brightness: 70
|
|
||||||
light.wled_soundreactive:
|
|
||||||
state: on
|
|
||||||
preset: 'WashingMachine'
|
|
||||||
- time: '23:00:00'
|
|
||||||
scene:
|
|
||||||
light.color01:
|
|
||||||
state: on
|
|
||||||
color_temp: 400
|
|
||||||
brightness: 125
|
|
||||||
light.colorflood05:
|
|
||||||
state: off
|
|
||||||
light.color03:
|
|
||||||
state: off
|
|
||||||
light.white08:
|
|
||||||
state: off
|
|
||||||
light.wled_soundreactive:
|
|
||||||
state: off
|
|
||||||
# sleep: input_boolean.sleeping
|
|
||||||
# sleep_state:
|
|
||||||
# scene:
|
|
||||||
# light.colorflood05:
|
|
||||||
# state: 'on'
|
|
||||||
# color_name: 'red'
|
|
||||||
# brightness: 10
|
|
||||||
|
|
||||||
# front_door:
|
|
||||||
# module: door
|
|
||||||
# class: Door
|
|
||||||
# app: living_room
|
|
||||||
# door: binary_sensor.front_contact
|
|
||||||
|
|
||||||
mancave_button:
|
|
||||||
module: button
|
|
||||||
class: Button
|
|
||||||
app: mancave
|
|
||||||
manual_mode: input_boolean.mancave_manual_mode
|
|
||||||
button: button07
|
|
||||||
ref_entity: light.color01
|
|
||||||
|
|
||||||
mancave_motion:
|
|
||||||
module: motion
|
|
||||||
class: Motion
|
|
||||||
app: mancave
|
|
||||||
sensor: binary_sensor.motionsensors01_occupancy
|
|
||||||
ref_entity: light.color01
|
|
||||||
47
apps/tap_dial.py
Normal file
47
apps/tap_dial.py
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
import re
|
||||||
|
|
||||||
|
from appdaemon.entity import Entity
|
||||||
|
from appdaemon.plugins.hass.hassapi import Hass
|
||||||
|
|
||||||
|
|
||||||
|
BUTTON_PRESS = re.compile(r'button_(\d)_press_release')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class TapDial(Hass):
|
||||||
|
active_entity: Entity
|
||||||
|
|
||||||
|
def initialize(self):
|
||||||
|
self.log(f"Action entity: {self.tap_dial_entity.friendly_name}")
|
||||||
|
self.tap_dial_entity.listen_state(self.my_callback)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def tap_dial_entity(self) -> Entity:
|
||||||
|
return self.get_entity(self.args["entity"])
|
||||||
|
|
||||||
|
@property
|
||||||
|
def step_size(self) -> int:
|
||||||
|
return int(self.args.get("step_size", 25))
|
||||||
|
|
||||||
|
def my_callback(self, entity: str, attribute: str, old: str, new: str, **kwargs):
|
||||||
|
# self.log(f'{new}')
|
||||||
|
if new:
|
||||||
|
if m := BUTTON_PRESS.match(new):
|
||||||
|
pressed_button = int(m.group(1))
|
||||||
|
self.log(f'Pressed button {pressed_button}')
|
||||||
|
|
||||||
|
if associated_light := self.args.get(f'button{pressed_button}'):
|
||||||
|
light_entity = self.get_entity(associated_light)
|
||||||
|
self.active_entity = light_entity
|
||||||
|
self.log(f'Setting active entity to {self.active_entity.friendly_name}')
|
||||||
|
self.active_entity.toggle()
|
||||||
|
|
||||||
|
match new:
|
||||||
|
case "dial_rotate_right_step":
|
||||||
|
b = self.active_entity.attributes['brightness']
|
||||||
|
self.active_entity.turn_on(brightness=b+self.step_size)
|
||||||
|
case "dial_rotate_left_step":
|
||||||
|
b = self.active_entity.attributes['brightness']
|
||||||
|
self.active_entity.turn_on(brightness=b-self.step_size)
|
||||||
|
# case _:
|
||||||
|
# self.log(f'Unhandled action: {new}')
|
||||||
Reference in New Issue
Block a user