[SOLVED]How to trouble shoot this ERROR (MainThread) [homeassistant.helpers.service] Error rendering data template: UndefinedError: 'None' has no attribute 'state'

Just upgraded to 0.93.
I’m getting this error but i have no idea where to start troubleshooting this:

2019-05-16 12:00:00 ERROR (MainThread) [homeassistant.helpers.service] Error rendering data template: UndefinedError: 'None' has no attribute 'state'

I found this, that apparently solves it, but i have no idea which template the error is referring too.

Any clues?

It 's related to a template. Do you use it a lot for entities or automation ?
Have you change template recently ? Perhaps you have an entity not existing anymore or with a new entity_id and one of the template don’t find it anymore.

I did a search within my config folder and found 134 occurances of value_template
:cry:

Does it help by filtering the one with state keyword inside ?

I cant thing of any clever wildcard to do this, but i believe that 99% of them would have the state keyword in them :frowning:

They are some braking changes in 0.93 do you see some integration or platform linked to potential use of template and in the breaking change list ?

Will check again with that scope in mind.
Nothing in there that i use, unfortunatelly.

Should i go remove my package folders and see if it goes away? and then find it by slowly restoring them?
Or is not worth the pain?

Could it be that my vacuum takes too long to be set up?

It’s 12.46 atm, and didnt have any more occurances of the error.

Perhaps activating debug level of logs generally can give you some clues on what home assistant is doing before rising the error.

Great idea!, here are the ssh logs (# hassio ha logs):

2019-05-16 12:30:00 INFO (MainThread) [homeassistant.components.automation] Executing Irrigation Weather - Update average weather conditions every 30 mins
2019-05-16 12:30:00 INFO (MainThread) [homeassistant.helpers.script] Script Irrigation Weather - Update average weather conditions every 30 mins: Running script
2019-05-16 12:30:00 INFO (MainThread) [homeassistant.helpers.script] Script Irrigation Weather - Update average weather conditions every 30 mins: Executing step call service
2019-05-16 12:30:00 INFO (MainThread) [homeassistant.helpers.script] Script calculate_average_weather_conditions: Running script
2019-05-16 12:30:00 INFO (MainThread) [homeassistant.helpers.script] Script calculate_average_weather_conditions: Executing step call service
2019-05-16 12:30:00 ERROR (MainThread) [homeassistant.helpers.service] Error rendering data template: UndefinedError: 'None' has no attribute 'state'

Looks like my irrigation weather calculations are the issue :smiley:

Seems like dark_sky sensor

states.sensor.dark_sky_forecast_daytime_high_temperature_0

was changed to

states.sensor.dark_sky_forecast_daytime_high_temperature_0d

Let’s see if that fixes it :slight_smile:

That was changed a version or 2 ago.

¯_(ツ)_/¯…

Thanks - its was my error too :+1:t3:

Good tip on using the logger. I was getting an error that said

ERROR (MainThread) [homeassistant.helpers.service] Error rendering data template: UndefinedError: 'binary_sensor' is undefined

I could not figure out what the issue was. The logger pointed me at the offending automation. In a nutshell I was using this code is_state('binary_sensor.bedroom_hall_motion', 'off') but I left the single quotes off of binary_sensor.bedroom_hall_motion.

This syntax that caused the error was like this: is_state(binary_sensor.bedroom_hall_motion, 'off')