Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

state_trigger doesn't work but time_trigger and state_status do #692

Answered by agambier
agambier asked this question in Q&A
Discussion options

Hi,

I've installed pyscript and tried a simple script to test it.

The following script works as expected so the entity 'input_boolean.stove_back_to_auto' is the right one.

log.info(f"Loading my script - {input_boolean.stove_back_to_auto}")
@time_trigger("period(now, 1s)")
@state_active("input_boolean.stove_back_to_auto == 'on'")
def hello_world():
 log.info(f"[Pyscript] Envoi notification: ")

But when using only state_trigger it doesn't work at all. I also try @state_trigger("input_boolean.stove_back_to_auto") .

log.info(f"Loading my script - {input_boolean.stove_back_to_auto}")
@state_trigger("input_boolean.stove_back_to_auto=='on'")
def hello_world():
 log.info(f"[Pyscript] Envoi notification: ")

input_boolean.stove_back_to_auto is an helper entity. I try to change its state using the dashboard and developer tools states UI but nothing happens.

Here's the debug log

2025年01月30日 09:15:14.738 DEBUG (Thread-2) [custom_components.pyscript] watchdog process(<FileModifiedEvent: event_type=modified, src_path='/config/pyscript/test.py', is_directory=False)
2025年01月30日 09:15:14.749 DEBUG (Thread-2) [custom_components.pyscript] watchdog process(<DirModifiedEvent: event_type=modified, src_path='/config/pyscript', is_directory=True)
2025年01月30日 09:15:14.802 DEBUG (MainThread) [custom_components.pyscript] reload: yaml, reloading scripts, and restarting
2025年01月30日 09:15:14.810 DEBUG (MainThread) [custom_components.pyscript] No new packages to install
2025年01月30日 09:15:14.814 DEBUG (MainThread) [custom_components.pyscript.eval] file.test: calling info("Loading my script - off", {})
2025年01月30日 09:15:14.814 INFO (MainThread) [custom_components.pyscript.file.test] Loading my script - off
2025年01月30日 09:15:14.815 INFO (MainThread) [custom_components.pyscript.global_ctx] Reloaded /config/pyscript/test.py
2025年01月30日 09:15:14.816 DEBUG (MainThread) [custom_components.pyscript.trigger] trigger file.test.hello_world is active
2025年01月30日 09:15:14.816 DEBUG (MainThread) [custom_components.pyscript.trigger] trigger file.test.hello_world: watching vars {'input_boolean.stove_back_to_auto'}
2025年01月30日 09:15:14.816 DEBUG (MainThread) [custom_components.pyscript.trigger] trigger file.test.hello_world waiting for state change or event

The log book shows the entity is changing.
image

Here are the modules versions:

  • pyscript v1.6.1
  • Core v2025.1.4
  • Supervisor v2024.12.3
  • Operating System v14.2
  • Frontend v20250109.2

I also tried to manually reload pyscript and home assistant but it still doesn't work.
Anything I could try or do to fix it ?

Thanks.

You must be logged in to vote

I've been able to solve it myself.

The pyscript documentation mentions we can configure pyscript using the UI or by editing the configuration.yaml file.
https://hacs-pyscript.readthedocs.io/en/latest/configuration.html#

I did it use the UI...

But it doesn't work. I edited the configuration.yaml file to add...

pyscript:
 allow_all_imports: true
 hass_is_global: true

then I restarted homeassistant and now it works !

So i guess the UI configuration does not work.

there was warnings in the logs and I now I understant it was related to this issue.

Replies: 1 comment

Comment options

I've been able to solve it myself.

The pyscript documentation mentions we can configure pyscript using the UI or by editing the configuration.yaml file.
https://hacs-pyscript.readthedocs.io/en/latest/configuration.html#

I did it use the UI...
image

But it doesn't work. I edited the configuration.yaml file to add...

pyscript:
 allow_all_imports: true
 hass_is_global: true

then I restarted homeassistant and now it works !

So i guess the UI configuration does not work.

there was warnings in the logs and I now I understant it was related to this issue.
image

You must be logged in to vote
0 replies
Answer selected by agambier
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant

AltStyle によって変換されたページ (->オリジナル) /