How to find this unsupported condition

I’m seeing this error in my logs from time to time, but have not been able to associate it with any specific automations. I feel like I’ve looked at the handful of OR conditions I have set up and nothing is jumping out at me.

Error during or-condition: unsupported operand type(s) for -: 'NoneType' and 'float'

Can anyone give me any suggestions as the best way to find where this may be coming from?

Thanks

if you use a decent text editor (Notepad++, etc) you can tell it to search all files in a directory for ‘float’. That’s the way I found a bunch of vague errors.

None types don’t support operators. So this is most likely an addition, subtraction, multiply, or divide between 2 things. I’m guessing the ‘float’ potion would be a hard-coded number. So… look for something like this:

{{ state_attr('x.x','x') + 4.0 }}

Reason I say state_attr, is because state_attr returns None. states() does not, it returns ‘unknown’, which is a string. And the error in that case would say ‘str’ and ‘float’.

EDIT. Also, look and see if you are using the last_triggered attribute. That one returns None if nothing has been triggered since restart.

1 Like

This could also be a new bug that cropped up… I’m seeing these errors too but I don’t really have any templates… Let alone any automations. All my stuff is in appdaemon.

EDIT: Nevermind those errors are from when I was playing around in the template editor. Maybe yours are from there too?

1 Like

Thanks for the tips. I do have a few automatons that don’t run too often, but they do use the last triggered attribute. So, I guess my question would be, other than the occasional error in the logs the 1st time the automation attempts to run, is this an issue. I guess a better question would be, will the automaiton run, throw an error, and then continue to run without error.

Yes.

But you can build in safety by doing something like

{% if not is_state_attr('automation.x','last_triggered', None) %}
1 Like

Interesting, is this an example of one that would cause the error, and how would I use your recommendation on this

  - condition: template
    value_template: '{{ as_timestamp(now()) - as_timestamp(states.automation.leave_any_zone.attributes.last_triggered) | int > 120 }}'
{% set t = states.automation.leave_any_zone.attributes.last_triggered %}
{% if t != None %}
  {{ as_timestamp(now()) - as_timestamp(t) | int > 120 }}
{% else %}
  False
{% endif %}
1 Like