Warning "homeassistant.helpers.script"

Hellooo

Anyone knows how to find the issue from this warning?

Logger: homeassistant.helpers.script
Source: helpers/script.py:857
First occurred: February 9, 2025 at 13:40:01 (68 occurrences)
Last logged: 14:20:00

Error in 'if[1]' evaluation: In 'template' condition: TypeError: unsupported operand type(s) for -: 'float' and 'NoneType'

As far as I can imagine, the issue is from a helper, but… how can I find the helper which produces this warning?

Thanks!

Looks like it could be a template condition in a script that has an if action.

Check your logbook page for a script that tried to run at 14:20:00

I was looking in the logbook but there is no script at that time or near, only 4 automations, but no script inside them… Some logs are very ambiguous…

Edit: I have watched the trigger time for the scripts as well, nothing near that time

Expand your search. I have found that in recent releases, these log errors are sometimes asynchronous with the error; they typically fire exactly on a minute (:00 seconds) and in some cases it isn’t even the next minute but 2-3 minutes later.

I dislike this behavior because it makes debugging exponentially more difficult.

Helpers here refer to the helpers to the HA core. It is not the same as helpers in the GUI, so check automations, scripts, template sensors and lovelace cards too.

Damn… :frowning: Like it was not enough that the information it is not exactly pointed where you should search, the time is “helping” as well … :frowning: And I was thinking about this, but I didn’t wanted to give credits :smiley:

Even worst… If the log could show the line code with the problem, it could be far easier to know where is the issue… Very useless log

The error message you posted tells you that:

(1) The problem is in the second itemized condition of an if statement (that’s the if[1] part of the error message; and
(2) The problem is in a subtraction expression, where one of the variables is a float but the other is ‘none’.

So apply that criteria. (You’re lucky – sometimes you don’t get this much information.)

(1) Yes, but if you have too many automations/scripts with the if condition… you are lost :smiley:
The same with (2), you can’t know exactly which one is none in that moment, and so on…

I have found the issue, my luck was that the warning was every 10 minutes, exactly 10… and I remebered that I have a timed automation for every 10 minutes… But again, if you don’t have any trace, you are lost in the log.
This log feature is a mess right now. I hope they will work for the log part as well as the other features. It would be great if we can have a log button for every automation/script/entity, anything… And if is something bad happening, to see it with a color, to know where’s the issue…
I think I ask too much, I know :slight_smile: but maybe in the “near” future…

I sounds like a float with no default set, so search for that.

I get the sense that in some cases, improving the error reporting is a challenge.

I’ve resorted to lots and lots of if statements, and a variable naming scheme that indicates the type and whether the variable could be none or undefined.

it’s likely state_attr as the second argument from a change awhile back where attributes now report None when missing. Search for

if:
...
- condition: template
  value_template: "{{ <something> - state_attr(..., ...) }}"