(How) can I trigger a HA automation on pyscript reload?
When a pyscript is updated the reload is logged as
2023-10-07 12:20:33.937 INFO (MainThread) [custom_components.pyscript.global_ctx] Reloaded /config/pyscript/sonnen_time_of_use_plan.py
in the log.
I would like to trigger a HA automation when I update a pyscript. How can I listen to/trigger based on the reloaded event?
https://hacs-pyscript.readthedocs.io/en/stable/reference.html#time-trigger
I hope this helps.
But please use the Discussions tab instead of Issues for questions <3
Thank you, @ALERTua but I need the trigger a HA built-in automation on reload.
I want to create python scripts with no or minimum HA or pyscript specific code so I can unit test them outside HA. So I am creating HA automations that collects states and attributes and call the pyscript as a service. The pysript is returning it's output using the new response_variable feature. And the HA automation is then updating relevant entities..
As a workaround I use the folder_watcher sensor but it triggers too fast so I have to add an artificial delay to wait for the reload.
Per @ALERTua 's suggestion - can't the pyscript call-on-reload function do something than can then trigger an HA built-in automation? Eg, it could set an entity or call a service?