#Now I m trying to create a template

1 messages · Page 1 of 1 (latest)

open musk
#

here's what I have, as a working template sensor:

`sensor:

  • name: "UPS Power Usage"
    unit_of_measurement: "kWh"
    icon: mdi:server
    state: >
    {{ (states('sensor.ups_load_2') | float / 100) * 900 / 1000 | round(2) }}
    state_class: total_increasing
    device_class: energy`
#

when I look at it in entities, I see a sensor that looks like any other energy meter. But this one isn't available to add to the energy dashboard

solid hound
#

You cant have total increasing and energy with unit W

open musk
#

im currently using: unit_of_measurement: "kWh"

#

my sensor looks like all my other energy meter entitites... but it isn't avaiable in the energy dashboard as an individual item

solid hound
#

If you don't add state class it won't show up no

open musk
#

I have state_class

#

`sensor:

  • name: "UPS Power Usage"
    unit_of_measurement: kWh
    icon: mdi:server
    state: >
    {{ (states('sensor.ups_load_2') | float / 100) * 900 / 1000 | round(2) }}
    state_class: total_increasing
    device_class: energy`
solid hound
#

Have you checked the Dev tools -> statistics for errors?

open musk
#

just did, right now it says no issue

#

in statistics, it shows the unit as W but in the entity it is kWh

swift bobcat
#

You understand the difference?

open musk
#

yeah, just making sure that descrpeancy isn't indivitive of an issue

solid hound
#

That's the issue then

tulip tapir
#

Believe you are using legacy-style templates. You need to use the new style templates to add state_class

solid hound
#

I think what happened is you saved the template once using unit W and then later changed it to kWh. Now the statistics unit is wrong, like you see

#

It should automatically create an issue for that and then you just click solve...

open musk
#

@solid hound that's it! .... after another reload I found the fix issue

#

many thanks! wow that was a hard one

#

now the only issue is this error:

Last reset missing
The following entities have state class 'measurement' but 'last_reset' is missing:
sensor.ups_power_usage

open musk
#

it's a template sensor and apparently last_reset isn't avaiable to templates

solid hound
#

Just wait