Need help creating template sensor for vacuum robot

Hi everyone.

I got an Ecovacs Deebot T9 and integrated it like outlined here:

[Advanced - DeebotUniverse](https://DeebotUniverse Documentation)

So far this works as expected.
I have my templates in my own template.yaml as i refer to it via an include in my configuration.yaml.

In this template.yaml i created the sensors which i need for the vacuum queue:


unique_id: deebot_dana_queue
trigger:
  - platform: state
    entity_id: input_text.deebot_dana_queue
sensor:
  # Add for each room the following. Change room_name accordingly
  - unique_id: deebot_dana_queue_living_room
    name: deebot_dana_queue_living_room
    # room_name must match the room name provided by the vacuum
    state: >
      {% set room_name = "living_room" %}
      {% set queue = trigger.to_state.state.split(",") %}
      {{ queue.index(room_name)+1 if room_name in queue else 0 }}
  # Add for each room the following. Change room_name accordingly
  - unique_id: deebot_dana_queue_kitchen
    name: deebot_dana_queue_kitchen
    # room_name must match the room name provided by the vacuum
    state: >
      {% set room_name = "kitchen" %}
      {% set queue = trigger.to_state.state.split(",") %}
      {{ queue.index(room_name)+1 if room_name in queue else 0 }}
  # Add for each room the following. Change room_name accordingly
  - unique_id: deebot_dana_queue_dining_room
    name: deebot_dana_queue_dining_room

and there i list the rest of those rooms.

Now i got a second ecovacs vacuum robot in the network and wanted to add template sensors for this one and pated it directly underneath the first.

unique_id: deebot_wilson_queue
  trigger:
  - platform: state
    entity_id: input_text.deebot_wilson_queue
sensor:
# Add for each room the following. Change room_name accordingly
  - unique_id: deebot_wilson_queue_study
    name: deebot_wilson_queue_study
    # room_name must match the room name provided by the vacuum
    state: >
      {% set room_name = "study" %}
      {% set queue = trigger.to_state.state.split(",") %}
      {{ queue.index(room_name)+1 if room_name in queue else 0 }}
# Add for each room the following. Change room_name accordingly
  - unique_id: deebot_wilson_queue_laundry
    name: deebot_wilson_queue_laundry
    # room_name must match the room name provided by the vacuum
    state: >
      {% set room_name = "laundry" %}
      {% set queue = trigger.to_state.state.split(",") %}
      {{ queue.index(room_name)+1 if room_name in queue else 0 }

Now as soon as i refresh the template entities the sensors of the first robot “dana” imediately become “unavailable”.

I also get the duplicate key warnings.
As i suggest it’s because those unique_id: states are indeed on the same line.
I tried using a custom name and indent the unique_id: line underneath that like so:

deebot_wilson_queue:
  unique_id: deebot_wilson_queue
  trigger:
    - platform: state
      entity_id: input_text.deebot_wilson_queue
  sensor:
  # Add for each room the following. Change room_name accordingly
    - unique_id: deebot_wilson_queue_study
      name: deebot_wilson_queue_study
      # room_name must match the room name provided by the vacuum
      state: >
        {% set room_name = "study" %}
        {% set queue = trigger.to_state.state.split(",") %}
        {{ queue.index(room_name)+1 if room_name in queue else 0 }}

But all sensors still are unavailable.
Can someone please point me in the right direction?

Regards.