Integrating existing MQTT devices

I have a bunch of devices around the house that have been designed to operate with Node Red. There are a lot, so I do’t want to change their code. They must stay ‘as is’.
They publish and subscribe to Node Red topics and are mostly simple values like temperature, light level, PIR status. I am trying to transistion from a working Node Red set up to Home Assistant. I have the MQTT add on installed but it is not detecting any devices. I can set up a single topic to monitor in the MQTT configuration and the value is correct. How can I add all the other topics I want to monitor. I’ll worry about publishing later. I tried editing the configuration.yaml and it shows a tick but it doesn’t work. It comes up as an error in Notifications

You have to create a mqtt entity for each device

How do I do that? Can you give an example?

1 Like

My MQTT.yaml

    
#--------------------------------------------------------------------------------------
# voordeur 
#--------------------------------------------------------------------------------------

  sensor:
    - name: "Frontdoor"
      state_topic: "sensor/frontdoor"
      
#--------------------------------------------------------------------------------------
# energy
#--------------------------------------------------------------------------------------

    - name: "mains total energy"
      state_topic: "sensor/totalenergy"    
      unique_id: "mains_energy_total"    

    - name: "mains energy yesterday"
      state_topic: "sensor/yesterday_energy"
      unique_id: "mains_energy_yesterday"    
      
          
    
    

#
#--------------------------------------------------------------------------------------
# ZMAI's
#--------------------------------------------------------------------------------------
#
    - name: "Mains Consumed Energy"
      state_topic: "electricity1/tele/RESULT"
      value_template: >- 
        {% set message = value_json.SerialReceived %}
        {% set payload = message[6:14] %}
        {% set payload_len = (payload | length) %}
        {% set result = namespace(value='') %}
      
        {% for i in range(0, payload_len + 1) | reverse -%}
          {%- if i is divisibleby 2 -%}
            {%- set result.value = result.value + payload[i:i+2] -%}
          {%- endif -%}
        {%- endfor -%}
      
        {{ (result.value|float(0)) / 100 }}
      unit_of_measurement: 'kWh'
      unique_id: "mains_consumed_energy"
      device_class: energy
      state_class: total_increasing
      device:
        identifiers:
          - C265BD
        connections:
          - - mac
            - 98:F4:AB:C2:65:BD
        name: electricity1
        model: Generic
        sw_version: 8.1.0.2(tasmota)
        manufacturer: Tasmota

    - name: "Mains Voltage"
      state_topic: "electricity1/tele/RESULT"
      value_template: >- 
        {% set message = value_json.SerialReceived %}
        {% set payload = message[14:22] %}
        {% set payload_len = (payload | length) %}
        {% set result = namespace(value='') %}
      
        {% for i in range(0, payload_len + 1) | reverse -%}
          {%- if i is divisibleby 2 -%}
           {%- set result.value = result.value + payload[i:i+2] -%}
         {%- endif -%}
        {%- endfor -%}
      
        {{ (result.value|float(0)) / 10 }}
      unit_of_measurement: 'V'
      unique_id: "mains_voltage"    
      device:
        identifiers:
          - C265BD
        connections:
          - - mac
            - 98:F4:AB:C2:65:BD
        name: electricity1
        model: Generic
        sw_version: 8.1.0.2(tasmota)
        manufacturer: Tasmota
      
    - name: "Mains Current"
      state_topic: "electricity1/tele/RESULT"
      value_template: >- 
        {% set message = value_json.SerialReceived %}
        {% set payload = message[22:30] %}
        {% set payload_len = (payload | length) %}
        {% set result = namespace(value='') %}
      
        {% for i in range(0, payload_len + 1) | reverse -%}
          {%- if i is divisibleby 2 -%}
            {%- set result.value = result.value + payload[i:i+2] -%}
          {%- endif -%}
        {%- endfor -%}
      
        {{ (result.value|float(0)) / 10000 }}
      unit_of_measurement: 'A'
      unique_id: "mains_current"
      device:
        identifiers:
          - C265BD
        connections:
          - - mac
            - 98:F4:AB:C2:65:BD
        name: electricity1
        model: Generic
        sw_version: 8.1.0.2(tasmota)
        manufacturer: Tasmota
      
#  - platform: mqtt
#    name: "Mains Frequency"
#    state_topic: "electricity1/tele/RESULT"
#    value_template: >- 
#      {% set message = value_json.SerialReceived %}
#      {% set payload = message[30:38] %}
#      {% set payload_len = (payload | length) %}
#      {% set result = namespace(value='') %}
      
#      {% for i in range(0, payload_len + 1) | reverse -%}
#        {%- if i is divisibleby 2 -%}
#          {%- set result.value = result.value + payload[i:i+2] -%}
#        {%- endif -%}
#      {%- endfor -%}
      
#      {{ (result.value|float(0)) / 100 }}
#    unit_of_measurement: 'Hz'
#    unique_id: "mains_frequency"        

    - name: "Mains Active Power"
      state_topic: "electricity1/tele/RESULT"
      value_template: >- 
        {% set message = value_json.SerialReceived %}
        {% set payload = message[38:46] %}
        {% set payload_len = (payload | length) %}
        {% set result = namespace(value='') %}
      
        {% for i in range(0, payload_len + 1) | reverse -%}
          {%- if i is divisibleby 2 -%}
            {%- set result.value = result.value + payload[i:i+2] -%}
          {%- endif -%}
        {%- endfor -%}
      
        {{ (result.value|float(0)) / 100 }}
      unit_of_measurement: 'W'
      unique_id: "mains_active_power"        
      device:
        identifiers:
          - C265BD
        connections:
          - - mac
            - 98:F4:AB:C2:65:BD
        name: electricity1
        model: Generic
        sw_version: 8.1.0.2(tasmota)
        manufacturer: Tasmota

#  - platform: mqtt
#    name: "Mains Reactive Power"
#    state_topic: "electricity1/tele/RESULT"
#    value_template: >- 
#      {% set message = value_json.SerialReceived %}
#      {% set payload = message[46:54] %}
#      {% set payload_len = (payload | length) %}
#      {% set result = namespace(value='') %}
#      
#      {% for i in range(0, payload_len + 1) | reverse -%}
#        {%- if i is divisibleby 2 -%}
#          {%- set result.value = result.value + payload[i:i+2] -%}
#        {%- endif -%}
#      {%- endfor -%}
      
#      {{ (result.value|float(0)) / 100 }}
#    unit_of_measurement: 'W'
#    unique_id: "mains_reactive_power"        

#  - platform: mqtt
#    name: "Mains Apparent Power"
#    state_topic: "electricity1/tele/RESULT"
#    value_template: >- 
#      {% set message = value_json.SerialReceived %}
#      {% set payload = message[54:62] %}
#      {% set payload_len = (payload | length) %}
#      {% set result = namespace(value='') %}
#      
#      {% for i in range(0, payload_len + 1) | reverse -%}
#        {%- if i is divisibleby 2 -%}
#          {%- set result.value = result.value + payload[i:i+2] -%}
#        {%- endif -%}
#      {%- endfor -%}
#      
#      {{ (result.value|float(0)) / 100 }}
#    unit_of_measurement: 'W'
#    unique_id: "mains_apparent_power"    

#  - platform: mqtt
#    name: "Mains Power Factor"
#    state_topic: "electricity1/tele/RESULT"
#    value_template: >- 
#      {% set message = value_json.SerialReceived %}
#      {% set payload = message[62:70] %}
#      {% set payload_len = (payload | length) %}
#      {% set result = namespace(value='') %}
#      
#      {% for i in range(0, payload_len + 1) | reverse -%}
#        {%- if i is divisibleby 2 -%}
#          {%- set result.value = result.value + payload[i:i+2] -%}
#        {%- endif -%}
#      {%- endfor -%}
#      
#      {{ (result.value|float(0)) / 10 }}
#    unit_of_measurement: '%'
#    unique_id: "mains_power_factor"    




    - name: "Upstairs Consumed Energy"
      state_topic: "electricity2/tele/RESULT"
      value_template: >- 
        {% set message = value_json.SerialReceived %}
        {% set payload = message[6:14] %}
        {% set payload_len = (payload | length) %}
        {% set result = namespace(value='') %}
      
        {% for i in range(0, payload_len + 1) | reverse -%}
          {%- if i is divisibleby 2 -%}
            {%- set result.value = result.value + payload[i:i+2] -%}
          {%- endif -%}
        {%- endfor -%}
      
        {{ (result.value|float(0)) / 100 }}
      unit_of_measurement: 'kWh'
      unique_id: "upstairs_consumed_energy"
      device_class: energy
      state_class: total_increasing
      device:
        identifiers:
          - C21FF1
        name: electricity2
        model: Generic
        sw_version: 8.4.0.3(0f1e4fc-tasmota)
        manufacturer: Tasmota
      

    - name: "Upstairs Voltage"
      state_topic: "electricity2/tele/RESULT"
      value_template: >- 
        {% set message = value_json.SerialReceived %}
        {% set payload = message[14:22] %}
        {% set payload_len = (payload | length) %}
        {% set result = namespace(value='') %}
      
        {% for i in range(0, payload_len + 1) | reverse -%}
          {%- if i is divisibleby 2 -%}
            {%- set result.value = result.value + payload[i:i+2] -%}
          {%- endif -%}
        {%- endfor -%}
      
        {{ (result.value|float(0)) / 10 }}
      unit_of_measurement: 'V'
      unique_id: "upstairs_voltage"    
      device:
        identifiers:
          - C21FF1
        name: electricity2
        model: Generic
        sw_version: 8.4.0.3(0f1e4fc-tasmota)
        manufacturer: Tasmota
      
    - name: "Upstairs Current"
      state_topic: "electricity2/tele/RESULT"
      value_template: >- 
        {% set message = value_json.SerialReceived %}
        {% set payload = message[22:30] %}
        {% set payload_len = (payload | length) %}
        {% set result = namespace(value='') %}
      
        {% for i in range(0, payload_len + 1) | reverse -%}
          {%- if i is divisibleby 2 -%}
            {%- set result.value = result.value + payload[i:i+2] -%}
          {%- endif -%}
        {%- endfor -%}
      
        {{ (result.value|float(0)) / 10000 }}
      unit_of_measurement: 'A'
      unique_id: "upstairs_current"    
      device:
        identifiers:
          - C21FF1
        name: electricity2
        model: Generic
        sw_version: 8.4.0.3(0f1e4fc-tasmota)
        manufacturer: Tasmota
      
#  - platform: mqtt
#    name: "Upstairs Frequency"
#    state_topic: "electricity2/tele/RESULT"
#    value_template: >- 
#      {% set message = value_json.SerialReceived %}
#      {% set payload = message[30:38] %}
#      {% set payload_len = (payload | length) %}
#      {% set result = namespace(value='') %}
#      
#      {% for i in range(0, payload_len + 1) | reverse -%}
#        {%- if i is divisibleby 2 -%}
#          {%- set result.value = result.value + payload[i:i+2] -%}
#        {%- endif -%}
#      {%- endfor -%}
      
#      {{ (result.value|float(0)) / 100 }}
#    unit_of_measurement: 'Hz'
#    unique_id: "upstairs_frequency"        
    - name: "Upstairs Active Power"
      state_topic: "electricity2/tele/RESULT"
      value_template: >- 
        {% set message = value_json.SerialReceived %}
        {% set payload = message[38:46] %}
        {% set payload_len = (payload | length) %}
        {% set result = namespace(value='') %}
      
        {% for i in range(0, payload_len + 1) | reverse -%}
          {%- if i is divisibleby 2 -%}
            {%- set result.value = result.value + payload[i:i+2] -%}
          {%- endif -%}
        {%- endfor -%}
      
        {{ (result.value|float(0)) / 100 }}
      unit_of_measurement: 'W'
      unique_id: "upstairs_active_power"
      device:
        identifiers:
          - C21FF1
        name: electricity2
        model: Generic
        sw_version: 8.4.0.3(0f1e4fc-tasmota)
        manufacturer: Tasmota
      
#  - platform: mqtt
#    name: "Upstairs Reactive Power"
#    state_topic: "electricity2/tele/RESULT"
#    value_template: >- 
#      {% set message = value_json.SerialReceived %}
#      {% set payload = message[46:54] %}
#      {% set payload_len = (payload | length) %}
#      {% set result = namespace(value='') %}
      
#      {% for i in range(0, payload_len + 1) | reverse -%}
#        {%- if i is divisibleby 2 -%}
#          {%- set result.value = result.value + payload[i:i+2] -%}
#        {%- endif -%}
#      {%- endfor -%}
      
#      {{ (result.value|float(0)) / 100 }}
#    unit_of_measurement: 'W'
#    unique_id: "upstairs_reactive_power"        
#  - platform: mqtt
#    name: "Upstairs Apparent Power"
#    state_topic: "electricity2/tele/RESULT"
#    value_template: >- 
#      {% set message = value_json.SerialReceived %}
#      {% set payload = message[54:62] %}
#      {% set payload_len = (payload | length) %}
#      {% set result = namespace(value='') %}
#      
#      {% for i in range(0, payload_len + 1) | reverse -%}
#        {%- if i is divisibleby 2 -%}
#          {%- set result.value = result.value + payload[i:i+2] -%}
#        {%- endif -%}
#      {%- endfor -%}
#      
#      {{ (result.value|float(0)) / 100 }}
#    unit_of_measurement: 'W'
#    unique_id: "upstairs_apparent_power"    

#  - platform: mqtt
#    name: "Upstairs Power Factor"
#    state_topic: "electricity2/tele/RESULT"
#    value_template: >- 
#      {% set message = value_json.SerialReceived %}
#      {% set payload = message[62:70] %}
#      {% set payload_len = (payload | length) %}
#      {% set result = namespace(value='') %}
#      
#      {% for i in range(0, payload_len + 1) | reverse -%}
#        {%- if i is divisibleby 2 -%}
#          {%- set result.value = result.value + payload[i:i+2] -%}
#        {%- endif -%}
#      {%- endfor -%}
#      
#      {{ (result.value|float(0)) / 10 }}
#    unit_of_measurement: '%'
#    unique_id: "upstairs_power_factor"    
    



    - name: "Extra Consumed Energy"
      state_topic: "electricity3/tele/RESULT"
      value_template: >- 
        {% set message = value_json.SerialReceived %}
        {% set payload = message[6:14] %}
        {% set payload_len = (payload | length) %}
        {% set result = namespace(value='') %}
      
        {% for i in range(0, payload_len + 1) | reverse -%}
          {%- if i is divisibleby 2 -%}
            {%- set result.value = result.value + payload[i:i+2] -%}
          {%- endif -%}
        {%- endfor -%}
      
        {{ (result.value|float(0)) / 100 }}
      unit_of_measurement: 'kWh'
      unique_id: "extra_consumed_energy"    
      device_class: energy
      state_class: total_increasing      
      device:
        identifiers:
          - C24112
        name: electricity3
        model: Generic
        sw_version: 8.4.0.2(6e11147-tasmota)
        manufacturer: Tasmota

    - name: "Extra Voltage"
      state_topic: "electricity3/tele/RESULT"
      value_template: >- 
        {% set message = value_json.SerialReceived %}
        {% set payload = message[14:22] %}
        {% set payload_len = (payload | length) %}
        {% set result = namespace(value='') %}
      
        {% for i in range(0, payload_len + 1) | reverse -%}
          {%- if i is divisibleby 2 -%}
            {%- set result.value = result.value + payload[i:i+2] -%}
          {%- endif -%}
        {%- endfor -%}
      
        {{ (result.value|float(0)) / 10 }}
      unit_of_measurement: 'V'
      unique_id: "extra_voltage"    
      device:
        identifiers:
          - C24112
        name: electricity3
        model: Generic
        sw_version: 8.4.0.2(6e11147-tasmota)
        manufacturer: Tasmota
  
    - name: "Extra Current"
      state_topic: "electricity3/tele/RESULT"
      value_template: >- 
        {% set message = value_json.SerialReceived %}
        {% set payload = message[22:30] %}
        {% set payload_len = (payload | length) %}
        {% set result = namespace(value='') %}
      
        {% for i in range(0, payload_len + 1) | reverse -%}
          {%- if i is divisibleby 2 -%}
            {%- set result.value = result.value + payload[i:i+2] -%}
          {%- endif -%}
        {%- endfor -%}
       
        {{ (result.value|float(0)) / 10000 }}
      unit_of_measurement: 'A'
      unique_id: "extra_current"    
      device:
        identifiers:
          - C24112
        name: electricity3
        model: Generic
        sw_version: 8.4.0.2(6e11147-tasmota)
        manufacturer: Tasmota

#  - platform: mqtt
#    name: "Extra Frequency"
#    state_topic: "electricity3/tele/RESULT"
#    value_template: >- 
#      {% set message = value_json.SerialReceived %}
#      {% set payload = message[30:38] %}
#      {% set payload_len = (payload | length) %}
#      {% set result = namespace(value='') %}
      
#      {% for i in range(0, payload_len + 1) | reverse -%}
#        {%- if i is divisibleby 2 -%}
#          {%- set result.value = result.value + payload[i:i+2] -%}
#        {%- endif -%}
#      {%- endfor -%}
      
#      {{ (result.value|float(0)) / 100 }}
#    unit_of_measurement: 'Hz'
#    unique_id: "extra_frequency"        

    - name: "Extra Active Power"
      state_topic: "electricity3/tele/RESULT"
      value_template: >- 
        {% set message = value_json.SerialReceived %}
        {% set payload = message[38:46] %}
        {% set payload_len = (payload | length) %}
        {% set result = namespace(value='') %}
      
        {% for i in range(0, payload_len + 1) | reverse -%}
          {%- if i is divisibleby 2 -%}
            {%- set result.value = result.value + payload[i:i+2] -%}
          {%- endif -%}
        {%- endfor -%}
      
        {{ (result.value|float(0)) / 100 }}
      unit_of_measurement: 'W'
      unique_id: "extra_active_power"        
      device:
        identifiers:
          - C24112
        name: electricity3
        model: Generic
        sw_version: 8.4.0.2(6e11147-tasmota)
        manufacturer: Tasmota

#  - platform: mqtt
#    name: "Extra Reactive Power"
#    state_topic: "electricity3/tele/RESULT"
#    value_template: >- 
#      {% set message = value_json.SerialReceived %}
#      {% set payload = message[46:54] %}
#      {% set payload_len = (payload | length) %}
#      {% set result = namespace(value='') %}
#      
#      {% for i in range(0, payload_len + 1) | reverse -%}
#        {%- if i is divisibleby 2 -%}
#          {%- set result.value = result.value + payload[i:i+2] -%}
#        {%- endif -%}
#      {%- endfor -%}
      
#      {{ (result.value|float(0)) / 100 }}
#    unit_of_measurement: 'W'
#    unique_id: "extra_reactive_power"        

#  - platform: mqtt
#    name: "Extra Apparent Power"
#    state_topic: "electricity3/tele/RESULT"
#    value_template: >- 
#      {% set message = value_json.SerialReceived %}
#      {% set payload = message[54:62] %}
#      {% set payload_len = (payload | length) %}
#      {% set result = namespace(value='') %}
#      
#      {% for i in range(0, payload_len + 1) | reverse -%}
#        {%- if i is divisibleby 2 -%}
#          {%- set result.value = result.value + payload[i:i+2] -%}
#        {%- endif -%}
#      {%- endfor -%}
#      
#      {{ (result.value|float(0)) / 100 }}
#    unit_of_measurement: 'W'
#    unique_id: "extra_apparent_power"    

#  - platform: mqtt
#    name: "Extra Power Factor"
#    state_topic: "electricity3/tele/RESULT"
#    value_template: >- 
#      {% set message = value_json.SerialReceived %}
#      {% set payload = message[62:70] %}
#      {% set payload_len = (payload | length) %}
#      {% set result = namespace(value='') %}
#      
#      {% for i in range(0, payload_len + 1) | reverse -%}
#        {%- if i is divisibleby 2 -%}
#          {%- set result.value = result.value + payload[i:i+2] -%}
#        {%- endif -%}
#      {%- endfor -%}
#      
#      {{ (result.value|float(0)) / 10 }}
#    unit_of_measurement: '%'
#    unique_id: "extra_power_factor"    





    - name: "Kitchen Consumed Energy"
      state_topic: "electricity4/tele/RESULT"
      value_template: >- 
        {% set message = value_json.SerialReceived %}
        {% set payload = message[6:14] %}
        {% set payload_len = (payload | length) %}
        {% set result = namespace(value='') %}
      
        {% for i in range(0, payload_len + 1) | reverse -%}
          {%- if i is divisibleby 2 -%}
            {%- set result.value = result.value + payload[i:i+2] -%}
          {%- endif -%}
        {%- endfor -%}
      
        {{ (result.value|float(0)) / 100 }}
      unit_of_measurement: 'kWh'
      unique_id: "kitchen_consumed_energy"    
      device_class: energy
      state_class: total_increasing
      device:
        identifiers:
          - C220A4
        connections:
          - - mac
            - 98:F4:AB:C2:20:A4          
        name: electricity4
        model: Generic
        sw_version: 8.1.0.2(tasmota)
        manufacturer: Tasmota

    - name: "Kitchen Voltage"
      state_topic: "electricity4/tele/RESULT"
      value_template: >- 
        {% set message = value_json.SerialReceived %}
        {% set payload = message[14:22] %}
        {% set payload_len = (payload | length) %}
        {% set result = namespace(value='') %}
      
        {% for i in range(0, payload_len + 1) | reverse -%}
          {%- if i is divisibleby 2 -%}
            {%- set result.value = result.value + payload[i:i+2] -%}
          {%- endif -%}
        {%- endfor -%}
      
        {{ (result.value|float(0)) / 10 }}
      unit_of_measurement: 'V'
      unique_id: "kitchen_voltage"    
      device:
        identifiers:
          - C220A4
        connections:
          - - mac
            - 98:F4:AB:C2:20:A4          
        name: electricity4
        model: Generic
        sw_version: 8.1.0.2(tasmota)
        manufacturer: Tasmota

    - name: "Kitchen Current"
      state_topic: "electricity4/tele/RESULT"
      value_template: >- 
        {% set message = value_json.SerialReceived %}
        {% set payload = message[22:30] %}
        {% set payload_len = (payload | length) %}
        {% set result = namespace(value='') %}
      
        {% for i in range(0, payload_len + 1) | reverse -%}
          {%- if i is divisibleby 2 -%}
            {%- set result.value = result.value + payload[i:i+2] -%}
          {%- endif -%}
        {%- endfor -%}
      
        {{ (result.value|float(0)) / 10000 }}
      unit_of_measurement: 'A'
      unique_id: "kitchen_current"    
      device:
        identifiers:
          - C220A4
        connections:
          - - mac
            - 98:F4:AB:C2:20:A4          
        name: electricity4
        model: Generic
        sw_version: 8.1.0.2(tasmota)
        manufacturer: Tasmota

#  - platform: mqtt
#    name: "Kitchen Frequency"
#    state_topic: "electricity4/tele/RESULT"
#    value_template: >- 
#      {% set message = value_json.SerialReceived %}
#      {% set payload = message[30:38] %}
#      {% set payload_len = (payload | length) %}
#      {% set result = namespace(value='') %}
      
#      {% for i in range(0, payload_len + 1) | reverse -%}
#        {%- if i is divisibleby 2 -%}
#          {%- set result.value = result.value + payload[i:i+2] -%}
#        {%- endif -%}
#      {%- endfor -%}
      
#      {{ (result.value|float(0)) / 100 }}
#    unit_of_measurement: 'Hz'
#    unique_id: "kitchen_frequency"        

    - name: "Kitchen Active Power"
      state_topic: "electricity4/tele/RESULT"
      value_template: >- 
        {% set message = value_json.SerialReceived %}
        {% set payload = message[38:46] %}
        {% set payload_len = (payload | length) %}
        {% set result = namespace(value='') %}
      
        {% for i in range(0, payload_len + 1) | reverse -%}
          {%- if i is divisibleby 2 -%}
            {%- set result.value = result.value + payload[i:i+2] -%}
          {%- endif -%}
        {%- endfor -%}
      
        {{ (result.value|float(0)) / 100 }}
      unit_of_measurement: 'W'
      unique_id: "kitchen_active_power"        
      device:
        identifiers:
          - C220A4
        connections:
          - - mac
            - 98:F4:AB:C2:20:A4          
        name: electricity4
        model: Generic
        sw_version: 8.1.0.2(tasmota)
        manufacturer: Tasmota

#  - platform: mqtt
#    name: "Kitchen Reactive Power"
#    state_topic: "electricity4/tele/RESULT"
#    value_template: >- 
#      {% set message = value_json.SerialReceived %}
#      {% set payload = message[46:54] %}
#      {% set payload_len = (payload | length) %}
#      {% set result = namespace(value='') %}
#      
#      {% for i in range(0, payload_len + 1) | reverse -%}
#        {%- if i is divisibleby 2 -%}
#          {%- set result.value = result.value + payload[i:i+2] -%}
#        {%- endif -%}
#      {%- endfor -%}
      
#      {{ (result.value|float(0)) / 100 }}
#    unit_of_measurement: 'W'
#    unique_id: "kitchen_reactive_power"        

#  - platform: mqtt
#    name: "Kitchen Apparent Power"
#    state_topic: "electricity4/tele/RESULT"
#    value_template: >- 
#      {% set message = value_json.SerialReceived %}
#      {% set payload = message[54:62] %}
#      {% set payload_len = (payload | length) %}
#      {% set result = namespace(value='') %}
#      
#      {% for i in range(0, payload_len + 1) | reverse -%}
#        {%- if i is divisibleby 2 -%}
#          {%- set result.value = result.value + payload[i:i+2] -%}
#        {%- endif -%}
#      {%- endfor -%}
#      
#      {{ (result.value|float(0)) / 100 }}
#    unit_of_measurement: 'W'
#    unique_id: "kitchen_apparent_power"    

#  - platform: mqtt
#    name: "Kitchen Power Factor"
#    state_topic: "electricity4/tele/RESULT"
#    value_template: >- 
#      {% set message = value_json.SerialReceived %}
#      {% set payload = message[62:70] %}
#      {% set payload_len = (payload | length) %}
#      {% set result = namespace(value='') %}
#      
#      {% for i in range(0, payload_len + 1) | reverse -%}
#        {%- if i is divisibleby 2 -%}
#          {%- set result.value = result.value + payload[i:i+2] -%}
#        {%- endif -%}
#      {%- endfor -%}
#      
#      {{ (result.value|float(0)) / 10 }}
#    unit_of_measurement: '%'
#    unique_id: "kitchen_power_factor"    

    - name: "5 Active Power"
      state_topic: "electricity5/tele/RESULT"
      value_template: >- 
        {% set message = value_json.SerialReceived %}
        {% set payload = message[38:46] %}
        {% set payload_len = (payload | length) %}
        {% set result = namespace(value='') %}
      
        {% for i in range(0, payload_len + 1) | reverse -%}
          {%- if i is divisibleby 2 -%}
            {%- set result.value = result.value + payload[i:i+2] -%}
          {%- endif -%}
        {%- endfor -%}
      
        {{ (result.value|float(0)) / 100 }}
      unit_of_measurement: 'W'
      unique_id: "5_active_power"        
      device:
        identifiers:
          - DA463E
        connections:
          - - mac
            - D8:BF:C0:DA:46:3E        

    - name: "6 Active Power"
      state_topic: "electricity6/tele/RESULT"
      value_template: >- 
        {% set message = value_json.SerialReceived %}
        {% set payload = message[38:46] %}
        {% set payload_len = (payload | length) %}
        {% set result = namespace(value='') %}
      
        {% for i in range(0, payload_len + 1) | reverse -%}
          {%- if i is divisibleby 2 -%}
            {%- set result.value = result.value + payload[i:i+2] -%}
          {%- endif -%}
        {%- endfor -%}
      
        {{ (result.value|float(0)) / 100 }}
      unit_of_measurement: 'W'
      unique_id: "6_active_power"        
      device:
        identifiers:
          - C220BF
        connections:
          - - mac
            - 98:F4:AB:C2:20:BF        
        name: electricity6
        model: Generic
        sw_version: 8.1.0.2(tasmota)
        manufacturer: Tasmota

Thank you Francis, that is a very extensive example. Could I ask what kind of current monitor that refers to. I have designed my own module that has a simple Node Redd message in the form Utility/current NN. Where NN is a value representing the RMS current. I would guess that you are using a commercially available current sense flashed with Tasmota software. Most of my modules give a response that is of the same format - room/parameter value. A lot of your file seems to be formatting the file using json, which I am not familiar with. Is it possible to just use
value: number
unit_of_measurement: “Amps”

Or something similar.
Thank you for your feedback.

Ok. I finally cracked it. Thank you for your help