-
Notifications
You must be signed in to change notification settings - Fork 58
-
Is there any way to use a variable for state_hold in a trigger? i.e. instead of using a constant integer seconds, the ability to use a defined "input_integer.xxx" to define the hold time
Beta Was this translation helpful? Give feedback.
All reactions
Answered by
ALERTua
Jun 2, 2025
You can, if you wrap your state trigger in a factory
registered_setup_example_app = {} def setup_example_app(entity_id: str): task_name = f"{__name__}_{entity_id}" state_hold_value = int(state.get('input_integer.xxx')) @state_trigger( entity_id, watch=[entity_id], state_hold=state_hold_value, ) def fnc_trigger(trigger_type=None, var_name=None, value=None, old_value=None, context=None, **kwargs): task.unique(task_name) log.info(f"{task_name}: {old_value}->{var_name}->{value}") registered_setup_example_app[task_name] = fnc_trigger @time_trigger('once(now)') def gen(): for config in pyscript.app_config: s...
Replies: 1 comment 2 replies
-
You can, if you wrap your state trigger in a factory
registered_setup_example_app = {} def setup_example_app(entity_id: str): task_name = f"{__name__}_{entity_id}" state_hold_value = int(state.get('input_integer.xxx')) @state_trigger( entity_id, watch=[entity_id], state_hold=state_hold_value, ) def fnc_trigger(trigger_type=None, var_name=None, value=None, old_value=None, context=None, **kwargs): task.unique(task_name) log.info(f"{task_name}: {old_value}->{var_name}->{value}") registered_setup_example_app[task_name] = fnc_trigger @time_trigger('once(now)') def gen(): for config in pyscript.app_config: setup_example_app(**config)
Beta Was this translation helpful? Give feedback.
All reactions
2 replies
-
but you will also need to trigger on the input_integer.xxx
state change and execute pyscript.reload
Beta Was this translation helpful? Give feedback.
All reactions
-
Thank you very much! It's more wordy than what I expected, but it will do.
Beta Was this translation helpful? Give feedback.
All reactions
-
❤️ 1
Answer selected by
khaimong
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment