Could not render template Last Motion, the state is unknown?

Folks,
I do get in my log very many:

2017-11-24 17:02:01 WARNING (MainThread) [homeassistant.components.sensor.template] Could not render template Last Motion Time Schlafzimmer, the state is unknown.
2017-11-24 17:02:01 WARNING (MainThread) [homeassistant.components.sensor.template] Could not render template Batterie-Status Schlafzimmer, the state is unknown.
2017-11-24 17:02:01 WARNING (MainThread) [homeassistant.components.sensor.template] Could not render template Last Motion Time Wonzimmer, the state is unknown.
2017-11-24 17:02:01 WARNING (MainThread) [homeassistant.components.sensor.template] Could not render template Batterie-Status Wohnzimmer, the state is unknown.
2017-11-24 17:02:01 WARNING (MainThread) [homeassistant.components.sensor.template] Could not render template Last Motion Time Gang, the state is unknown.
2017-11-24 17:02:01 WARNING (MainThread) [homeassistant.components.sensor.template] Could not render template Licht an Buero, the state is unknown.
2017-11-24 17:02:01 WARNING (MainThread) [homeassistant.components.sensor.template] Could not render template Licht an Gang, the state is unknown.
2017-11-24 17:02:01 WARNING (MainThread) [homeassistant.components.sensor.template] Could not render template Licht an Kueche, the state is unknown.
2017-11-24 17:02:01 WARNING (MainThread) [homeassistant.components.sensor.template] Could not render template Licht an Schlafzimmer, the state is unknown.
2017-11-24 17:02:01 WARNING (MainThread) [homeassistant.components.sensor.template] Could not render template Licht an Wohnzimmer, the state is unknown.
2017-11-24 17:02:01 WARNING (MainThread) [homeassistant.components.sensor.template] Could not render template Licht im Bad, the state is unknown.
2017-11-24 17:02:05 WARNING (MainThread) [homeassistant.components.sensor.template] Could not render template Last Motion, the state is unknown.
2017-11-24 17:02:07 WARNING (MainThread) [homeassistant.components.sensor.template] Could not render template Last Motion, the state is unknown.
2017-11-24 17:02:09 WARNING (MainThread) [homeassistant.components.sensor.template] Could not render template Last Motion, the state is unknown.
2017-11-24 17:02:10 WARNING (MainThread) [homeassistant.components.sensor.template] Could not render template Last Motion, the state is unknown.
2017-11-24 17:02:11 WARNING (MainThread) [homeassistant.components.sensor.template] Could not render template Last Motion, the state is unknown.

when I look into my template sensor section for:

template_last_motion:
  friendly_name: 'Last Motion'
  value_template: >
    {%- set sensors = [states.binary_sensor.fibaro_buero_sensor, states.binary_sensor.fibaro_gang_sensor, states.binary_sensor.fibaro_kueche_sensor, states.binary_sensor.fibaro_schlafzimmer_sensor, states.binary_sensor.fibaro_wohnzimmer_sensor_2, states.binary_sensor.vision_multisensor_bad_sensor ] %}
    {% for sensor in sensors %}
      {% if as_timestamp(sensor.last_changed) == as_timestamp(sensors | map(attribute='last_changed') | max) %}
        {{ sensor.name }}
      {% endif %}
    {% endfor %} 

luminanc_bad_below_level:
  friendly_name: 'Licht im Bad'
  value_template: '{{ (states.sensor.vision_multisensor_bad_luminance.state | float) < (states.sensor.helligkeit_off.state | float) }}'

How can I define starting values for these sensors?

Take a look here:

Don’t get the point. How does your recommandation differ to what I made?

I’ve looked at this a few time and other posts and still have nto figured it out. I get:

[homeassistant.components.sensor.template] Could not render template Last Motion, the state is unknown.

Here is my sensor:

template_last_motion:
  friendly_name: 'Last Motion'
  value_template: >
    {%- set sensors = [states.binary_sensor.back_porch_motion, states.binary_sensor.driveway_motion, states.binary_sensor.front_porch_motion, states.binary_sensor.lr2_motion, states.binary_sensor.hall_tab_motion_detector, states.binary_sensor.garaged_sensor, states.binary_sensor.backd_sensor, states.binary_sensor.frontd_sensor, states.binary_sensor.hallsensor_motion, states.binary_sensor.server_sensor, states.group.bedroom_lights, states.group.ceiling_fan_light, states.group.dining_room, states.group.kitchen, states.switch.back_porch_light_switch, states.light.bedroomlamp_level, states.switch.front_porch_light_switch, states.light.hall_light_1, states.light.hall_light_2, states.light.lrlamp_level, states.light.tablelamp_level] %}
    {% for sensor in sensors %}
      {% if as_timestamp(sensor.last_changed) == as_timestamp(sensors | map(attribute='last_changed') | max) %}
        {{ sensor.name }}
      {% else %}
        n/a
      {% endif %}
    {% endfor %}

Any suggestions? I am sure it is something simple… I am trying to get my logs cleaned up :slight_smile:

I am also getting this error even though there is a value in ui for those sensors.
image

  - platform: template
    sensors:
      google_travel_km_buss_gs:
        unit_of_measurement: 'km'
        value_template: "{{ states.sensor.christer_till_gamlestan_buss.attributes.distance}}"
      google_travel_km_cykel_gs:
        unit_of_measurement: 'km'
        value_template: "{{ states.sensor.christer_till_gamlestan_cykel.attributes.distance}}"
      google_travel_km_cykel_hck:
        unit_of_measurement: 'km'
        value_template: "{{ states.sensor.christer_till_hck_cykel.attributes.distance}}"
      google_travel_km_buss_hck:
        unit_of_measurement: 'km'
        value_template: "{{ states.sensor.christer_till_hck_buss.attributes.distance}}"
      google_travel_km_cykel_molndal:
        unit_of_measurement: 'km'
        value_template: "{{ states.sensor.christer_till_molndal_cykel.attributes.distance}}"
      google_travel_km_buss_molndal:
        unit_of_measurement: 'km'
        value_template: "{{ states.sensor.christer_till_molndal_buss.attributes.distance}}"
      google_travel_km_cykel_vak:
        unit_of_measurement: 'km'
        value_template: "{{ states.sensor.christer_till_vak_cykel.attributes.distance}}"
      google_travel_km_buss_vak:
        unit_of_measurement: 'km'
        value_template: "{{ states.sensor.christer_till_vak_buss.attributes.distance}}"

and
image
- platform: template
sensors:
fibaro_battery:
unit_of_measurement: ‘%’
value_template: “{{ states.zwave.fibaro_system_fgms001zw5_motion_sensor.attributes.battery_level}}”

Hi Corey, did you find a solution for this issue? I’m using the same template for detecting Last Motion, resulting in the same error ‘Could not render template Last Motion, the state is unknown’.

1 Like

I have not, still getting the error. Other than this, my logs a pretty clean.

1 Like