Skip to content

Variables for state_hold ? #727

Answered by ALERTua
khaimong asked this question in General
Jun 2, 2025 · 1 comments · 2 replies
Discussion options

You must be logged in to vote

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

Comment options

You must be logged in to vote
2 replies
@ALERTua
Comment options

@khaimong
Comment options

Answer selected by khaimong
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants