I have put this template configuration into the Development tools template checker and it shows it working!
template:
-
sensor:
- entity_id:
- sun.sun
default_entity_id: sensor.nextsunrise
icon: mdi:weather-sunset-up
name: Next Sunrise
state: ‘{{ (state_attr(‘sun.sun’, ‘next_rising’) | as_timestamp(0)) | timestamp_custom(’%I:%M %p’) | replace(’ 0’, ‘’) }}’
- sun.sun
- entity_id:
-
sensor:
- entity_id:
- sun.sun
default_entity_id: sensor.nextsunset
icon: mdi:weather-sunset-down
name: Next Sunset
state: ‘{{ (state_attr(‘sun.sun’, ‘next_setting’) | as_timestamp(0)) | timestamp_custom(’%I:%M %p’) | replace(" 0", “”) }}’
- sun.sun
- entity_id:
-
sensor:
- default_entity_id: sensor.weather_wind_dir
name: Wind Direction
state: ‘{% set direction = [‘N’,‘NNE’,‘NE’,‘ENE’,‘E’,‘ESE’,‘SE’,‘SSE’,‘S’,‘SSW’,‘SW’,‘WSW’,‘W’,‘WNW’,‘NW’,‘NNW’] %}{% set degree = states(‘sensor.met_office_rustington_wind_direction’)|float(0) %}{{ direction[((degree % 360) / 22.5)|int] }}’
- default_entity_id: sensor.weather_wind_dir
I put it into the yaml and it says
bad indentation of a mapping entry (16:30)
13 | default_entity_id: sensor.nextsunrise
14 | icon: mdi:weather-sunset-up
15 | name: Next Sunrise
16 | state: '{{ (state_attr (‘sun.sun’, ‘next_rising’) | as_t …
-----------------------------------^
17 |
18 | - sensor:
Or
bad indentation of a mapping entry (13:34)
10 | - sensor:
11 | - default_entity_id: sensor.weather_wind_dir
12 | name: Wind Direction
13 | state: ‘{% set direction = [‘N’,‘NNE’,‘NE’,‘ENE’,‘E’,‘ESE’,’ …
---------------------------------------^
14 |
15 | - sensor:
I cannot work this out! What are the rules on indentation!