Quantcast
Channel: Configuration - Home Assistant Community
Viewing all articles
Browse latest Browse all 105913

I need to create a graph that measures monthly energy consumption by collecting data from previous months

$
0
0

Hi, I need to create a chart with a consumption history for the last 12 months. I currently use one that doesn’t show the reference month indication and crashes the view with Safari or from app installed on any Apple device.

The graph in use is as follows:

The YAML code is:

type: custom:mini-graph-card
name: Consumo e Costo Mensile
hours_to_show: 8760
points_per_hour: 0.0014
aggregate_func: max
group_by: month
show:
  graph: bar
  extrema: true
  labels: true
  name: true
  icon: true
  state: false
entities:
  - entity: sensor.consumo_energia_mensile
    name: kWh
    color: "#42A5F5"
  - entity: sensor.costo_mensile
    name: €
    color: "#F44336"
show_empty: false

This is the part of my configuration.yaml related to the function:

sensor:
  - platform: raccolta_rifiuti
    calendar_entity_id: calendar.raccolta_rifiuti
  - platform: integration
    source: sensor.0x000474000123fc71_power
    name: Consumo Energetico Totale
    unit_prefix: k
    round: 2
    method: left
    unit_time: h

template:
  - sensor:
      - name: "Consumo Giornaliero"
        unit_of_measurement: "kWh"
        device_class: energy
        state_class: total
        state: >
          {{ states('sensor.consumo_energia_giornaliero') | float(0) | round(3) }}

      - name: "Costo Giornaliero"
        unit_of_measurement: "€"
        icon: mdi:currency-eur
        state: >
          {{ (states('sensor.consumo_energia_giornaliero') | float(0) * 0.32075472) | round(2) }}

      - name: "Consumo Mensile"
        unit_of_measurement: "kWh"
        device_class: energy
        state_class: total
        state: >
          {{ states('sensor.consumo_energia_mensile') | float(0) | round(3) }}

      - name: "Costo Mensile"
        unit_of_measurement: "€"
        icon: mdi:currency-eur
        state: >
          {{ (states('sensor.consumo_energia_mensile') | float(0) * 0.32075472) | round(2) }}

      - name: "Intervallo Consumo Mensile"
        icon: mdi:calendar-range
        state: >
          {% set today = now().date() %}
          {% set first_day = today.replace(day=1).strftime('%-d %B %Y') %}
          {% set last_day = today.strftime('%-d %B %Y') %}
          Dal {{ first_day }} al {{ last_day }}

utility_meter:
  consumo_energia_giornaliero:
    source: sensor.consumo_energetico_totale
    cycle: daily

  consumo_energia_mensile:
    source: sensor.consumo_energetico_totale
    cycle: monthly

Thank you very much!

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 105913

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>