YAML Syntax problem. I'm not able to insert my second sensor config

Hi there.

I’m new with HA and in these forum :wink:
So - Hi at all! :wink:

Around two weeks ago i have inserted my first energy logging sensor to the configuration.yaml .
I had found that on the web and it worked directly.

Now, i would like to add another sensor to these file.
The parser show me a lot of faulty things.
I have test some styles of syntax, but the parser dont like that…

Example:
My first sensor started with “modbus:” - The new one, too.
So the parser notificate that there is a double entry.

I would like to use the script ol Brynn:

The other script was for my EM24 sensor:

Could anybody advice me how i can add both sensors to the file?
Must i used the “- platform: xxx” synstax to encapsulate one sensor in the file?

Hope anyone can send me a hint of this.

Thank you in advance.
Bjoern

Make sure you only have one

modbus:

in your configuration.yaml. Both sensors go under it, without using ‘modbus:’ again.

1 Like

Hi Francis.

Thank you for that really fast reply!

The one “driver” have modbus on start position, the other on the end.
Should i delete the second “modbus:” line?

Hope my logged data from the last two weeks will not be lost if i make a not correct change.

maybe show your current configuration.yaml

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

# Text to speech
tts:
  - platform: google_translate

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

#Modbus
modbus:
  - name: EM24_Energiezaehler Haus
    type: tcp
    host: 192.168.1.101
    port: 502
    sensors:
      - name: EM24_V L1-N
        unit_of_measurement: V
        slave: 1
        address: 0
        input_type: input
        data_type: int32
        scale: 0.1
        precision: 2
        swap: word
        count: 2
        device_class: voltage
      - name: EM24_V L2-N
        unit_of_measurement: V
        slave: 1
        address: 2
        data_type: int32
        scale: 0.1
        precision: 2
        swap: word
        device_class: voltage
      - name: EM24_V L3-N
        unit_of_measurement: V
        slave: 1
        address: 4
        data_type: int32
        scale: 0.1
        precision: 2
        swap: word
        device_class: voltage
      - name: EM24_V L1-L2
        unit_of_measurement: V
        slave: 1
        address: 6
        data_type: int32
        scale: 0.1
        precision: 2
        swap: word
        device_class: voltage
      - name: EM24_V L2-L3
        unit_of_measurement: V
        slave: 1
        address: 8
        data_type: int32
        scale: 0.1
        precision: 2
        swap: word
        device_class: voltage
      - name: EM24_V L3-L1
        unit_of_measurement: V
        slave: 1
        address: 10
        data_type: int32
        scale: 0.1
        precision: 2
        swap: word
        device_class: voltage
      - name: EM24_I L1
        unit_of_measurement: A
        slave: 1
        address: 12
        input_type: input
        data_type: int32
        scale: 0.001
        precision: 2
        swap: word
        count: 2
        device_class: current
      - name: EM24_I L2
        unit_of_measurement: A
        slave: 1
        address: 14
        data_type: int32
        scale: 0.001
        precision: 2
        swap: word
        device_class: current
      - name: EM24_I L3
        unit_of_measurement: A
        slave: 1
        address: 16
        data_type: int32
        scale: 0.001
        precision: 2
        swap: word
        device_class: current
      - name: EM24_P Bezug
        unit_of_measurement: kWh
        slave: 1
        address: 52
        data_type: int32
        scale: 0.1
        precision: 2
        swap: word
        device_class: energy
        state_class: total
      - name: EM24_P Einspeisung
        unit_of_measurement: kWh
        slave: 1
        address: 78
        data_type: int32
        scale: 0.1
        precision: 2
        swap: word
        device_class: energy
        state_class: total
      - name: EM24_P L1
        unit_of_measurement: W
        slave: 1
        address: 18
        data_type: int32
        scale: 0.1
        precision: 2
        swap: word
        device_class: power
      - name: EM24_P L2
        unit_of_measurement: W
        slave: 1
        address: 20
        data_type: int32
        scale: 0.1
        precision: 2
        swap: word
        device_class: power
        input_type: input
      - name: EM24_P L3
        unit_of_measurement: W
        slave: 1
        address: 22
        data_type: int32
        scale: 0.1
        precision: 2
        swap: word
        device_class: power
        input_type: input
      - name: EM24_P Aktuell
        unit_of_measurement: W
        slave: 1
        address: 40
        data_type: int32
        scale: 0.1
        precision: 2
        swap: word
        count: 2
        device_class: power
        
 
 
    
    
    
#EPEver eBox-Wifi-01 modbus
modbus1:
-   name: Solar2EP
    type: rtuovertcp
    host: 192.168.1.154
    port: 8088
    delay: 5
    timeout: 10
    close_comm_on_error: false
    retry_on_empty: true
    retries: 20
# Modbus sensors for EPever Charge Controller 2
    sensors:
    - name: "Sol2 Battery Capacity"
      unit_of_measurement: "%"
      device_class: battery
      slave: 1
      address: 12570
      input_type: input
      scan_interval: 10
    - name: "Sol2 Solar V"
      unit_of_measurement: V
      device_class: voltage
      slave: 1
      address: 12544
      input_type: input
      scale: 0.01
      precision: 2
      scan_interval: 10
    - name: "Sol2 Solar A"
      unit_of_measurement: A
      device_class: current
      slave: 1
      address: 12545
      input_type: input
      scale: 0.01
      precision: 2
      scan_interval: 10
    - name: "Sol2 Charging W"
      unit_of_measurement: W
      device_class: power
      slave: 1
      address: 12546
      input_type: input
      data_type: int32
      scale: 0.01
      count: 2
      precision: 2
      swap: word
      scan_interval: 10
    - name: "Sol2 Battery V"
      unit_of_measurement: V
      device_class: voltage
      slave: 1
      address: 13082
      input_type: input
      scale: 0.01
      precision: 2
      scan_interval: 10
    - name: "Sol2 Load W"
      unit_of_measurement: W
      device_class: power
      slave: 1
      address: 12558  # low 12550  high 12551 #12558
      input_type: input
      scale: 0.01
      precision: 2
      scan_interval: 5
    - name: "Sol2 Load A"
      device_class: current
      unit_of_measurement: A
      slave: 1
      address: 12549
      input_type: input
      scale: 0.001
      precision: 2
      scan_interval: 10
    - name: "Sol2 Load V"
      device_class: voltage
      unit_of_measurement: V
      slave: 1
      address: 12548
      input_type: input
      scale: 0.01
      precision: 2
      scan_interval: 10
    - name: "Sol2 Battery Temp"
      unit_of_measurement: °C
      slave: 1
      address: 12560
      input_type: input
      scale: 0.01
      precision: 2
      scan_interval: 10
    - name: "Sol2 Controller Temp"
      unit_of_measurement: °C
      slave: 1
      address: 12561
      input_type: input
      scale: 0.01
      precision: 2
      scan_interval: 10
    - name: "Sol2 WH Today"
      device_class: energy
      unit_of_measurement: KWh
      slave: 1
      address: 13068
      input_type: input
      data_type: int32
      scale: 0.01
      precision: 2
      count: 2
      swap: word
      scan_interval: 10
    - name: "Sol2 WH Month"
      device_class: energy
      unit_of_measurement: KWh
      slave: 1
      address: 13070
      input_type: input
      data_type: int32
      scale: 0.01
      precision: 2
      count: 2
      swap: word
      scan_interval: 10
    - name: "Sol2 WH Year"
      device_class: energy
      unit_of_measurement: KWh
      slave: 1
      address: 13072
      input_type: input
      data_type: int32
      scale: 0.01
      precision: 2
      count: 2
      swap: word
      scan_interval: 10
    - name: "Sol2 WH Total"
      device_class: energy
      unit_of_measurement: KWh
      slave: 1
      address: 13074
      input_type: input
      data_type: int32
      scale: 0.01
      precision: 2
      count: 2
      swap: word
      scan_interval: 10
    binary_sensors:
    - name: "Sol2 load switch"
      slave: 1
      address: 2
      scan_interval: 10

I could not upload the file, so i have to copy it into these Thread.
Thats the complete config at the moment without the new sense.

As per francisp’s suggested, ensure there’s only one modbus: in the file. Remove this line:

modbus1:
1 Like

Here’s an example of how to use 2 modbus devices in a config:

modbus:
# 1st modbus device
    type: rtuovertcp
    host: 10.240.1.4
    port: 8088
    name: epeveriot
    switches:
      - name: Solar Load Switch IOT
        slave: 1
        address: 2
        write_type: coil
        verify:
    sensors:
      - name: "Battery Array Capacity IOT"
        unit_of_measurement: "%"
        slave: 1
        device_class: battery
        address: 12570
    delay: 5
    close_comm_on_error: true
    retry_on_empty: true
    retries: 10
# 2nd modbus device
    type: serial
    baudrate: 115200
    bytesize: 8
    method: rtu
    parity: N
    stopbits: 1
    switches:
      - name: Load Switch 1
        slave: 1
        address: 2
        write_type: coil
        verify:
    sensors:
      - name: "Battery Array Capacity 1"
        unit_of_measurement: "%"
        slave: 1
        device_class: battery
        address: 12570
        input_type: input
        scan_interval: 5

1 Like

@francisp Thank you for your hint to delete the other Modbus entry! Now HA will accept the code.

@123 Hi! Yes, i have deleted the second Modbus and now its accepted. Thank you!

1 Like

@Brynn Thank you for your example in syntax! Now its clear how to define that. I have to say, that i came from the (){}-Programming world, and for me, it is a bit strange to use whitespace as separators :wink:
Furthermore thank you for your shared code to include the epever controller! At the moment its not working properly on my side. The supplier had send the wrong device to me (Only cloud service).

Have a nice day @ all!

Greetings, Bjoern

You’re welcome! However you should mark francisp’s post with the Solution tag, not my post, because his was the first to make the suggestion to make sure you only have one modbus in the configuration.

Of course, that was my fault.
I had selected a few post as the solution.
But the software will only accept only one post.

Have a nice weekend!

1 Like