Delaying template sensors until zwave is settled

Can I delay the template sensors until zwave is fully initialized? If it’s easy I would prefer to do so, to avoid the warnings in the homeassistant log.


17-05-02 11:52:00 WARNING (MainThread) [homeassistant.components.sensor.template] Could not render template laundry_running, the state is unknown. 17-05-02 11:52:30 WARNING (Thread-9) [homeassistant.components.zwave] zwave not ready after 30 seconds, continuing anyway

template sensor config is this

- platform: template
  sensors:
    laundry_running:
      value_template: "{% if  states.sensor.tvattmaskin_power_23_8.state | float > 2.0  %}Tvättar{% else %}Klar{% endif %}"

The state of tvattmaskin_power_23_8.state is unknow to start with, but the sensor works fine once zwave is ready.

I’d be interested in this too. I get the same problem with the Google Travel Maps Time platform:

- platform: template
  sensors: 
    distance_from_home:
    value_template: '{{ states.sensor.ross_travel_time.attributes.distance }}'
    friendly_name: 'Distance away'

17-05-02 11:16:49 WARNING (MainThread) [homeassistant.components.sensor.template] Could not render template Distance away, the state is unknown.

Maybe this will help.
Should be the same for template sensor.

Thanks for the reply, but I don’t think is_state() can be used in this case since i’m not checking a single value, but performing a comparison and basing my template on the result.

The info in your link gave me an idea though, I might be able to avoid the error in a similar way by adding more if conditions to check if tvattmaskin_power_23_8 exists and if it has a valid state. I’ll give it a try and see how it works out.

I updated my template sensor code so it avoids the error:

- platform: template
  sensors:
    laundry_running:
      value_template: "{% if states.sensor.tvattmaskin_power_23_8 %} {% if states.sensor.tvattmaskin_power_23_8.state | float > 2.0  %}Tvättar{% else %}Klar{% endif %} {% endif %}"

The difference here is that I wrap the old template code with another if/endif:

value_template: "{% if states.sensor.xxx %} the old code {% endif %}"

This way the template is blank until states.sensor.xxx contains something useful.

1 Like