PVPC Optimizer (only for Spain): Turn on devices based on the PVPC electricity tariff

Hi @afternet ,

I tried what you mentioned in my Home Assistant and the light is working without any problem for me.

The scene will not turn off because it is an entity that can only be turned on. If you want to turn off the scene after one hour, you can create a script that will turn on the scene, wait one hour, and turn if back off. Then, call this script with the blueprint.

Hope if helps!

Hi Marc.

I was very stuck trying to do precisely what your Blueprint does: find the (in my case) cheapest 4 hours. Now I see that you give us the job done: THANK YOU VERY MUCH.
I’ve been poking around the code to see how it does it and I came across this bit (which differs from GitHub):
options:

  • ‘00’
  • ‘01’
  • ‘02’
  • ‘03’
  • ‘04’
  • ‘05’
  • ‘06’
  • ‘07’
  • 08
  • 09
  • ‘10’
  • ‘11’
  • ‘12’
  • ‘13’
  • ‘14’
  • ‘15’
  • ‘16’
  • ‘17’
  • ‘18’
  • ‘19’
  • ‘20’
  • ‘21’
  • ‘22’
  • ‘23’
    I think it may be a mistake.
    On the other hand, I would like to ask you a question. Until now I used Google Calendar to activate the heater at the times that I dictated to it. Would it be possible to call your Blueprint from an automation? (Sorry if the question is stupid).
    Slds.

Forget it! I already manage to do what I wanted.
Regards!

Posible nueva mejora en el “blueprint”

Buenas Marc, uso a diario tu blueprint y va muy fino la verdad. Como supongo sabrás, en estas fechas de tanto calor y sol, se acumulan a menudo días con muchas horas muy baratas. Se me ha ocurrido algo que quizás podría ser una mejora al código, si a ti te parece bien.

En mi caso, cuando el precio de la energía está por debajo de 0,05€, por poner solo un ejemplo, pues ya me parece un precio muy bajo que me permite encender muchas cosas sin importarme el gasto sin tener que esperar a las 3h elegidas más baratas.
Como ahora mismo esto no lo puedo hacer, me toca deshabilitar el blueprint cuando veo precios como los de la foto que te envío.
pvpc

Entonces se me ocurre en si se podría añadir una opción donde cuando el precio sea más bajo de 0,0X€/KWh pues que mantenga los dispositivos de nuestra lista del blueprint encendidos, sin importar el precio. Como ves en la imagen de hoy hay 8h seguidas con un precio por debajo de 0,03€/KWh y el tener que esperar a las 14:00h pues puede no compensar en un caso así a algunas personas que usen este código.

Aprovecho para darte las gracias por este trabajo, el incluir lo de activar en los precios más caros que te lo pedí yo me resultó fabuloso para un proyecto que tenía entre manos.


Possible new improvement in the “blueprint”

Hi Marc, I use your blueprint daily and it works very well, to be honest. As I suppose you know, during these days of so much heat and sun, there are often days with many very cheap hours. I have thought of something that could perhaps be an improvement to the code, if that’s okay with you.

In my case, when the price of energy is below 0.05€, to give just one example, it seems like a very low price that allows me to turn on many things without worrying about the expense without having to wait for the 3 hours chosen for the cheapest.
As I can’t do this right now, I have to disable the blueprint when I see prices like the ones in the photo I’m sending you.

Then it occurs to me that an option could be added where when the price is lower than 0.0X€/KWh, it would keep the devices on our blueprint list on, regardless of the price. As you can see in today’s image, there are 8 consecutive hours with a price below 0.03€/KWh and having to wait until 2:00 p.m. may not be worth it in such a case for some people who use this code.

I take this opportunity to thank you for this work, including the activation at the most expensive prices that I asked you for was fabulous for a project I had in hand.

Hi @afternet !

I’ve been thinking about your suggestion, but I think it is not necessary to complicate the blueprint. I think your idea can be solved with a simple automation that turns on the devices when the PVPC sensor is < 0,05, and turns it back off when it is above. I propose the following automation. Keep in mind I didn’t try it and should be adapted to every case. The delay at the beginning is to ensure that the PVPC Optimizer blueprint already finished before giving another turn on/off action.

I hope it helps!

alias: Control Device Based on PVPC
description: Turns on the device when the energy price is below €0.05/kWh and turns it off when it is above €0.05/kWh, with a 5-second delay
trigger:
  - platform: state
    entity_id: sensor.pvpc
condition: []
action:
  - delay: '00:00:05'
  - choose:
      - conditions:
          - condition: numeric_state
            entity_id: sensor.pvpc
            below: 0.05
        sequence:
          - service: switch.turn_on
            target:
              entity_id: switch.your_device
      - conditions:
          - condition: numeric_state
            entity_id: sensor.pvpc
            above: 0.05
        sequence:
          - service: switch.turn_off
            target:
              entity_id: switch.your_device
mode: single

Gracias Marc
Realmente pienso que sería el complemento ideal para el blueprint.

A menudo que vamos avanzando tenemos mas y mas automatizaciones que se cruzan a veces entre ellas. En el caso de este blueprint, tenerlo todo ahí a mano opino que sería ideal.

Voy a probar igualmente como me dices y a ver si no se lian ambas automatizaciones, y si acabo yo también de ajustarlo bien.

Gracias de nuevo


Thanks Marc
I really think that it would be the ideal complement to the blueprint.

Often as we move forward we have more and more automations that sometimes overlap with each other. In the case of this blueprint, having everything there at hand I think would be ideal.

I’m going to try as you say and see if both automations don’t get mixed up, and if I also end up adjusting it well.

Thanks again

Congratulations on this great blueprint. It works very well for me, however, I have realized that if I run it for two hours it chooses the two cheapest (or most expensive) hours, whether consecutive or not. I think it would be a good improvement to have the option of wanting it to work continuously for the hours you select (two, three, etc.), since there are devices that must work continuously (in my case, a purifier). Thanks again and congratulations

Hi @iesgeber,

Thank you for your comments! I’m glad to hear that you find this blueprint useful :blush:.

This blueprint indeed turns on a device during the cheapest (or most expensive) hours of the day, even if they are not consecutive. However, it sounds like you’re looking for a way to turn on a device at the cheapest hour of the day and keep it running for two or three hours.

Here’s how you can achieve that with this blueprint:

  1. Create a Timer: Set up a timer that will count down to turn off your air purifier.
  2. Create a Script (A): Create a new script that turns on your device (air purifier) when the timer starts and turns it off when the timer finishes.
  3. Set Up the Blueprint: Configure the blueprint to operate for only one hour per day.
  4. Set up a Script (B) to start the Timer: Create a new script with only the action to start the timer.
  5. Call the Script (B) from the Blueprint: Instead of turning on the device directly in the blueprint, call the script B to start the timer.

This method is more flexible as it also allows you to trigger the timer manually. The blueprint will only trigger the event, while the timer and other scripts handle the rest.

I hope this helps! If you have any more questions, feel free to ask.

:loudspeaker: BLUEPRINT UPDATE: :arrow_double_up: EXITING NEW FEATURES :arrow_double_up:

Based on your valuable feedback, I’m thrilled to introduce a major update to this blueprint, packed with powerful new features and enhancements.

Key Improvements:

  1. Enhanced Flexibility: I’ve added a new section to configure custom actions before and after turning on/off the device. This opens up endless possibilities for seamless interactions with other blueprints.
  2. Optional Device Selection: You can now choose to run the device from the build in action, or to call it from the custom actions directly, unlocking a world of possibilities beyond this blueprint. For instance, you can turn on a device and set a timer to turn it off after a specified period, all within the blueprint itself – no external scripts required!
  3. Optional Action Triggers: I’ve introduced a boolean switch to make calling the actions to turn on and off entirely optional.

Backward Compatibility: Rest assured that this update is fully compatible with previous configurations. The only requirement is to have Home Assistant version 2024.6 or later.

Your Feedback Matters: As this is a significant update, I kindly request that you report any issues or incompatibilities you may encounter. Your input will help me refine and improve the blueprint further.

Enjoy!


You can get all the new features by redownloading the blueprint code.