Problem with config.yaml

Hi, im trying to add a couple of lines to my config.yaml but im getting the red circle with an explanation mark stopping me from doing so.
Im thinking its something to do with the previous template that i have made? - but just a guess. Is it possible to have two templates one after another?

My yaml file is below, please scroll to the bottom.
Im completely new to ha, but have managed to get things working for my inverter, and now trying to capture data from a shunt using a wemos d1 mini over mqtt…

(Home Assistant + Tasmota (Wemos mini R1) + Battery meter KG140F - #23 by Catchmydrift)

Im trying to add these lines:

template:
  - trigger:
      - platform: mqtt
        topic: tele/D1_mini_1/RESULT

But cant even add the first line ‘template’… Presumably due to the previous template? - of so, how do i end a template to add a fresh new one?

Thank you :+1::+1:

You need to format your code. It looks like jibberish if you don’t. Use 3 backticks before your code and 3 backticks after your code. This is a backtick `. If you have an american keyboard, it shares the same button as ~. Edit your original post and format it. Do not copy from your original post and paste as it will retain the incorrect format.

However, even without formatting I can tell you’re trying to add a template: section at the bottom of your file when you already have a template section. That is not possible, your code needs to go in the template section. Make sure you don’t also paste the word template: into your template: section.

Thanks very much, that really helped :+1:. (ive added my yaml file below, the spaces may be slightly wrong at the line - trigger and below, as added them in a minute ago as i Deleted them for the moment)

The syntax is correct now, but unfortunately i get this error in the logs:

Logger: homeassistant.config
Source: config.py:982
First occurred: 8:21:48 PM (3 occurrences)
Last logged: 8:23:50 PM

Invalid config for [template]: [trigger] is an invalid option for [template]. Check: template->sensor->3->trigger. (See /config/configuration.yaml, line 183).
Invalid config for [template]: [trigger] is an invalid option for [template]. Check: template->sensor->3->trigger. (See /config/configuration.yaml, line 180).

Any ideas much appreciated :sob:

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

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

# Text to speech
tts:
  - platform: google_translate

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

http:
  use_x_forwarded_for: true
  trusted_proxies:
    - 172.30.33.0/24
    


modbus:
  - name: epever
    type: rtuovertcp
    host: 192.168.0.188
    port: 8088
    delay: 5
    timeout: 10
    close_comm_on_error: false
    retry_on_empty: true
    retries: 20
    sensors:
      # Utility
      - name: "Grid Voltage"
        unit_of_measurement: V
        slave: 10
        address: 0x3500
        input_type: input
        scale: 0.01
        precision: 2      
      - name: "Grid Current"
        unit_of_measurement: A
        slave: 10
        address: 0x3501
        input_type: input
        scale: 0.01
        precision: 2  
      - name: "Grid State"
        # 0:Normal, 1:Low input; 2:High input, 3: No connected
        slave: 10
        address: 0x3511
        input_type: input
      - name: "Grid Total"
        unit_of_measurement: kWh
        slave: 10
        address: 0x350F
        input_type: input
        scale: 0.01
        precision: 2
        data_type: int32
        swap: word
        count: 2
      # PV Array
      - name: "PV Voltage"
        unit_of_measurement: V
        slave: 10
        address: 0x3549
        input_type: input
        scale: 0.01
        precision: 2   
      - name: "PV Current"
        unit_of_measurement: A
        slave: 10
        address: 0x354A
        input_type: input
        scale: 0.01
        precision: 2
      - name: "PV Power"
        unit_of_measurement: W
        slave: 10
        address: 0x354B
        input_type: input
        scale: 0.01
        precision: 2
        data_type: int32
        swap: word
        count: 2
      - name: "PV Total"
        unit_of_measurement: kWh
        slave: 10
        address: 0x3557
        input_type: input
        scale: 0.01
        precision: 2
        data_type: int32
        swap: word
        count: 2
      # Load
      - name: "Load Voltage"
        unit_of_measurement: V
        slave: 10
        address: 0x3521
        input_type: input
        scale: 0.01
        precision: 2      
      - name: "Load Current"
        unit_of_measurement: A
        slave: 10
        address: 0x3522
        input_type: input
        scale: 0.01
        precision: 2   
      - name: "Load Total"
        unit_of_measurement: kWh
        slave: 10
        address: 0x3530
        input_type: input
        scale: 0.01
        precision: 2
        data_type: int32
        swap: word
        count: 2
      # Battery
      - name: "Battery Voltage"
        unit_of_measurement: V
        slave: 10
        address: 0x3580
        input_type: input
        scale: 0.01
        precision: 2      
      - name: "Battery Current"
        unit_of_measurement: A
        slave: 10
        address: 0x3581
        input_type: input
        scale: 0.01
        precision: 2   
      - name: "Battery Capacity"
        unit_of_measurement: "%"
        slave: 10
        address: 0x3586
        input_type: input
        scale: 1
      - name: "Battery Temp"
        #ElectricChrgBatteryTemp 
        unit_of_measurement: "°C"
        slave: 10
        address: 0x3512
        input_type: input
        scale: 0.01
      - name: "Battery State"
        # 0:Normal, 1:Overvoltage, 2:Undervoltage, 3:Undervoltage Disconnect, 4:Fault 
        slave: 10
        address: 0x3589
        input_type: input
      - name: "Charging Mode"
        # 1:Solar Priority, 2:Utility & Solar, 3:Solar
        slave: 10
        address: 0x9607
        input_type: holding
      - name: "Inverter Mode"
        # 0:Inverter priority, 1:Utility Priority
        slave: 10
        address: 0x9608
        input_type: holding
      - name: "Inverter Temp"
        #LoadHeatSink2Temp 
        unit_of_measurement: "°C"
        slave: 10
        address: 0x3533
        input_type: input
        scale: 0.01
       
       
        
        
        
template:
  sensor:
    - name: "Grid Power"
      unit_of_measurement: W
      device_class: power
      state: "{{((states('sensor.grid_current')| float(0) * states('sensor.grid_voltage')| float(0))) | round(2) }}"
      
    - name: "Power into batt"
      state: "{{ states('sensor.grid_power') | float + states('sensor.pv_power') | float }}"
      unit_of_measurement: W
      device_class: power
        
    - name: "House Load"
      unit_of_measurement: W
      device_class: power
      state: "{{((states('sensor.load_current')| float(0) * states('sensor.load_voltage')| float(0))) | round(2) }}"

 - trigger:
       - platform: mqtt
         topic: tele/D1_mini_1/RESULT

  sensor:
      - name: Temperatura
        unit_of_measurement: "°C"
        state: "{{ (trigger.payload.split(',')[9] | float-100) }}"
      - name: Tensione
        unit_of_measurement: "V"
        state: "{{ (trigger.payload.split(',')[3] | float/100) }}"
      - name: Corrente
        unit_of_measurement: "A"
        state: "{{ (trigger.payload.split(',')[4] | float/100) }}"
      - name: Potenza
        unit_of_measurement: "W"
        state: "{{ (trigger.payload.split(',')[6] | float/100) }}"
      - name: Capacità
        unit_of_measurement: "%"
        state: "{{ (trigger.payload.split(',')[5] | float/11000*100) }}"
      - name: Consumato
        unit_of_measurement: "kWh"
        state: "{{ (trigger.payload.split(',')[6] | float/10000) }}"


sensor:
  - platform: integration
    source: sensor.house_load
    name: energy_used
    unit_prefix: k
    round: 2

The letter t in trigger should line up with the indentation level for a in sensor. Also, the previous sensor will need a dash before it.

Thanks for your help, but when formatted correctly like you say above, i still get this in logs:

Logger: homeassistant.config
Source: config.py:982
First occurred: 7:22:27 PM (1 occurrences)
Last logged: 7:22:27 PM

Invalid config for [template]: [trigger] is an invalid option for [template]. Check: template->sensor->3->trigger. (See /config/configuration.yaml, line 180).

Please post your config

Sorry, do you mean config.yaml? If so:


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

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

# Text to speech
tts:
  - platform: google_translate

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

http:
  use_x_forwarded_for: true
  trusted_proxies:
    - 172.30.33.0/24
    


modbus:
  - name: epever
    type: rtuovertcp
    host: 192.168.0.188
    port: 8088
    delay: 5
    timeout: 10
    close_comm_on_error: false
    retry_on_empty: true
    retries: 20
    sensors:
      # Utility
      - name: "Grid Voltage"
        unit_of_measurement: V
        slave: 10
        address: 0x3500
        input_type: input
        scale: 0.01
        precision: 2      
      - name: "Grid Current"
        unit_of_measurement: A
        slave: 10
        address: 0x3501
        input_type: input
        scale: 0.01
        precision: 2  
      - name: "Grid State"
        # 0:Normal, 1:Low input; 2:High input, 3: No connected
        slave: 10
        address: 0x3511
        input_type: input
      - name: "Grid Total"
        unit_of_measurement: kWh
        slave: 10
        address: 0x350F
        input_type: input
        scale: 0.01
        precision: 2
        data_type: int32
        swap: word
        count: 2
      # PV Array
      - name: "PV Voltage"
        unit_of_measurement: V
        slave: 10
        address: 0x3549
        input_type: input
        scale: 0.01
        precision: 2   
      - name: "PV Current"
        unit_of_measurement: A
        slave: 10
        address: 0x354A
        input_type: input
        scale: 0.01
        precision: 2
      - name: "PV Power"
        unit_of_measurement: W
        slave: 10
        address: 0x354B
        input_type: input
        scale: 0.01
        precision: 2
        data_type: int32
        swap: word
        count: 2
      - name: "PV Total"
        unit_of_measurement: kWh
        slave: 10
        address: 0x3557
        input_type: input
        scale: 0.01
        precision: 2
        data_type: int32
        swap: word
        count: 2
      # Load
      - name: "Load Voltage"
        unit_of_measurement: V
        slave: 10
        address: 0x3521
        input_type: input
        scale: 0.01
        precision: 2      
      - name: "Load Current"
        unit_of_measurement: A
        slave: 10
        address: 0x3522
        input_type: input
        scale: 0.01
        precision: 2   
      - name: "Load Total"
        unit_of_measurement: kWh
        slave: 10
        address: 0x3530
        input_type: input
        scale: 0.01
        precision: 2
        data_type: int32
        swap: word
        count: 2
      # Battery
      - name: "Battery Voltage"
        unit_of_measurement: V
        slave: 10
        address: 0x3580
        input_type: input
        scale: 0.01
        precision: 2      
      - name: "Battery Current"
        unit_of_measurement: A
        slave: 10
        address: 0x3581
        input_type: input
        scale: 0.01
        precision: 2   
      - name: "Battery Capacity"
        unit_of_measurement: "%"
        slave: 10
        address: 0x3586
        input_type: input
        scale: 1
      - name: "Battery Temp"
        #ElectricChrgBatteryTemp 
        unit_of_measurement: "°C"
        slave: 10
        address: 0x3512
        input_type: input
        scale: 0.01
      - name: "Battery State"
        # 0:Normal, 1:Overvoltage, 2:Undervoltage, 3:Undervoltage Disconnect, 4:Fault 
        slave: 10
        address: 0x3589
        input_type: input
      - name: "Charging Mode"
        # 1:Solar Priority, 2:Utility & Solar, 3:Solar
        slave: 10
        address: 0x9607
        input_type: holding
      - name: "Inverter Mode"
        # 0:Inverter priority, 1:Utility Priority
        slave: 10
        address: 0x9608
        input_type: holding
      - name: "Inverter Temp"
        #LoadHeatSink2Temp 
        unit_of_measurement: "°C"
        slave: 10
        address: 0x3533
        input_type: input
        scale: 0.01
       
       
        
        
        
template:
  - sensor:
    - name: "Grid Power"
      unit_of_measurement: W
      device_class: power
      state: "{{((states('sensor.grid_current')| float(0) * states('sensor.grid_voltage')| float(0))) | round(2) }}"
      
    - name: "Power into batt"
      state: "{{ states('sensor.grid_power') | float + states('sensor.pv_power') | float }}"
      unit_of_measurement: W
      device_class: power
        
    - name: "House Load"
      unit_of_measurement: W
      device_class: power
      state: "{{((states('sensor.load_current')| float(0) * states('sensor.load_voltage')| float(0))) | round(2) }}"
    
    - trigger:
      - platform: mqtt
        topic: tele/D1_mini_1/RESULT

      

sensor:
  - platform: integration
    source: sensor.house_load
    name: energy_used
    unit_prefix: k
    round: 2
      

By adding the trigger lines, it stops ‘grid power’ and ‘house load’ sensors from working now also…

Well that’s even worse than your last attempt.

Using your last attempt…

Notice the red line, that’s the indentation level. Hopefully my explanation makes sense now.

Thanks :grin:. Its working now :smiley::smiley::+1::+1:

Ive pasted in some other lines, and the data shows up in HA


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

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

# Text to speech
tts:
  - platform: google_translate

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

http:
  use_x_forwarded_for: true
  trusted_proxies:
    - 172.30.33.0/24
    


modbus:
  - name: epever
    type: rtuovertcp
    host: 192.168.0.188
    port: 8088
    delay: 5
    timeout: 10
    close_comm_on_error: false
    retry_on_empty: true
    retries: 20
    sensors:
      # Utility
      - name: "Grid Voltage"
        unit_of_measurement: V
        slave: 10
        address: 0x3500
        input_type: input
        scale: 0.01
        precision: 2      
      - name: "Grid Current"
        unit_of_measurement: A
        slave: 10
        address: 0x3501
        input_type: input
        scale: 0.01
        precision: 2  
      - name: "Grid State"
        # 0:Normal, 1:Low input; 2:High input, 3: No connected
        slave: 10
        address: 0x3511
        input_type: input
      - name: "Grid Total"
        unit_of_measurement: kWh
        slave: 10
        address: 0x350F
        input_type: input
        scale: 0.01
        precision: 2
        data_type: int32
        swap: word
        count: 2
      # PV Array
      - name: "PV Voltage"
        unit_of_measurement: V
        slave: 10
        address: 0x3549
        input_type: input
        scale: 0.01
        precision: 2   
      - name: "PV Current"
        unit_of_measurement: A
        slave: 10
        address: 0x354A
        input_type: input
        scale: 0.01
        precision: 2
      - name: "PV Power"
        unit_of_measurement: W
        slave: 10
        address: 0x354B
        input_type: input
        scale: 0.01
        precision: 2
        data_type: int32
        swap: word
        count: 2
      - name: "PV Total"
        unit_of_measurement: kWh
        slave: 10
        address: 0x3557
        input_type: input
        scale: 0.01
        precision: 2
        data_type: int32
        swap: word
        count: 2
      # Load
      - name: "Load Voltage"
        unit_of_measurement: V
        slave: 10
        address: 0x3521
        input_type: input
        scale: 0.01
        precision: 2      
      - name: "Load Current"
        unit_of_measurement: A
        slave: 10
        address: 0x3522
        input_type: input
        scale: 0.01
        precision: 2   
      - name: "Load Total"
        unit_of_measurement: kWh
        slave: 10
        address: 0x3530
        input_type: input
        scale: 0.01
        precision: 2
        data_type: int32
        swap: word
        count: 2
      # Battery
      - name: "Battery Voltage"
        unit_of_measurement: V
        slave: 10
        address: 0x3580
        input_type: input
        scale: 0.01
        precision: 2      
      - name: "Battery Current"
        unit_of_measurement: A
        slave: 10
        address: 0x3581
        input_type: input
        scale: 0.01
        precision: 2   
      - name: "Battery Capacity"
        unit_of_measurement: "%"
        slave: 10
        address: 0x3586
        input_type: input
        scale: 1
      - name: "Battery Temp"
        #ElectricChrgBatteryTemp 
        unit_of_measurement: "°C"
        slave: 10
        address: 0x3512
        input_type: input
        scale: 0.01
      - name: "Battery State"
        # 0:Normal, 1:Overvoltage, 2:Undervoltage, 3:Undervoltage Disconnect, 4:Fault 
        slave: 10
        address: 0x3589
        input_type: input
      - name: "Charging Mode"
        # 1:Solar Priority, 2:Utility & Solar, 3:Solar
        slave: 10
        address: 0x9607
        input_type: holding
      - name: "Inverter Mode"
        # 0:Inverter priority, 1:Utility Priority
        slave: 10
        address: 0x9608
        input_type: holding
      - name: "Inverter Temp"
        #LoadHeatSink2Temp 
        unit_of_measurement: "°C"
        slave: 10
        address: 0x3533
        input_type: input
        scale: 0.01
       
       
        
        
        
template:
- sensor:
    - name: "Grid Power"
      unit_of_measurement: W
      device_class: power
      state: "{{((states('sensor.grid_current')| float(0) * states('sensor.grid_voltage')| float(0))) | round(2) }}"
      
    - name: "Power into batt"
      state: "{{ states('sensor.grid_power') | float + states('sensor.pv_power') | float }}"
      unit_of_measurement: W
      device_class: power
        
    - name: "House Load"
      unit_of_measurement: W
      device_class: power
      state: "{{((states('sensor.load_current')| float(0) * states('sensor.load_voltage')| float(0))) | round(2) }}"
    
- trigger:
  - platform: mqtt
    topic: tele/D1_mini_1/RESULT
      
  sensor:
    - name: Temperatura
      unit_of_measurement: "°C"
      state: "{{ (trigger.payload.split(',')[9] | float-100) }}"
    - name: Tensione
      unit_of_measurement: "V"
      state: "{{ (trigger.payload.split(',')[3] | float/100) }}"
    - name: Corrent
      unit_of_measurement: "A"
      state: "{{ (trigger.payload.split(',')[4] | float/100) }}"
    - name: Potenza
      unit_of_measurement: "W"
      state: "{{ (trigger.payload.split(',')[6] | float/100) }}"
    - name: Capacità
      unit_of_measurement: "%"
      state: "{{ (trigger.payload.split(',')[5] | float/11000*100) }}"
    - name: Consumato
      unit_of_measurement: "kWh"
      state: "{{ (trigger.payload.split(',')[6] | float/10000) }}"  
      

sensor:
  - platform: integration
    source: sensor.house_load
    name: energy_used
    unit_prefix: k
    round: 2
      
1 Like