Initial public release

This commit is contained in:
ajp_anton
2026-05-30 15:44:40 +00:00
commit cc4e0c2c0f
56 changed files with 11840 additions and 0 deletions
+70
View File
@@ -0,0 +1,70 @@
from ha_deconz_bridge.automation import ActionSpec, automation_rules
def kelvin_to_mireds(kelvin: int) -> int:
return int(round(1_000_000 / kelvin))
def scene(target: str, *, brightness: int, kelvin: int) -> ActionSpec:
return ActionSpec(
"set_scene",
target=target,
brightness=brightness,
color_temp=kelvin_to_mireds(kelvin),
)
def all_lights_scene(*, brightness: int, kelvin: int) -> tuple[ActionSpec, ...]:
return (
scene("Example Living", brightness=brightness, kelvin=kelvin),
scene("Example Hall", brightness=brightness, kelvin=kelvin),
scene("Example Kitchen", brightness=brightness, kelvin=kelvin),
scene("Example Bathroom", brightness=brightness, kelvin=kelvin),
scene("Example Bedroom", brightness=brightness, kelvin=kelvin),
)
def all_lights_off() -> tuple[ActionSpec, ...]:
return (
ActionSpec("turn_off", target="Example Living"),
ActionSpec("turn_off", target="Example Hall"),
ActionSpec("turn_off", target="Example Kitchen"),
ActionSpec("turn_off", target="Example Bathroom"),
ActionSpec("turn_off", target="Example Bedroom"),
)
def room_automation(room: str) -> dict[str, dict[str, tuple[ActionSpec, ...]]]:
return {
"top": {
"single": (scene(room, brightness=255, kelvin=4000),),
"double": (scene(room, brightness=255, kelvin=5500),),
"hold": all_lights_scene(brightness=255, kelvin=4000),
"double_hold": all_lights_scene(brightness=255, kelvin=5500),
},
"up": {
"single": (scene(room, brightness=153, kelvin=3000),),
"double": (scene(room, brightness=204, kelvin=3500),),
"hold": (ActionSpec("brightness_step", target=room, brightness_step=26),),
},
"down": {
"single": (scene(room, brightness=51, kelvin=2200),),
"double": (scene(room, brightness=102, kelvin=2500),),
"hold": (ActionSpec("brightness_step", target=room, brightness_step=-26),),
},
"bottom": {
"single": (ActionSpec("turn_off", target=room),),
"hold": all_lights_off(),
},
}
AUTOMATION_CONFIG = {
"example_living_remote": room_automation("Example Living"),
"example_kitchen_remote": room_automation("Example Kitchen"),
"example_hall_remote": room_automation("Example Hall"),
"example_bathroom_remote": room_automation("Example Bathroom"),
"example_bedroom_remote": room_automation("Example Bedroom"),
}
AUTOMATIONS = automation_rules(AUTOMATION_CONFIG)