Both of the triggger do not work (see screenshot of the automation):
(1) Trigger on the 0th second of the 1st minute of the 0th hour
(2) When Home Assistant is started
However when I hit run actions manually it works.
Can anyone let me know how to set the triggers correctly?
“Run actions” skips the automation’s triggers (and conditions) and only executes its actions. It confirmed the action works but it hasn’t tested the triggers.
Check the Logs for related errors (reported at 00:01:00 and whenever Home Assistant was restarted) and check the automation’s traces.
Thanks. Interesting, looks like the python script gets executed before the read in sensor state?! I am going to change the code to make sure it is always a float. Let’s see.
see Log:
This error originated from a custom integration.
Logger: custom_components.python_script
Source: custom_components/python_script/init.py:107
integration: Python Scripts Pro (documentation, issues)
First occurred: 3:27:49 PM (1 occurrences)
Last logged: 3:27:49 PM
Error executing script
Traceback (most recent call last):
File “/config/custom_components/python_script/init.py”, line 107, in execute_script
exec(code, vars)
~~~~^^^^^^^^^^^^
File “/config/python_scripts/voltage_to_soc.py”, line 729, in
input_val_x = float(hass.states.get(“sensor.ss_battery_voltage”).state[:])
ValueError: could not convert string to float: ‘unavailable’
Adding a try except handling to the python script for reading in other sensor values does the job. So even the re-start HA trigger is not able to solve the final problem, it restarts the script and the other polling trigger is able to read in the sensor.
That’s entirely possible. On startup, integrations are loaded sequentially so it’s possible the Automation integration was loaded before whatever integration is responsible for initializing sensor.ss_battery_voltage.
This would explain failure when triggered on startup. However you said both triggers failed. So why did it fail when triggered at 00:01:00? Is it because it’s common for the sensor’s state to become unavailable?
Wrong parameter setup. It was not executed at all I reckon. In my 2nd screenshot I changed it to 20 sec polling. Anyway that try catch was necessary by all means due to the reason I mentioned above.
It can’t be an incorrect Time Trigger because the screenshot you posted clearly indicates it understood the trigger’s purpose: “Trigger on the 0th second of the first minute of the 0th hour”.
That’s this:
triggers:
- trigger: time
at: '00:01:00'
The topic’s title claims neither trigger fired which is surprising because they’re very simple triggers. It appears that the restart trigger did fire but the python script failed because it didn’t handle the possibility that the sensor’s value could be unavailable.
Check the automation’s traces for the one recorded at 00:01:00.
If it doesn’t exist then it means the automation never triggered at the scheduled time or the trace is too old and has already been discarded. It keeps a record of the last 5 traces.