Template sensor doesn't show up in entities

Dear all,

I’m trying to create a template that shows me the total water usage.
The path where I stored the file (sensor.yaml) is: /homeassistant/

After a reboot of HA I don’t see the sensor as an identity.

Who is able and willing to help me and push me in the correct direction to let it work?

I created this sensor:

- platform: template
  sensors:
    watermeter_sensus_total_water_usage:
    unit_of_measurement: "m³"
    friendly_name: "Watermeter Total"
    value_template: "{{ 174.145 + states('sensor.water_meter_homewizard_total_water_usage') | float }}"

Thanks in advance and hope for the best :pray:

Regards

Bert

is sensor included in configuration.yaml pointing to sensor.yaml?

sensor: !include sensor.yaml

Indent properly.

Also make sure to put a default for your float… without a default, if your usage sensor isn’t reporting a numeric state it will cause the template to fail.

It’s usually a good idea to have an availability too.

- platform: template
  sensors:
    watermeter_sensus_total_water_usage:
      unit_of_measurement: "m³"
      friendly_name: "Watermeter Total"
      value_template: "{{ 174.145 + states('sensor.water_meter_homewizard_total_water_usage') | float(0) }}"
      availability_template: "{{ has_value('sensor.water_meter_homewizard_total_water_usage')  }}" 
1 Like

Also please use the new template sensor format for new sensors. The legacy format is not getting any new features (like state_class).

configuration.yaml (not sensors.yaml)

template:
  - sensor:
      - name: "Watermeter Total"
        unit_of_measurement: "m³"
        device_class: water
        state_class: total # or total_increasing
        state: "{{ 174.145 + states('sensor.water_meter_homewizard_total_water_usage') | float(0) }}"
        availability: "{{ has_value('sensor.water_meter_homewizard_total_water_usage')  }}"

Hopping in, why not creating a Utility Meter helper from the UI and then call the calibrate service to match your real total?

Also keep in mind to never use the HomeWizard Water Meter to pass on your consumption to your supplier, the values are not guaranteed to be accurate.

Dear all,

You all deserved a beer, it is finally working and the code that was working for me was:

template:
  - sensor:
      - name: "Watermeter Total"
        unit_of_measurement: "m³"
        device_class: water
        state_class: total # or total_increasing
        state: "{{ 174.145 + states('sensor.water_meter_homewizard_total_water_usage') | float(0) }}"
        availability: "{{ has_value('sensor.water_meter_homewizard_total_water_usage')  }}"

So indeed, it was not needed to create a sensor.yaml file, just add the code in the configuartion.yaml.

Again, thanks and have a nice evening !

Regrads
Bert