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

@@ -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)