Multiple sensors in configuration.yaml - Configurator notes duplicated mapping key but passes configuration check

Relatively new to HA and have mostly copied and pasted my way through

I’ve noticed that the Configurator has a red exclamation point and then this:
duplicated mapping key at line 162, column -71:
sensor:
^
This correlates with the second instance in my configuration.yaml of a sensor call out.

First is

# DarkSky
sensor:
  - platform: darksky

Second is

# NOAA Tides
sensor:
  - platform: noaa_tides

Third is

# Orbit Bhyve
bhyve:
  username: [email protected]
  password: xxx
sensor:
  - platform: bhyve
binary_sensor:
  - platform: bhyve
switch:
  - platform: bhyve

If I go to Configuration - Server Controls - Check Configuration, it passes

So my questions:

  1. Is this just a formatting preference that doesn’t really matter (like one space or two after a period in written language)?
  2. If not proper, how am I supposed to deal with these sensors? I tried changing the names to sensor.noaa or sensor.bhyve but that threw up real errors.

Thanks!

Only the last sensor will be created. You only need one key, and then list the individual ones inside it.

Should be:

sensor:
  - platform: darksky

  - platform: noaa_tides

  - platform: bhyve

The way you had it it would overwrite the first one with the second one, and then overwrite the second one with the third one as it parsed the file.

3 Likes

You need to read the basics.

1 Like

Well I have to say this has got me flummoxed as well.

I have stared at the post from anon43302295 and the basics in the link provided by flamingm0e and I’m still floundering in a sea of uncertainty! :blush:

In my configuration.yaml I have an entry near the top for sensor here under Wirelsss Tags;

`# Wireless Tags
wirelesstag:
  username: username
  password: password

binary_sensor:
  - platform: wirelesstag
    monitored_conditions:
      - light
      - battery

sensor:
  - platform: wirelesstag
    monitored_conditions:
      - temperature`

And then further down near the bottom where I am trying to install OpenSky I now have a second entry for sensor;

# OpenSky
sensor:
  - platform: opensky
    radius: 10

Obviously the Editor flags a red exclamation mark and reports the error;

duplicated mapping key at line 148, column -45:
sensor:
^

Line 148 corresponds with the sensor entry under OpenSky as you would expect but in this example how exactly do I modify the yaml to correct this please? :thinking:

Thanks & kind regards,
-=Glyn=-

sensor:
  - platform: wirelesstag
    monitored_conditions:
      - temperature`

  - platform: opensky
    radius: 10

And if you don’t like that, you can split the configuration. Include this at the top of configuration.yaml:

sensor: !include_dir_merge_list sensors

then create a folder called sensors, and move your sensors into as many separate YAML files as you want. You could have sensors/opensky.yaml for example, containing:

- platform: opensky
  radius: 10

Note that you don’t repeat the sensor: section heading in the included files; and you should have no other sensor: blocks in the main configuration.yaml file.

2 Likes

Thanks for taking the time to reply guys.

Troon: I’m too new to HA to start splitting configuration files at the moment although ultimately I will probably have to go down this road at some point. Baby steps…:crazy_face:

Dennis: I’ve seen other references like this but as I’m still easing my way into HA and have screwed my configuration.yaml more times than I care to count I still don’t know where these particular entries will sit in context? :thinking:

If I post my configuration.yaml here in full could some kind soul show me where & how I can incorporate the additional sensor lines and at the same time cast their learned eye over it to ensure I am on the right road with the other entries please?

I am guessing the same logic will apply to adding additional media_player as I had to remove this same entry from my LG TV when I added the Pioneer AVR?


# Configure a default setup of Home Assistant (frontend, api, etc)
default_config:

# Text to speech
tts:
  - platform: google_translate

# Home Assistant
homeassistant:
  auth_providers:
    - type: homeassistant
    - type: trusted_networks
      trusted_networks:
        - 192.168.x.0/24

# LG OLED TV
webostv:
  host: 192.168.x.x
  name: LG TV
  turn_on_action:
    service: persistent_notification.create
    data:
      message: "Turn on action"
  customize:
    sources:
      - Marantz
      - CCTV
      - Prime
      - YouTube

# Wireless Tags
wirelesstag:
  username: username
  password: password

binary_sensor:
  - platform: wirelesstag
    monitored_conditions:
      - presence
      - motion
      - door
      - cold
      - heat
      - dry
      - wet
      - light
      - battery

sensor:
  - platform: wirelesstag
    monitored_conditions:
      - temperature
      - humidity
      - light
      
switch:
  - platform: wirelesstag
    monitored_conditions:
      - temperature
      - humidity
      - motion
      - light

# LightwaveRF      
lightwave:
  host: 192.168.x.x
  lights:
    R1D1:
      name: Light
    
  switches:
    R1D2:
      name: Switch
   
# Neato
neato:
  client_id: very_long_number!
  client_secret: another very long number!

# Pioneer AVR
media_player:
  - platform: pioneer
    host: 192.168.x.x

group: !include groups.yaml
automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml
    

Thanks & kind regards,
-=Glyn=-

I have been struggling with this issue with the “google_domains” integration. I can make it work if I only do one domain, but I was hoping to have multiple dynamic DNS domains updated with this integration. No matter how I format it, it either doesn’t work at all, or it only does the last one.

I tried the options below, but none seem to work:

Simple: Throws an error and does not save the config

google_domains:
  domain: host01.domain.net
  username: afaewdsfasdrf234r5
  password: adfasdf2454235
  domain: host02.domain.net
  username: afaewdsfasdrf234r5
  password: adfasdf2454235

Dash Deliminated: doesn’t work at all

google_domains:
  - domain: host01.domain.net
    username: afaewdsfasdrf234r5
    password: adfasdf2454235
  - domain: host02.domain.net
    username: afaewdsfasdrf234r5
    password: adfasdf2454235

Multiple entries: only the last one updates

google_domains:
  domain: host01.domain.net
  username: afaewdsfasdrf234r5
  password: adfasdf2454235
google_domains:
  domain: host02.domain.net
  username: afaewdsfasdrf234r5
  password: adfasdf2454235

Just curious if this even works, or if I am looking at the wrong solution for this. Any ideas would be much appreciated.