Calculate energy price based on time of day and daylight savings time

Hi,

I’m trying to make same calculations for my electricity consumption. My provider prices the electricity in two different timetables, Winter and Summer. Inside each one the price is different depending on time of day and day of week. For example:

  • Winter
    • from Monday to Friday
      • from 00h00 to 07h00 (low price)
      • from 07h00 to 24h00 (normal price)
    • Saturday
      • from 00h00 to 09h30 (low price)
      • from 09h30 to 13h00 (normal price)
      • from 13h00 to 18h30 (low price)
      • from 18h30 to 22h00 (normal price)
      • from 22h00 to 24h00 (low price)
    • Sunday
      • from 00h00 to 24h00 (low price)

The Summer timetable is different only on Saturday. From Monday to Friday, and Sunday the price is the same.

Whats the best way to do the math?? Create template sensors in HA or mess with Arduino code??

Should I create two template sensors for low and normal price?? Or publish into two different topics for low and normal price??

The current setup is Rpi 3 with HA 0.52.1. The energy sensor is running on a NodeMCU with Arduino code.

Can someone help please? My brain is starting to fry… Lol…

Thank you!

This is a cool idea. Just setup my DTE bridge and this would be a nice addition. I’ll look into it when I get a chance. Update here if you think of something!

1 Like

Hi @j.assuncao ,

My advice, which may be wrong, is to take the AppDaemon approach. AppDaemon gives you the flexibility that HA lacks in terms of performing more complex automations or coding maths (although maybe it is possible to do the maths with template sensors as you say inside HA). What I would definitely try to avoid is to put all this inside the Arduino code; I don’t see how the NodeMCU is going to be aware of the hour and date, and if your electricity provider changes the rules you’ll have to update and upload the new code to the device, which is not comfortable at all.

The drawback of my advice is that you’ll have to install AppDaemon and learn a little bit about how it works but… who does not want to learn new things from time to time? :grinning:

Hi @timseebeck,

I think you are right about avoid messing with the Arduino code. The date and time awareness could be solved with NTP but i don’t think there is enough processing power for all the math.

I use template sensors to get Current (A) and Apparent Power (kVA) from the data send by NodeMCU. It’s simple math…

I’ve been “fighting” with AppDaemon for the last few weeks, can’t make it work. I use a Rpi3 with Hass.io 0.63, Home Assistant 0.53.1 and AppDaemon 0.0.13 (from Vlad’s repository in https://github.com/vkorn/hassio-addons). Keep getting "WARNING Unable to connect to Home Assistant, retrying in 5 seconds" in AppDaemon log. Can someone give a hand making this work?

Thank you.