Why do these sensors not appear as entities to be displayed inLovelace

I am very new to HA.
I have copied the confiuration for getting energy values from a tp-link HS110 smart plug into my configuration.yaml, and also written a calculation there as well. The config check comes-up as clear, but I can’t find any of these items in the entities list (so I can display them in Lovelace, use in an automation, etc).

Should they automatically appear in the list of entities ?

sensor:
  - platform: template
    sensors:
      test_switch_amps:
        friendly_name_template: "{{ state_attr('switch.test_switch','friendly_name') }} Current"
        value_template: "{{ state_attr('switch.test_switch','current_a') | float }}"
        unit_of_measurement: "A"
      test_switch_watts:
        friendly_name_template: "{{ state_attr('switch.test_switch','friendly_name') }} Current Consumption"
        value_template: "{{ state_attr('switch.test_switch','current_power_w') | float }}"
        unit_of_measurement: "W"
      test_switch_total_kwh:
        friendly_name_template: "{{ state_attr('switch.test_switch','friendly_name') }} Total Consumption"
        value_template: "{{ state_attr('switch.test_switch','total_energy_kwh') | float }}"
        unit_of_measurement: "kWh"
      test_switch_volts:
        friendly_name_template: "{{ state_attr('switch.test_switch','friendly_name') }} Voltage"
        value_template: "{{ state_attr('switch.test_switch','voltage') | float }}"
        unit_of_measurement: "V"
      test_switch_today_kwh:
        friendly_name_template: "{{ state_attr('switch.test_switch','friendly_name') }} Today's Consumption"
        value_template: "{{ state_attr('switch.test_switch','today_energy_kwh') | float }}"
        unit_of_measurement: "kWh"
#---------------------------------------------------------
# calculation for charging stop power point
      charging_stop_power_calc:
        entity_id: sensor.stop_power_calc
        friendly_name: "Charging stop calc (W)"
        unit_of_measurement: "W"
        value_template: "{{ states('input_number.charging_start_power') | float - states('input_number.charging_hysterisis_w') | float }}" 

Have you either restarted HA or reloaded templates in the server control section?

What he said, and have you looked in states panel in developer tools?

thanks for your replies. I have restarted HA (a few times). I wasn’t aware of the States tab, but now I have checked it out, I can’t see any of them there either.

Check the log for errors

No errors in the Logbook either.

I’m gathering for all your responses, that they should appear in the entities list automatically? I’m not missing a step?

Where did you put this code?

Did you reload templates, or restarted HA ?

the code is in my configuration.yaml file

I restarted HA

Do you have multiple times sensor: in your configuration.yaml?

Not the Logbook but in the home-assistant.log

1 Like

yes, the word “sensor:” appears twice - is it only permitted once ?

ah - the home-assistant.log is new to me - and there it tells me about a duplicate key :sensor:"

thank you all

1 Like

You can only have one sensor: section in one file, all sensors need to be configured under the same section.

Don’t wanna take the solution from @sjee, but to someone else looking at this topic and then the suggested solution, it wouldn’t help them at all, because “checking the logbook” is not the solution, it lead you to the solution.

1 Like