Hello, I just installed a IotaWatt. I defined MainsComsomption and MainsExport as requested. On HA I set to track MainsConsumption.wh. Now my main problem is how to calculate the cost.

HydroQuebec charges 6,159 ¢/kWh for the first 40kWh per day. Afterwards it charges 9,502 ¢/kWh if exceeding 40.

In reality Hydro says it has two tiers, but its not for your daily basis consumption as you as asking for.

So as I understand we need to find a way to calculate it over the periode (62 days in the exemple) so anything that is over the 2480Kwh will be billed as a second tier until the next period.

I hope this info still useful

they say in their website:

Myth

Rate D does indeed have two-tiered pricing:

6.319¢/kWh for energy consumed up to 40 kWh per day times the number of days in the consumption period (1st tier)

9.749¢/kWh for the remaining energy consumed (2nd tier)

We do not bill based on your daily consumption. We take into account your total consumption during the consumption period, which is more beneficial for you.

For example, if your consumption period covers 62 days, 2,480 kWh (40 kWh per day × 62 days = 2,480 kWh) will be billed at the first-tier price. Any remaining energy consumption will be billed using the second-tier price.

Not a real solution. If you check my code I posted a few comments ago, I found a solution that works as long as you consume more than 40kw per day, but as jeison-souza clarified hydro calculates per month, so my formula doesn’t apply,

In the end I’m just not calculating the cost in $, I simply let it go.