Energy cost and price hourly

I think that can be useful show the cost and price per hour in the energy dashboard.

I have a custom panel for it

image

Orange: Consumption
Red: Price
Blue: Cost

Could you share your card code?

Yes, no problem:

type: custom:apexcharts-card
yaxis:
  - id: value
    min: ~0
    apex_config:
      tickAmount: 4
      decimalsInFloat: 3
  - id: price
    opposite: true
    min: ~0
    apex_config:
      tickAmount: 4
      decimalsInFloat: 3
header:
  show: true
  title: Consumo por horas
  show_states: true
  colorize_states: true
graph_span: 24h
span:
  end: hour
series:
  - entity: sensor.energy_per_hour
    yaxis_id: value
    name: Energía
    type: column
    unit: kw
    float_precision: 2
    group_by:
      duration: 1h
      func: max
      fill: zero
  - entity: sensor.cost_energy_per_hour
    name: Coste
    yaxis_id: price
    stroke_width: 2
    float_precision: 3
    unit: €
    group_by:
      func: last
      duration: 1h
      fill: last
  - entity: sensor.energy_price
    name: €/kw
    yaxis_id: price
    stroke_width: 2
    float_precision: 3
    group_by:
      func: max
      duration: 1h
      fill: last

You need the energy and cost per hour. I use utility meter integration to get them

2 Likes

Thanks; how do you create your sensor.energy_price ?

Is a custom sensor that return a price or other depending of the hour. There are a lots examples in the forum.

1 Like

Any advance or news ideas?

  • It is easy to edit and adapt to your rate.
  • First check if it is a holiday with the option of the workday platform, you just have to configure your country and area.
  • then check if it’s a weekend
  • Then check the hours on weekdays.
  • You can see a nice graph with the current rate,
  • and you can use it so that you know the real price
  • It currently has the “night rate” of Naturgy Spain with 3 rates (p1, p2 and p3)

configuration.yaml

binary_sensor:
  - platform: workday
    name : 'Dia Laborable'
    country: ES
    province: CT 
    workdays: [mon, tue, wed, thu, fri]
    excludes: [sat, sun, holiday]
    remove_holidays:
      - '2022-12-08'
      - '2020-12-25'
    add_holidays:
      - "2020-02-24"
      - "2020-04-25"

template:
  - sensor:
    - name: "Precio Energia"
      unique_id: "precio_energia"
      state: >
        {% if is_state('binary_sensor.dia_laborable', 'off') %}
          0.1278
        {% elif now().weekday() > 5 %}
          0.1278
        {% elif 10 <= now().hour < 14  %} 
          0.2205  
        {% elif  18 <= now().hour < 22  %} 
          0.2205
        {% elif  0 <= now().hour < 8  %} 
          0.1278
        {% else %}
          0.1677
        {% endif %}
      unit_of_measurement: EUR/kWh

Card Configuration Indicator

type: gauge
entity: sensor.precio_energia
name: € / kwh
min: 0.1078
max: 0.235
needle: true
severity:
  green: 1
  yellow: 0.147
  red: 0.1941
1 Like