@petro thanks for the feedback. I did restart the HA, in automation editor drop down menu (under Call Service) there was a new entry “python_script.test” which I selected in step-3.
PS: I did not know that restart was not required once the service is created, learnt something new
I am running HA as “unsupervised” on a dedicated Ubuntu 20.10 machine. Perhaps there is a way I can check log files with grep option independently outside HA interface to confirm if these three lines are present in the logs cos I do not see them under HA logs. Do you know which log files I should be checking for this on Ubuntu machine?
Another question, if my python script had imported a new package then normally I would install it using pip before running the script. How does that work in HA?
@petro the output below suggests that python script is working
config $ cat home-assitant.log | grep "Python script triggered from automation"
2020-12-27 03:37:43 INFO (SyncWorker_31) [homeassistant.components.python_script.test.py] Python script triggered from automation
But within HA interface the logs do not even show this entry, in the snippet below about 50-second time window seems blanked out.
20-12-27 11:37:11 INFO (MainThread) [supervisor.api.proxy] Home Assistant WebSocket API request initialize
20-12-27 11:37:11 INFO (MainThread) [supervisor.api.proxy] WebSocket access from a0d7b954_vscode
20-12-27 11:37:11 INFO (MainThread) [supervisor.api.proxy] Home Assistant WebSocket API request running
20-12-27 11:37:13 INFO (MainThread) [supervisor.homeassistant.core] Detect a running Home Assistant instance
20-12-27 11:38:09 INFO (MainThread) [supervisor.api.proxy] Home Assistant WebSocket API connection is closed
20-12-27 11:38:09 INFO (MainThread) [supervisor.api.proxy] Home Assistant WebSocket API request initialize
20-12-27 11:38:09 INFO (MainThread) [supervisor.api.proxy] WebSocket access from a0d7b954_vscode
Is this a UI or log related display issue? If so how to rectify it as I use the logs within HA UI as reference for all work.
Thanks for your input, this has been very helpful.
@PanMat - If you are looking to do a number of Python scripts, and want to get more advanced (ie: full imports etc), then I would recommend looking at AppDaemon. It was suggested to me when I first started out, and have never looked back. No need to restart etc, and it’s out of the way of the typical HA functions as it runs as it’s own process, with it’s own logs etc (but gets all events from HA, and can call back into HA).
@sillyfrog your timing is impeccable, I just started reading the details at https://appdaemon.readthedocs.io/ when your message arrived. Thanks for confirming as it seems like the right direction
Thanks Stefan. As of now AppDaemon seems to be clicking for me, still have lot more to learn but got my scripts working which has added flexibility to add more functionality.
@ReneTode examples/tutorials posted on Github were spot on and thanks for putting content together.