nuki47
(Nuki47)
January 14, 2022, 8:27am
1
I would like to start with my first python script “hello world” from this documentation: Python Scripts - Home Assistant
In my config.yaml i changed the logger to:
logger:
default: warning
logs:
homeassistant.components.python_script: info
But I don’t get any output in the logfile, what’s going wrong?
Developer Tools
python script
name = data.get("name", "world")
logger.info("Hello %s", name)
hass.bus.fire(name, {"wow": "from a Python script!"})
VDRainer
(🍻)
January 14, 2022, 12:21pm
2
You will not see info logs if you set the logger default to warnings.
Either set the logger to info
default: info
or your script to send warnings
logger.warning("Hello %s", name)
petro
(Petro)
January 14, 2022, 12:52pm
3
It should if it outputs to [homeassistant.components.python_script]
, his configuration for the python_script section is set to info.
However, that will show logger info from the [homeassistant.components.python_script]
log output. It’s been awhile since I’ve ran a python script, but logger may not output to [homeassistant.components.python_script]
for python scripts.
1 Like
nuki47
(Nuki47)
January 14, 2022, 1:00pm
4
If I change the code to
logger:
default: info
logs:
homeassistant.components.python_script: info
there is also no output into the Log (Configurations>Logs)
petro
(Petro)
January 14, 2022, 1:04pm
5
Look at your log file, not the UI. Also, when you change log levels, you need to restart or reload the logger integration.
petro
(Petro)
January 14, 2022, 1:07pm
7
Nothing to be sorry about, it’s confusing if you’ve never used it. I try to supply the most amount of information to the information suppliers
nuki47
(Nuki47)
January 14, 2022, 1:12pm
8
Thank you…and sorry, I am a beginner with python.
I always have done the restart after changes in config.yaml
In the logfile (config/home-assistant.log) I can find only this line:
2022-01-14 13:58:26 INFO (SyncWorker_11) [homeassistant.components.python_script.hello_world.py] Hello world
petro
(Petro)
January 14, 2022, 1:18pm
9
That’s showing that it’s working. And if you want to setup your logger properly…
logger:
default: warning
logs:
homeassistant.components.python_script.hello_world.py: info
1 Like