#Device entity missing device_class and state_class

1 messages · Page 1 of 1 (latest)

crude sky
#

I have a water flow sensor by FortrezZ (model: FMI) that does have a water consumption entity sensor (calculated in US gal) but it does not have a device_class or state_class attribute, therefore I'm unable to use it under Energy dashboards. What is the best way to add these attributes to this entity, so that it may be used within energy?

solemn ibex
#

How does the sensor behave? Is it continually increasing?

crude sky
#

yes, continously increasing

#

Considering the device calculates water consumption in US gal and I need m3 - I thought to just create a template entity sensor as follows, but even after state change I still don't get a value (status = unavailable):

- name: 'Water Meter Water Consumption [m3]'
  icon: hass:water
  unit_of_measurement: m³
  device_class: water
  state_class: total_increasing
  state: >
    {% set new = (states('sensor.water_meter_water_consumption_us_gallons')|float * 0.0037854118) %}
  availability: "{{ states('sensor.water_meter_water_consumption_us_gallons') | is_number }}"
solemn ibex
#

this doesn't look valid:

state: >{% set new = (states('sensor.water_meter_water_consumption_us_gallons')|float * 0.0037854118) %}

crude sky
#

suggestions? Sorry, my brain is melting after this 🙂

solemn ibex
#

I think

    state: "{{ states('sensor.water_meter_water_consumption_us_gallons')|float * 0.0037854118 }}"
#

your template is setting a variable new but that's not used anywhere

#

I think the template entity is the right approach