Energy sensor/template

I have no idea how you have your configuration.yaml set up, so I don’tknow how to answer that. Typically if you had a separate binary_sensor section, your include would look like this:

binary_sensor: !include binary_sensor.yaml
sensor: !include sensor.yaml

and then inside the file, you’d omit the section and just have the platforms.

binary_sensor.yaml

- platform: template
  sensors:
    my_first_binary_sensor:
      ...
    my_second_binary_sensor:
      ...

sensor.yaml

- platform: template
  sensors:
    my_first_sensor:
      ...
    my_second_sensor:
      ...

@petro

I don’t understand, I have a binary_sensor: !include binary_sensor.yaml
if I try to add:

sensor: !include binary_sensor_yaml I get a duplicate error.

where do I need to make a template normally like this then?

Look at what I wrote and compare it to what you said. You’re including the same file in both areas, I’m not.

Err…

sensor: !include binary_sensor.yaml Should be:

sensor: !include sensor.yaml

1 Like

Yeah… copy paste :man_facepalming:

1 Like

@petro

I got it working for now, the only thing is that I had to put the template in my Config… for some reason it won’t work when I separate it.

because you were probably adding a second field name, like you said earlier.

@petro

it’s correct know, first time I had a error, now did it over. whit sensor.yaml / !include sensor.yaml

1 Like

Nice, glad you got it working with includes.

1 Like

strange, it just stop working! I didn’t change anything, the sensors created by the utility_meter are not updating anymore… I checked everything, all is still the same.

the smart plug reports over Mqtt, the entity in HA is still reporting some kWh’s, only the extra sensors are not! anyone any idea?

this is the utility_meter:

utility_meter:
  daily_energy_tv_wand:
    source: sensor.tv_wand_plug_energy
    cycle: daily
  monthly_energy_tv_wand:
    source: sensor.tv_wand_plug_energy
    cycle: monthly

this is HA entity:

sensor.tv_wand_plug_energy

what Mqtt publish:

NFO: MQTT publish: topic 'zigbee2mqtt/tv wand plug', payload '{"consumption":5.33,"current":0.6682,"energy":1.27,"linkquality":11,"power":147.56,"state":"ON","temperature":21,"voltage":224}'

The problem is found, I updated zigbee2mqtt. That broke the energy state for my smart plug in not increasing the value anymore!