Made a sensor in template, now what?

HI good people.

I want to add two PV panels power output together and show that as one gauge on the UI.

I have created this code in the template editor:

template:
  - sensor:
      - name: "Total Charging Power"
        unit_of_measurement: "W"
        device_class: power
        state: >
          {{ [ states('sensor.solarsynk_2403258282_pv1_power'), 
               states('sensor.solarsynk_2403258282_pv2_power') ]
               | map('float') | sum }}
        availability: >
          {{ not 'unavailable' in 
             [ states('sensor.inverter1qpigs_pv1_charging_power'), 
               states('sensor.inverter2qpigs_pv2_charging_power') ] }}

On the right hand side it gave me this result:

template:
  - sensor:
      - name: "Total Charging Power"
        unit_of_measurement: "W"
        device_class: power
        state: >
          4702.0
        availability: >
          True

What do I do now? I can not find “Total Charging Power” in my entities. I am sure I need to create the sensor still, but I am not sure where or how.

Thanks

That is the template editor. It is used for testing templates. It does not create entities.

You need to add that configuration to your configuration.yaml file and restart home assistant.

1 Like

This is my configuration 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

# Text-to-speech
tts:
  - platform: google_translate

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

Do I just copy and paste it at the bottom? All of it, even the “template:” line?

Yes.

1 Like

This worked 100%, thank you very much.

1 Like