StyraHem / ShellyForHASS

Shelly smart home platform for Home Assistant
MIT License
619 stars 111 forks source link

[FR] Energy Dashboard intregration #578

Open Techwolf12 opened 2 years ago

Techwolf12 commented 2 years ago

Is your feature request related to a problem? Please describe.

The Shelly total_consumption is not selectable/usable in the energy dashboard.

Describe the solution you'd like

Setting the total_consumption state_class to total_increasing and the device_class to energy (Power should be real time power, not long term usage). Also add the last_reset for the dashboard to properly handle it, to epoch time 0 since it doesn't need to be updated anyway.

Describe alternatives you've considered

A alternative that could be used is to set this snippet in the configuration.yaml:

homeassistant:
  customize_glob:
      sensor.shelly_*_total_consumption:
        last_reset: '1970-01-01T00:00:00+00:00'
        state_class: total_increasing
        device_class: energy

This sets the attributes to the proper values for the Energy dashboard to handle it. But it would be nicer if it just worked for everyone without this change.

Additional context

Home Assistant dev docs on long term statistics

wonderiuy commented 2 years ago

+1 for this request

Octofinger commented 2 years ago

+1 for this request.

I'd like to add the device_class power and state_class measurement for current consumption entities.

Just a note, I had to wrap the glob in quotes for the snippet to work in configuration.yaml.

homeassistant:
  customize_glob:
    "sensor.shelly_*_total_consumption":
    last_reset: '1970-01-01T00:00:00+00:00'
    state_class: total_increasing
    device_class: energy
martin3000 commented 2 years ago

Here is the corresponding documentation: https://developers.home-assistant.io/docs/core/entity/sensor/#available-device-classes

device_class power is for W and kW, device_class energy is for Wh, kWh, MWh

Zodiac5 commented 2 years ago

+1 for this request.

I'd like to add the device_class power and state_class measurement for current consumption entities.

Just a note, I had to wrap the glob in quotes for the snippet to work in configuration.yaml.

homeassistant:
  customize_glob:
    "sensor.shelly_*_total_consumption":
    last_reset: '1970-01-01T00:00:00+00:00'
    state_class: total_increasing
    device_class: energy

Thanks for the help, for @Octofinger solution to work the indentation needs to be as per the original example though

m-reuter commented 2 years ago

This is , I think, a duplicate to #571 , also note, that last_reset is not needed any longer.