How to solve this error? Duplicated mapping key and MODBUS error

Hello,
I want to add a Modbus (Carel c.PCO) device into HA to control my fancoil and radiant floor.
I’ve created this instruction, but I’ve received this error

duplicated mapping key (124:5)

  • 121 | command_template: >*
  • 122 | {{ {‘Auto’:0,‘Bassa’:1,'M …*
  • 123 | *
  • 124 | sensor:*
    -----------^
  • 125 | - platform: modbus*
  • 126 | name: "Velocità Fancoil Sog …*

This is my config:

modbus:
  - name: carel
    type: tcp
    host: 192.168.1.115
    port: 502
    delay: 2
    timeout: 5

    switch:
      - platform: modbus
        name: "Impianto Clima"
        hub: carel
        register: 1487
        register_type: holding
        command_on: 1
        command_off: 0

    number:
      - platform: modbus
        name: "Setpoint Soggiorno"
        hub: carel
        register: 15992
        register_type: holding
        min_value: 18
        max_value: 30
        step: 0.5
        scale: 0.1

      - platform: modbus
        name: "Setpoint Camera Letto"
        hub: carel
        register: 15996
        register_type: holding
        min_value: 18
        max_value: 30
        step: 0.5
        scale: 0.1

      - platform: modbus
        name: "Setpoint Cameretta"
        hub: carel
        register: 15997
        register_type: holding
        min_value: 18
        max_value: 30
        step: 0.5
        scale: 0.1

    sensor:
      - platform: modbus
        name: "Temperatura Soggiorno"
        hub: carel
        register: 17194
        register_type: input
        unit_of_measurement: "°C"
        scale: 0.1

      - platform: modbus
        name: "Temperatura Camera Letto"
        hub: carel
        register: 17198
        register_type: input
        unit_of_measurement: "°C"
        scale: 0.1

      - platform: modbus
        name: "Temperatura Cameretta"
        hub: carel
        register: 17199
        register_type: input
        unit_of_measurement: "°C"
        scale: 0.1

    select:
      - platform: modbus
        name: "Velocità Fancoil Soggiorno"
        hub: carel
        register: 7899
        options:
          - Auto
          - Bassa
          - Media
          - Alta
        command_template: >
          {{ {'Auto':0,'Bassa':1,'Media':2,'Alta':3}[value] }}

      - platform: modbus
        name: "Velocità Fancoil Camera"
        hub: carel
        register: 7903
        options:
          - Auto
          - Bassa
          - Media
          - Alta
        command_template: >
          {{ {'Auto':0,'Bassa':1,'Media':2,'Alta':3}[value] }}

      - platform: modbus
        name: "Velocità Fancoil Cameretta"
        hub: carel
        register: 7904
        options:
          - Auto
          - Bassa
          - Media
          - Alta
        command_template: >
          {{ {'Auto':0,'Bassa':1,'Media':2,'Alta':3}[value] }}

    sensor:
      - platform: modbus
        name: "Velocità Fancoil Soggiorno Stato"
        hub: carel
        register: 7778
        register_type: input

      - platform: modbus
        name: "Velocità Fancoil Camera Stato"
        hub: carel
        register: 7785
        register_type: input

      - platform: modbus
        name: "Velocità Fancoil Cameretta Stato"
        hub: carel
        register: 7786
        register_type: input

    select:
      - platform: modbus
        name: "Modalità Impianto"
        hub: carel
        register: 3597
        options:
          - Estate
          - Inverno
        command_template: >
          {{ {'Estate':0,'Inverno':1}[value] }}

    type: vertical-stack
    cards:

      - type: thermostat
        entity: climate.soggiorno
        name: Soggiorno

      - type: thermostat
        entity: climate.camera_letto
        name: Camera da letto

      - type: thermostat
        entity: climate.cameretta
        name: Cameretta

      - type: entities
        entities:
          - switch.impianto_clima
          - select.modalita_impianto

You have 2 entries named sensor: (and select:) which is incorrect since there can only be 1 entry for each under each code block.

Delete the second sensor: line & move all the Velocità Fancoil sensors under the first sensor line where you have the Temperatura entries.

Do the same thing for select:

Delete the second select: line & move the Modalità Impianto entry up to the Velocità Fancoil select section.

Thanks!
Now I got this new message

duplicated mapping key (152:5)

 149 |         command_template: >
 150 |           {{ {'Estate':0,'Inverno': ...
 151 | 
 152 |     type: vertical-stack
-----------^
 153 |     cards:
 154 | 

Here below the updated code:

modbus:
  - name: carel
    type: tcp
    host: 192.168.1.115
    port: 502
    delay: 2
    timeout: 5

    switch:
      - platform: modbus
        name: "Impianto Clima"
        hub: carel
        register: 1487
        register_type: holding
        command_on: 1
        command_off: 0

    number:
      - platform: modbus
        name: "Setpoint Soggiorno"
        hub: carel
        register: 15992
        register_type: holding
        min_value: 18
        max_value: 30
        step: 0.5
        scale: 0.1

      - platform: modbus
        name: "Setpoint Camera Letto"
        hub: carel
        register: 15996
        register_type: holding
        min_value: 18
        max_value: 30
        step: 0.5
        scale: 0.1

      - platform: modbus
        name: "Setpoint Cameretta"
        hub: carel
        register: 15997
        register_type: holding
        min_value: 18
        max_value: 30
        step: 0.5
        scale: 0.1

    sensor:
      - platform: modbus
        name: "Temperatura Soggiorno"
        hub: carel
        register: 17194
        register_type: input
        unit_of_measurement: "°C"
        scale: 0.1

      - platform: modbus
        name: "Temperatura Camera Letto"
        hub: carel
        register: 17198
        register_type: input
        unit_of_measurement: "°C"
        scale: 0.1

      - platform: modbus
        name: "Temperatura Cameretta"
        hub: carel
        register: 17199
        register_type: input
        unit_of_measurement: "°C"
        scale: 0.1

      - platform: modbus
        name: "Velocità Fancoil Soggiorno Stato"
        hub: carel
        register: 7778
        register_type: input

      - platform: modbus
        name: "Velocità Fancoil Camera Stato"
        hub: carel
        register: 7785
        register_type: input

      - platform: modbus
        name: "Velocità Fancoil Cameretta Stato"
        hub: carel
        register: 7786
        register_type: input

    select:
      - platform: modbus
        name: "Velocità Fancoil Soggiorno"
        hub: carel
        register: 7899
        options:
          - Auto
          - Bassa
          - Media
          - Alta
        command_template: >
          {{ {'Auto':0,'Bassa':1,'Media':2,'Alta':3}[value] }}

      - platform: modbus
        name: "Velocità Fancoil Camera"
        hub: carel
        register: 7903
        options:
          - Auto
          - Bassa
          - Media
          - Alta
        command_template: >
          {{ {'Auto':0,'Bassa':1,'Media':2,'Alta':3}[value] }}

      - platform: modbus
        name: "Velocità Fancoil Cameretta"
        hub: carel
        register: 7904
        options:
          - Auto
          - Bassa
          - Media
          - Alta
        command_template: >
          {{ {'Auto':0,'Bassa':1,'Media':2,'Alta':3}[value] }}

      - platform: modbus
        name: "Modalità Impianto"
        hub: carel
        register: 3597
        options:
          - Estate
          - Inverno
        command_template: >
          {{ {'Estate':0,'Inverno':1}[value] }}

    type: vertical-stack
    cards:

      - type: thermostat
        entity: climate.soggiorno
        name: Soggiorno

      - type: thermostat
        entity: climate.camera_letto
        name: Camera da letto

      - type: thermostat
        entity: climate.cameretta
        name: Cameretta

      - type: entities
        entities:
          - switch.impianto_clima
          - select.modalita_impianto

I’ve also got this error message

Invalid config for 'modbus' at configuration.yaml, line 152: not a valid value for dictionary value 'modbus->0->type', got 'vertical-stack'

and

Setup failed for 'modbus': Invalid config.

Remove everything from the type: vertical-stack till the end. That is a dashboard card config which has nothing to do with the entity config.

Where did you get the original code from? It should have explained that those are 2 different things

1 Like

Done. Still got these error messages

Setup failed for 'modbus': Integration failed to initialize.

and

Modbus carel contain no entities, causing instability, entry not loaded```

Post your updated yaml here, maybe someone familiar with modbus will explain why it’s not loading.

1 Like

Here my complete .yaml file

# Loads default set of integrations. Do not remove.
default_config:

# Load frontend themes from the themes folder
frontend:
  themes: !include_dir_merge_named themes

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

#Configurazione impianto modbus Carel
modbus:
  - name: "carel"
    type: tcp
    host: 192.168.1.151
    port: 502
    delay: 2
    timeout: 5

    switch:
      - platform: modbus
        name: "Impianto Clima"
        hub: carel
        register: 1487
        register_type: holding
        command_on: 1
        command_off: 0

    number:
      - platform: modbus
        name: "Setpoint Soggiorno"
        hub: carel
        register: 15992
        register_type: holding
        min_value: 18
        max_value: 30
        step: 0.5
        scale: 0.1

      - platform: modbus
        name: "Setpoint Camera Letto"
        hub: carel
        register: 15996
        register_type: holding
        min_value: 18
        max_value: 30
        step: 0.5
        scale: 0.1

      - platform: modbus
        name: "Setpoint Cameretta"
        hub: carel
        register: 15997
        register_type: holding
        min_value: 18
        max_value: 30
        step: 0.5
        scale: 0.1

    sensor:
      - platform: modbus
        name: "Temperatura Soggiorno"
        hub: carel
        register: 17194
        register_type: input
        unit_of_measurement: "°C"
        scale: 0.1

      - platform: modbus
        name: "Temperatura Camera Letto"
        hub: carel
        register: 17198
        register_type: input
        unit_of_measurement: "°C"
        scale: 0.1

      - platform: modbus
        name: "Temperatura Cameretta"
        hub: carel
        register: 17199
        register_type: input
        unit_of_measurement: "°C"
        scale: 0.1

      - platform: modbus
        name: "Velocità Fancoil Soggiorno Stato"
        hub: carel
        register: 7778
        register_type: input

      - platform: modbus
        name: "Velocità Fancoil Camera Stato"
        hub: carel
        register: 7785
        register_type: input

      - platform: modbus
        name: "Velocità Fancoil Cameretta Stato"
        hub: carel
        register: 7786
        register_type: input

    select:
      - platform: modbus
        name: "Velocità Fancoil Soggiorno"
        hub: carel
        register: 7899
        options:
          - Auto
          - Bassa
          - Media
          - Alta
        command_template: >
          {{ {'Auto':0,'Bassa':1,'Media':2,'Alta':3}[value] }}

      - platform: modbus
        name: "Velocità Fancoil Camera"
        hub: carel
        register: 7903
        options:
          - Auto
          - Bassa
          - Media
          - Alta
        command_template: >
          {{ {'Auto':0,'Bassa':1,'Media':2,'Alta':3}[value] }}

      - platform: modbus
        name: "Velocità Fancoil Cameretta"
        hub: carel
        register: 7904
        options:
          - Auto
          - Bassa
          - Media
          - Alta
        command_template: >
          {{ {'Auto':0,'Bassa':1,'Media':2,'Alta':3}[value] }}

      - platform: modbus
        name: "Modalità Impianto"
        hub: carel
        register: 3597
        options:
          - Estate
          - Inverno
        command_template: >
          {{ {'Estate':0,'Inverno':1}[value] }}

maybe the keys are wrong, see below. Does sensor needs to be sensors, switch needs to be switches ?

Also, doesn’t look there are number or select options

1 Like

Hello your yaml looks not correct.
Try as per instruction:


modbus:
  - name: "carel"
    type: tcp
    host: 192.168.1.151
    port: 502
    delay: 2
    timeout: 5

    switches:
        address: 1487
        input_type: holding
        device_address: slaveaddresshereifmultiple

The indenting is already telling that the device, switches is part of the modbus and it will look to ip address 192.168.1.151.
Please use a static ip for your device.

Then if these are fancoil why don’t you use a climate modbus entity see documentation above linked by @Holdestmade