Strange sensor problem

I wanted to have my phone’s batteries appear in Home Assistant, so I added the following into my sensors.yaml file:

# Trackers battery status
  - platform: template
    sensors:
      dev_battery:
        friendly_name: Kim's Phone Battery
        value_template: "{{ state_attr('device_tracker.kim', 'battery') }}"
        unit_of_measurement: '%'
        device_class: battery

  - platform: template
    sensors:
      dev_battery:
        friendly_name: Steve's Phone Battery
        value_template: "{{ state_attr('device_tracker.steve', 'battery') }}"
        unit_of_measurement: '%'
        device_class: battery

Now, here’s the problem - only the second phone shows on my home page. I swapped them and again, only the second one shows.

What did I do wrong?

try this:

# Trackers battery status
  - platform: template
    sensors:
      dev_battery:
        friendly_name: Kim's Phone Battery
        value_template: "{{ state_attr('device_tracker.kim', 'battery') }}"
        unit_of_measurement: '%'
        device_class: battery

      dev_battery:
        friendly_name: Steve's Phone Battery
        value_template: "{{ state_attr('device_tracker.steve', 'battery') }}"
        unit_of_measurement: '%'
        device_class: battery

Thanks, but, nope. Didn’t fix it. No config error, but still, only the second phone’s battery shows on the home page. I swap the two phones and still, only the second one shows.

hang on… I just noticed that both sensors have the same name. change one to dev_battery_1 or whatever

That was it- and it makes sense that the second one may have overwritten the first.

Thanks