Skip to content

state_hold in version 2.0 doesn't work in all cases, but still works with legacy_decorators: true #845

@Einixx

Description

@Einixx

First of all, thanks for all the great work.
I have been using pyscript for years and do pretty much all automation with it.
I got a trigger if a new movie or episode is played to write it into a database. To avoid too many entries if I accidentally start an episode, I use state_hold to give it a few seconds

@state_trigger("media_player.kodi == 'playing' ", state_hold=10)
def kodi_mark_watched():
log.debug(f"KODI Media Position: {state.get('media_player.kodi.media_position')} ")
...

This worked fine with previous pyscript versions. Now I updated to 2.0. and it doesn´t trigger at all. If i remove the state_hold=10 argument, it triggers. I also tried the legacy_decorators: true in pyscript.yaml and now it works again.

What puzzles me is the fact that I use it in other parts of my code, and it is working as expected:
@state_trigger("media_player.kodi == 'playing' and input_boolean.mode_night == 'on' ", state_hold=42)
def kodi_playing():
pyscript.light_on( device='light.tv_strip', red=242, green=175, blue=35, bright=30, trans=5)
pyscript.light_on( device='light.livingroom_bulb', red=242, green=175, blue=35, bright=20, trans=5)

How could I assist to debug that?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions