Garage Door code giving me problems

Code:
template:

  • sensor:
    • name: “Garage Door”
      state: >
      {% if is_state(‘binary_sensor.garage_sensor’, ‘off’) and is_state(‘switch.garage_door’, ‘on’) %}
      opening
      {% elif is_state(‘binary_sensor.garage_sensor’, ‘off’) and is_state(‘switch.garage_door’, ‘off’) %}
      closing
      {% elif is_state(‘binary_sensor.garage_sensor’, ‘on’) %}
      open
      {% else %}
      closed
      {% endif %}

sensor:

  • platform: openweathermap_all
    api_key: <redacted>
    latitude: <redacted>
    longitude: <redacted>

cover:

  • platform: template
    covers:
    garage_door:
    device_class: garage
    friendly_name: “Garage Door”
    value_template: “{{ states(‘sensor.garage_door’) }}”
    open_cover:
    - condition: state
    entity_id: sensor.garage_door
    state: “closed”
    - service: switch.toggle
    target:
    entity_id: switch.garage_door
    close_cover:
    - condition: state
    entity_id: sensor.garage_door
    state: “open”
    - service: switch.toggle
    target:
    entity_id: switch.garage_door
    stop_cover:
    service: switch.toggle
    target:
    entity_id: switch.garage_door
    icon_template: >-
    {% if is_state(‘cover.garage_door’, ‘opening’) or is_state(‘cover.garage_door’, ‘closing’) %}
    mdi:garage-alert
    {% elif is_state(‘cover.garage_door’, ‘open’) %}
    mdi:garage-open
    {% else %}
    mdi:garage
    {% endif %}

Error:
duplicated mapping key (65:1)

62 | closed
63 | {% endif %}
64 |
65 | sensor:
------^
66 | - platform: openweathermap_all
67 | api_key: 00b5c3a6d111778706df2d98554e1e7da62c

Question: Should I be looking for another instance of line 67 API Key ? I cant find one. Or is it the use of Sensor I have screwed up with ?

https://community.home-assistant.io/t/how-to-help-us-help-you-or-how-to-ask-a-good-question/114371#oneone-format-it-properly-16

You have two instances of the sensor integration declared in your configuration.yaml file, i.e. two of these hard up against the page margin:

sensor:

The other one is probably something like

sensor: !include sensors.yaml

So that file (sensors.yaml) is where you should put this:

- platform: openweathermap_all
  api_key: <redacted>
  latitude: <redacted>
  longitude: <redacted>

Many thanks Tom for your guidance. I really must try and learn yaml with some greater understanding. In closing, Should I place all Sensors code in my sensor folder ?
Cheers
Mark

PS Please deleat Lat and long and api key as they might cause bigger problems.
Cheers
Mark

Personal info hidden.

Only move sensors that have this in the documentation:

Thanks again Tom, I presume I can add multiple sensor code in the sensor file? Also interested in unique code in your example, is that a working format for a unique code and is it as simple as adding something similar and unique with a file editor?
Cheers Mark

Sorry now off topic :slight_smile:

Yes. Each one preceded by - so they are a YAML list.

That was taken from here: