Hi, I’m Markus and newbie.
I still have HA now for 1/2 year. But still now I work with the basics in HA. I did a little bit of YAML. But not more then c/p. But now I tried to create me first own entity.
I have many Shellys at home and now i tried to add the power-entities in 1 value.
Thats my config:
- configuration.yaml
template: !include_dir_list template/
- folder: template
- file: sensor.yaml
the code:
name: "total energy"
unique_id: "total energy"
device_clase: "power"
unit_of_measurement: 'KW'
value_template: "{{ (states('sensor.120_power') | float +
states('sensor.wz_shelly_176_channel_1_power') | float +
states('sensor.wz_shelly_176_channel_2_power') | float +
states('sensor.192_power') | float +
states('sensor.196_power') | float) | round(0) }}"
Under development/templates/template-editor I get a value_template : “212”
My question: I searched the value “total energy” under actual entities. But i can not find anything.
Pls can anybody help me. What is my mistake. I look new for 3 night for any solution.
Thx Markus
You are using the legacy style template sensor configuration which should be included under the top-level key sensor
, but you have included it under the template
key. You should be using the current format, and you either need to include defaults for your floats or filter out non-numeric values.
Also… device_class (not device_clase).
What are you measuring? You have called your template sensor total energy, but the sensors seem to be power sensors. Energy is not the same as power - a power sensor would typically have W as a unit of measurement; an energy sensor would typically have kWh a unit of measurement.
If it’s any help, a “modern” template sensor should look something like this:
- sensor:
- name: "total_energy"
state: '{{ states("sensor.washing_machine_energy")| float(0) + states("sensor.cooker_energy")| float(0) + states("sensor.computers_energy")| float(0) + states("sensor.smarthome_energy")| float(0) + states("sensor.lighting_energy")| float(0) }}'
device_class: energy
state_class: total_increasing
unit_of_measurement: kWh
Hi Didgeridrew/Stiltjack.
many thx for answers. Will test it this weekend.
Markus