Template Sensor : bad indentation of a sequence entry

Hello…

Not sure what the proper formatting for multiple template sensors should be. I would like two sensors but I can’t figure out what the problem is with this:

template:
  - sensor:
      - name: "Time to next light event"
        state: "{{ (state_attr('binary_sensor.sr_light_cycle', 'next_update') | as_datetime | as_local - now() - timedelta(hours=1)).total_seconds() | timestamp_custom('%Hh %Mm',false) }}"
        icon: mdi:update

      - name "Next light update"
        state: "{{ as_timestamp(state_attr('binary_sensor.sr_light_cycle', 'next_update')) | timestamp_custom('%d %h at %H:%M')}}"
        icon: mdi:table-clock

The first entry is fine, the second complains of a “bad indenation of a sequence entry”. Not sure why the first one works but the second one doesn’t.

Any hints please?

I think it should be like this:

template:
  - sensor:
      - name: "Time to next light event"
        state: "{{ (state_attr('binary_sensor.sr_light_cycle', 'next_update') | as_datetime | as_local - now() - timedelta(hours=1)).total_seconds() | timestamp_custom('%Hh %Mm',false) }}"
        icon: mdi:update
  - sensor:
      - name "Next light update"
        state: "{{ as_timestamp(state_attr('binary_sensor.sr_light_cycle', 'next_update')) | timestamp_custom('%d %h at %H:%M')}}"
        icon: mdi:table-clock

Missing colon after the second name.

No, the original structure is fine apart from the missing colon, which you’ve copied into your answer.

2 Likes

Good lord that is it. I looked and looked but couldn’t see! Thanks for that.

Well spotted.

1 Like