This commit is contained in:
2026-08-07 10:09:42 +02:00
parent 52d11bfff0
commit 52442c50f1
15 changed files with 827 additions and 252 deletions

View File

@@ -35,7 +35,7 @@ def kz_regal_scenes():
entity = "light.music_mouse_regal_licht"
def fade_out_f(rgb_color, seconds):
return multiple_f(cover_f("close_cover", "cover_kinderzimmer_rollo"),
return multiple_f(cover_f("close_cover", "cover.kinderzimmer_rollo"),
light_f("turn_on", entity, brightness=250, rgb_color=rgb_color, effect="side_0.5"),
light_f("turn_on", entity, brightness= 10, rgb_color=rgb_color, effect="side_0.5_inc4", transition=int(0.8 * seconds)),
light_f("turn_on", entity, brightness= 10, rgb_color=rgb_color, effect="side_0.2_inc8", transition=int(0.2 * seconds))),
@@ -46,7 +46,7 @@ def kz_regal_scenes():
fade_out_f([255, 98, 231], 10 * 60),
light_f("turn_off", entity)
]
else:
else:
scenes = [
light_f("turn_on", entity, brightness=250, rgb_color=[255, 182, 41], effect="static"),
light_f("turn_on", entity, brightness=250, rgb_color=[255, 98, 231], effect="static"),
@@ -154,8 +154,10 @@ def on_ios_action_fired(actionName, **kwargs):
if actionName == "az_oben_licht":
scene_helper(az_oben_licht_scenes)
elif actionName == "kz_regal":
log.info("KZ Regal action fired")
scene_helper(kz_regal_scenes)
elif actionName == "az_unten_licht":
log.info("AZ unten Licht action fired")
scene_helper(az_unten_licht_scenes)
elif actionName == "wz_deckenlampe":
scene_helper(wz_deckenlampe)
@@ -205,17 +207,52 @@ def on_ios_shortcut_event(room, action, device, **kwargs):
elif action == "hass_cover_half":
cover_half.set_half(entity_id="cover.arbeitszimmer_rollo")
if room in ("küche", "esszimmer", "sofa", "wohnzimmer"):
if action == "hass_light_off":
light_f('turn_off', "group.living_area")()
elif action == "hass_light_orange":
scene_f("wohnbereich_orange")()
elif action == "hass_light_blue":
scene_f("wohnbereich_blau_grun")()
elif action == "hass_light_bright":
scene_f("wohnbereich_hell")()
elif action == "hass_light_darken":
dimmer.dim(entity_id="group.living_area", offset=-80)
elif action == "hass_light_brighten":
dimmer.dim(entity_id="group.living_area", offset=80)
elif action == "hass_light_off":
light.turn_off(entity_id="group.living_area")
elif action == "hass_cover_open":
cover.open_cover(entity_id="group.living_area")
elif action == "hass_cover_close":
cover.close_cover(entity_id="group.living_area")
elif action == "hass_cover_half":
cover_half.set_half(entity_id="group.living_area")
elif action == "hass_sun_blinds":
cover_half.set_half(entitiy_id="cover.wohnzimmer_fenster_rollo")
if room == "kinderzimmer":
if action == "hass_cover_open":
cover.open_cover(area_id="kinderzimmer")
elif action == "hass_cover_close":
cover.close_cover(area_id="kinderzimmer")
if room == "buero_oben":
entity = "scene.arbeitszimmer_orange"
if action == "hass_light":
scene_helper(az_oben_licht_scenes)
elif action == "hass_light_orange":
light_f("turn_on", entity, color_temp=470, brightness=100)()
elif action == "hass_light_blue":
light_f("turn_on", entity, color_temp=180, brightness=230)()
elif action == "hass_light_darken":
dimmer.dim(entity_id=entity, offset=-30)
elif action == "hass_light_brighten":
dimmer.dim(entity_id=entity, offset=30)
elif action == "hass_light_off":
light.turn_off(entity_id=entity)
light.turn_off(entity_id="light.arbeitszimmer_oben_fluter")
elif action == "hass_light_orange":
scene_f("arbeitszimmer_oben_orange")()
elif action == "hass_light_blue":
scene_f("arbeitszimmer_oben_blau")()
elif action == "hass_light_darken":
dimmer.dim(entity_id="light.arbeitszimmer_oben_fluter", offset=-80)
elif action == "hass_light_brighten":
dimmer.dim(entity_id="light.arbeitszimmer_oben_fluter", offset=80)
elif action == "hass_light_off":
light.turn_off(entity_id="light.arbeitszimmer_oben_fluter")
elif action == "hass_cover_open":
cover.open_cover(area_id="arbeitszimmeroben")
elif action == "hass_cover_close":
cover.close_cover(area_id="arbeitszimmeroben")

View File

@@ -71,15 +71,17 @@ def esszimmer_gangtuer(entity_id=None, event_type=None):
covers = ['group.living_area']
if key == "arrow_down":
if long_click:
vacuum("Esszimmer")
else:
cover_half.set_half(entity_id=covers)
cover_half.set_half(entity_id=covers)
#if long_click:
# vacuum("Esszimmer")
#else:
# cover_half.set_half(entity_id=covers)
elif key == "arrow_up":
if long_click:
vacuum("Küche")
else:
cover.open_cover(entity_id=covers)
cover.open_cover(entity_id=covers)
#if long_click:
# vacuum("Küche")
#else:
# cover.open_cover(entity_id=covers)
elif key == "bulb_orange":
if long_click:
scene.kuche_essbereich_orange.turn_on()
@@ -114,15 +116,17 @@ def wohnzimmer_gangtur(entity_id=None, event_type=None):
covers = ['group.living_area']
if key == "arrow_down":
if long_click:
vacuum("Wohnzimmer")
else:
cover_half.set_half(entity_id=covers)
cover_half.set_half(entity_id=covers)
#if long_click:
# vacuum("Wohnzimmer")
#else:
# cover_half.set_half(entity_id=covers)
elif key == "arrow_up":
if long_click:
vacuum("Wohnzimmer")
else:
cover.open_cover(entity_id=covers)
cover.open_cover(entity_id=covers)
#if long_click:
# vacuum("Wohnzimmer")
#else:
# cover.open_cover(entity_id=covers)
elif key == "bulb_orange":
if long_click:
scene.wohnzimmer_orange.turn_on()

View File

@@ -61,6 +61,8 @@ def cover_half_f(entity_id):
def light_f(name, entity_id, **kwargs):
if 'color_temp' in kwargs:
kwargs['color_temp_kelvin'] = round(1_000_000 / kwargs.pop('color_temp'))
async def f():
await hass.services.async_call('light', name, {'entity_id': entity_id, **kwargs})
return f
@@ -133,7 +135,7 @@ class CyclicCounter:
TIMEOUT_REPEAT_PRESS = 5 # time to switch states when pressed shortly in sequence, in seconds
TIMEOUT_REPEAT_PRESS = 3 # time to switch states when pressed shortly in sequence, in seconds
# --------------------------------- Helper functions ----------------------------------------------------
@@ -144,7 +146,7 @@ def scene_helper(scene_function):
Otherwise light is toggled"""
unique_name_for_globals = id(scene_function)
is_on_func, scenes = scene_function()
last_called, call_idx = light_scene_helper_dict.get(unique_name_for_globals, (datetime.now(), -1))
last_called, call_idx = light_scene_helper_dict.get(unique_name_for_globals, (datetime.now(), -1))
now = datetime.now()
time_since_last_call = now - last_called
recently_called = (time_since_last_call < timedelta(seconds=TIMEOUT_REPEAT_PRESS))
@@ -161,8 +163,8 @@ def scene_helper(scene_function):
elif not light_already_on:
scenes[0]()
call_idx = 0
else:
else:
idx = call_idx % len(scenes)
scenes[idx]()
light_scene_helper_dict[unique_name_for_globals] = (now, call_idx)
light_scene_helper_dict[unique_name_for_globals] = (now, call_idx)