Help with template update

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’, ‘’) }}’
  • 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", “”) }}’
  • 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] }}’

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!

First you need to post your yaml properly formatted so we can see the actual indentation of your code or no one can help you.

Second, if you put it anywhere other than configuration.yaml, you need to tell us where and how that file is included in you configuration.yaml file.

- 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", "") }}'

- 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", "") }}'

I get an error message now relating to the following lines
`  - entity_id:
    - sun.sun`
- what should they change to?

The entity_id key was deprecated over 5 years ago, and was not accounted for in the tool that created the repairs. Just delete them.

- sensor:
    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", "") }}'

- sensor:
    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", "") }}'

Many thanks! The code showing what I should have in the “new” templates had that code in it!