Price entity & Power->Energy

Hi all

First of all, thanks to the developers for the great new energy feature :slight_smile:

I’m struggling with two things.

First of all the price per kWh. I’m having two different rates:

  • Mo-Fr 07:00 - 20:00 & Sa 07:00-13:00 —> 0.1898 CHF
  • All other times —> 0.1348 CHF
    How can I create an entity with this two values according to actual time?

Second thing. I’m having some devices, which provides only actual consumption in W, Energy in kWh is not available.
As the Energy feature only allows kWh entities it seems like I need to build a counter inside HA? If yes, can anyone give me a hint where I can find a guideline? And if no, how can I solve it?

Thank you very much
Marco

For W to kWh conversion use the rhieman integration integration.

1 Like

and hopefully this will answer your tariff question.

1 Like

A fellow swiss guy :slight_smile:

I have the same peak and off-peak schedule as you do. Here’s my automation to set the tariff accordingly → smart-home-setup/energy.yaml at 490a4d541a4e521023df9e2ce756ba8432c52170 · Burningstone91/smart-home-setup · GitHub

I have two input numbers as well for the peak and off-peak price. Just let me know in case something should be unclear.

2 Likes

Ha ha, as it happens, I am Swiss too, but living in Australia for more than 15 years now…

Hopp Schwiiz
Roland

3 Likes

I should use “CHF” more often in my postings :smiley:

Hopp Schwiiz

2 Likes

Thanks to all.

I solved the meter issue with Riemann sum integral.

The utility meter for the price I have not quite understood, or was too complicated for me :slight_smile:

I now solved it the (for me) simple way with:

  - platform: template
    sensors:   
      strom_tarif:
        friendly_name: "Strom Tarif"
        unit_of_measurement: CHF
        value_template:  "
            {% if now().weekday() >= 0 
                and now().weekday() < 5 
                and now().hour >= 7
                and now().hour < 20 %}  0.1898
            {% elif now().weekday() == 5 
                and now().hour >= 7 
                and now().hour < 13 %} 0.1898
            {% else %} 0.1348 
            {% endif %}"
2 Likes

Hello,
I an see how this works for the current unit price, based on kWh.
How are people dealing with daily standing charges?

There’s a feature request for this already, I guess it will be implemented directly into the energy dashboard in an upcoming version.

2 Likes

Here is an example using holidays for Slovenia:

    - name: "Energy Price"
      unique_id: "energy_price"
      state: >
        {% set holidays =
            ['2021-11-01', '2022-02-08', '2022-04-18', '2022-04-27', '2022-05-02', '2022-08-15', '2022-10-31', '2022-11-01',
             '2022-12-26', '2023-01-02', '2023-02-08', '2023-04-10', '2023-04-27', '2023-05-01', '2023-05-02', '2023-08-15',
             '2023-10-31', '2023-11-01', '2023-12-25', '2023-12-26', '2024-01-01', '2024-01-02', '2024-02-08', '2024-04-01',
             '2024-05-01', '2024-05-02', '2024-06-25', '2024-08-15', '2024-10-31', '2024-11-01', '2024-12-25', '2024-12-26',
             '2025-01-01', '2025-01-02', '2025-04-21', '2025-05-01', '2025-05-02', '2025-06-25', '2025-08-15', '2025-10-31',
             '2025-12-25', '2025-12-26', '2026-01-01', '2026-01-02', '2026-04-06', '2026-04-27', '2026-05-01', '2026-06-25',
             '2026-12-25', '2027-01-01', '2027-02-08', '2027-03-29', '2027-04-27', '2027-06-25', '2027-11-01', '2028-02-08',
             '2028-04-17', '2028-04-27', '2028-05-01', '2028-05-02', '2028-08-15', '2028-10-31', '2028-11-01', '2028-12-25',
             '2028-12-26', '2029-01-01', '2029-01-02', '2029-02-08', '2029-04-02', '2029-04-27', '2029-05-01', '2029-05-02',
             '2029-06-25', '2029-08-15', '2029-10-31', '2029-11-01', '2029-12-25', '2029-12-26', '2030-01-01', '2030-01-02',
             '2030-02-08', '2030-04-22', '2030-05-01', '2030-05-02', '2030-06-25', '2030-08-15', '2030-10-31', '2030-11-01',
             '2030-12-25', '2030-12-26']
        %}{% if now().weekday() < 5 and 6 < now().hour < 22 and now().date().isoformat() not in holidays %}0.1286124{% else %}0.0836188{% endif %}
      unit_of_measurement: EUR/kWh
1 Like

I’m struggling with something similar. My challenge is how to have daily and monthly cost when price changes hourly.

Could somebody help me here - Utility meter hourly tarifss

Hi
I have the same issue and also from Switzerland
Do you have an easy short tutorial how to integrated this?
I’m very new to Homeassistant.

1 Like

Thank you for this!

I think i figured this out for anyone with LADWP:

- platform: template
    sensors:   
      electricity_tariff:
        friendly_name: "Electricity tariff (LADWP)"
        unit_of_measurement: USD
        value_template:  "
            {% if now().weekday() >= 0 
                and now().weekday() < 5 
                and now().hour >= 10
                and now().hour < 13 %} 0.22347
            {% elif now().weekday() >= 0 
                and now().weekday() < 5
                and now().hour >= 13 
                and now().hour < 17 %} 0.26807
            {% elif now().weekday() >= 0 
                and now().weekday() < 5
                and now().hour >= 17 
                and now().hour < 20 %} 0.22347
            {% else %} 0.19704 
            {% endif %}"

First IF = Low tier (during the week and between 10 am and 1 pm)
Second IF = High Tier (during the week and between 1pm and 5pm)
Third IF = Low Tier (during the week and between 5pm and 8pm)
Else = Base

1 Like

have the following working

# energy cost
 - platform: template
   sensors:   
      energy_tariff:
        friendly_name: "Energy Tariff"
        unit_of_measurement: GBP/kWh
        value_template:  "
            {% if now().hour >= 5
                and now().hour < 23 %}  0.314
            {% else %} 0.075 
            {% endif %}"

but would like to use 23:30 and 05:30. It seems not to like the half hours.
I’m probable missing something simple.
how to implement this?

I think you can do this:

 - platform: template
   sensors:   
      energy_tariff:
        friendly_name: "Energy Tariff"
        unit_of_measurement: GBP/kWh
        value_template:  "
            {% if (now().hour + now().minute / 60) >= 5.5
                and (now().hour + now().minute / 60) < 23.5 %}  0.314
            {% else %} 0.075 
            {% endif %}"

thanks that did the trick.