-
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.
Answered by
ALERTua
Jun 2, 2025
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.
2 replies
Answer selected by
khaimong
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can, if you wrap your state trigger in a factory