Using Home Assistant to calculate my energy bill using data from my Solar Inverter

Hi @Stake63,

When you only have 1 tariff, you probably don’t need an if statement.
When you have an if statement, i think you might need an else statement, otherwise it doesnt know what to do when your if statement doesnt match.

Try this instead

template:
  - sensor:
      - name: Tariff Price
        unit_of_measurement: AUD/kWh
        state: >
            {{ 0.2844 }}

Now for the energy cost

To be fair, this one looks good already. I have only messed with formatting to help me understand it.

- sensor:
      - name: Energy Cost
        device_class: monetary
        state_class: measurement
        unit_of_measurement: AUD
        state: >
          {{ (states('sensor.daily_energy_Peak') | float * 0.2844 +
              0.8702) | round(2) }}

I often use Developer tools to work out the logic.

Example:

As my retailer currently does not charge peak for Spring months (Sept-Oct), your code will not match mine exactly. Using your code, we can see the $0.87 result on the right of the picture. This deliberately unmatched sensor pretty much simulates what will happen at the start of every day (midnight) when the daily_energy_peak gets reset.

When I change the sensor to match one of my sensors, I can see the 0.87 being added to the current value of that sensor

Here is the value of my sensor
image

Lets break down the code using my sensor value above as an example.

4.457 kWh (energy consumed today) * $0.2844 (your peak rate per kWh) = $1.2675708
$1.2675708 + $0.8702 (daily service charge) = $2.1377708

That is your cost for the whole day including daily service charge. Note: this does not include solar compensation as its not in your code. Otherwise, looks good to me if you if you do not have solar.

My code also includes the solar compensation so I can see 3 elements…
1 - the whole daily grid import usage cost
2 - excess solar grid export compensation
3 - daily service charge
…all in 1 number that represents what I paid for power for the whole day.
That is the whole point of this whole project really :slight_smile:

Sorry, I think I may have misled you slightly.

This is the problem, no matter how hard you try, you cannot incorporate daily cost into energy dashboard as they use a simple kWh multiplier value that makes it impossible to implement the additional daily cost into Energy Dashboard. Even if you divided the daily cost into hours, it still will not work.

This is why I have gone to the trouble of creating the total cost sensor to fill the gap that energy dashboard currently has.

I hope you can understand the confusion.

Thanks for the fast reply and information. Very helpful

Thanks for clarifying the Energy dasboard shortcoming. It would have driven me mad

Can you add this to the Energy dashboard? If so I’m guessing I just need to create a few more sensors the same as import for export but with a -ve value create the total energy sensor and add it

Have I understood this correctly or is Energy Dashboard 100% incapable of doing it no matter what?

Thanks again

Energy dashboard can and does track the import cost and export compensation properly, with a caveat and that is no daily service charge.

Here is my setup

Energy dashboard uses the value below as a multiplier for the most recent hour of statistics it is recording.

In my case, the value that this sensor shows to energy dashboard varies depending on the time of day.
image

Lets break it down.
These 2 numbers below = 4.951 when added together
Energy Dashboard is always 1h12m behind so that’s why it doesnt match exactly.

image

image

4.457 kWh * 0.122275 (off peak tariff) = $0.544979675
0.494 kWh * 0.149796 (shoulder tariff) = $0.073999224
add them together and I get = $0.618978899
Which matches image in energy dashboard.

Incorporating daily service charge into energy dashboard is impossible for me. Only the Home Assistant Devs can fix this gap. In the meantime, I will be relying on my own daily total cost sensor that fills this gap.

Hi @Stake63,

I just went over my original post and found that I mentioned this caveat already.

Perhaps where I was not clear is in my next sentence after that, what I meant to say was that I have a workaround that does not involve Energy Dashboard.

I will update this to prevent any confusion.

I think that’s where I got confused

The daily charge has been mentioned here Daily Charge

Hopefully the devs or a community member can come up with a workable solution

Thanks again.

1 Like

That’s an interesting device. Does it interfere in any way with the way the Envoy reports consumption and production? How does it pick up that there’s a surplus of production, how does it measure the water temperature, and does it still run the heater appropriately when there is no surplus, preferably on off-peak where possible?

I know this is likely showing my ignorance but how/where do I place the syntax below within HA. Is it a template and put in config.yaml?

  • sensor:
    name: Grid Import Power
    state_class: measurement
    icon: mdi:transmission-tower
    unit_of_measurement: W
    device_class: power
    state: >
    {{ [0, states(‘sensor.envoy_SERIALNUMBER_current_power_consumption’) | int - states(‘sensor.envoy_SERIALNUMBER_current_power_production’) | int ] | max }}

I can tell its doing its job when production and consumption are overlapping each other or the numbers are roughly the same. On a sunny day, it will do its thing till a little bit after 11am and then drop off and start exporting excess solar to the grid.

Yesterday was a rainy day so it didnt finish till like 4:30pm

image

image

It has another CT clamp on the same wire that my solar CT clamp is on.
Blue CT Clamp is for Paladin and Black CT Clamp is for Solar.

image

image

The CT Clamp tells Paladin how much power is coming in/going out to the grid.
Paladin reacts very quickly to balance the grid in/out as close to 0 as it can.

I wedged a temp sensor between the foam insulation and the exterior of the stainless water tank. That sensor then has 2 wires that I connected to just 2 of the 8 wires of an ethernet cable that then goes into the paladin box.

image

This was the only weak point for me. It has several minimum temperature settings you can choose from. 60, 50, 40 (default), 30, 10.
If the water temp ever dropped below the minimum temp threshold, it would immediately pull power from the grid to get it back up to the minimum. This was a problem for me which made me feel like I had no control over the device. For example, if a bath was taken at 6pm which is within peak tariff, then it would draw a bunch of electricity from the grid to get it back up to minimum temp at the most expensive time for electricity. This sort of negated to whole point of the device. I regained control over the device by setting the minimum temp as low as it would go and that situation has not been a problem since. If there is a string of consecutive low production days, I just go out to the fusebox and switch it over from paladin (DAY) back to controlled load (NIGHT) and it will heat up over night using my changeover switch I installed.

It is also worth mentioning that the Paladin also has code that prevents legionnaire’s disease by heating up the water using grid power if the temp has not reached 60 degrees Celsius in the last 72 hours. I have never needed it so far. see https://www.paladinsolarcontroller.com.au/wp-content/uploads/2019/03/Paladin-V6-User-Guide.pdf

Changeover switch I used:

For installing, I found this diagram to be the most helpful for retaining the ability to use controlled load over night if I ever needed it. In the diagram below, switch position 1 is day and position 2 is night.

image

1 Like

Thanks for all the info. So it doesn’t interfere at all with what Enlighten records for consumption and production, or how your HA sensors work? When it diverts solar to the heater, that is counted as normal House consumption?

What if you don’t have much surplus production at all during the day? Is there a risk you’ll run out of hot water?

Did you do the installation yourself? The temp reading could be a problem for me, with the water heater being 2 floors away from the switchboard!

Hi, yes, it is a template sensor so put it in the template block.

Prett much all of the sensors I talk about are in the template block of configuration.yaml

The only exception is the - platform: integration sensors.
They have their own block I like to put after the template block. So it would go like this.

template:
  - sensor:
        name: Grid Import Power
        state_class: measurement
        icon: mdi:transmission-tower
        unit_of_measurement: W
        device_class: power
        state: >
            {{ [0, states('sensor.envoy_SERIALNUMBER_current_power_consumption') | int - states('sensor.solar_power_corrected') | int ] | max }}
sensor:
  - platform: integration
    name: Grid Import Energy
    source: sensor.grid_import_power
    method: left
    unit_prefix: k
    unit_time: h

Yep, as seen in this graph from yesterday.
Generation (purple) and Consumption (Blue) didnt separate until 4:30pm yesterday due to rainy day. These lines usually overlap due to how closely paladin tries to consume all excess solar power.

image

Grid Export (orange) is only seen after hot water is done heating up.
Grd Import (Aqua) is only seen once the sun goes down.

image

Yes, I did. I think the max length for a cat5e cable is normally 100 meters, however given there is a 5V temp sensor on the other end of it, I think the 5v signal degrades too much after 50 meters. I was able to run mine from upstairs fusebox, through the roof cavity and then down 2 levels to the hot water bottle on ground floor which was about 30 meters for me.

If you don’t feel like running a temp sensor, there are other cheaper devices that work in a similar way but don’t have a temp sensor. They rely purely on CT clamp data and algorithms instead. see https://www.catchpower.com.au/ ($649 for Catch Power Green Gen2)

Nope, other that having the production and consumption lines overlapping until just after 11am on a sunny day. Also, I see little spikes occasionally for the rest of the day to maintain the 73 degrees Celsius. Those spikes never exceed what is currently being produced. That is the only thing I notice.

Correct.

The only situation where I cannot see any data is if I manually switch from paladin (DAY) to controlled load (NIGHT) using the changeover switch I installed. This is because controlled load is essentially a seperate wire coming from my meter which is metered seperately. If I wanted to measure that, I would have to put a CT clamp on that wire. Given I have only had to use the changeover swtich once since installing paladin, its not worth worrying about. I’ll see it on my bill eventually anyway.

Here is the 1 night that I used the changeover switch as shown on my energy bill.


So, working with this 1 night of data, we can assume that $0.93 * 90 days = $83.7 per quarter in hot water costs if I didn’t have the diverter.
Now that solar compensation has dropped by 20% on October 1 2021 to lets say 6c - 7.6c per kwh exported, it has suddenly made the solar diverter a bit more attractive.

Installed everything yourself, or just the temp sensor?

I wonder how costs would be affected if a device simply always ran the heater overnight regardless, on off peak (not controlled load). The thermostat would stop it when it’s up to temp anyway. Looks like this might be what the catchpower one does.

Now all we need is an HA interface so we can visualise what these devices are doing in realtime!

EDIT: What do you use to produce those overlapping graphs?

Yep, and I am not an electrician. I was ready to pay an electrician to do it if I felt I had bit off more than I could chew. That wasn’t needed. As I am not an electrician, admittedly it did take me a lot longer to do than an expert would take and the power for the whole house was off for most of the day while I figured it out.

Nothing. Paladin is pulling the power from the same wire that the rest of the house uses which is also the same wire that your solar power gets fed into. It just stops itself from pulling more that what the CT clamp says it can use. The only reason it can do this is because hot water heaters are called a resistive load. You can send 1 watt or 3600 watts to the heater and it will still do something. Just takes longer to heat up when less than 3600 Watts is available.

The controlled load hookup is only there for emergency top up when multiple consecutive cloudy days are experienced. It’s main function is to save you money and will always try to heat using solar only as best it can given the conditions.

I have considered getting a ‘dual power automatic transfer switch’ to try and use controlled load at night every night and then use paladin for top up via solar in the day. I’m not sure its worth the time and money at this point. Plus the whole point of the $900 diverter was to use only solar power to heat up my water. If I go back to controlled load as the primary method of heating, then I have wasted my time and money and let the power company win, Also, If I go back to contolled load, I am using coal power to heat my water instead of sun power and I have to pay the power company for that power instead of using my own for free.
Given I have only had to switch over to controlled load for one night since installing in August, I’d say it’s a minor inconvenience to go outside and flick a switch after 3 rainy days in a row, it’s not worth spending any more money on.
When I did choose to go to controlled load, it wasn’t like my hot water went cold, it just went warm instead of boiling. I was still able to shower comfortably. This was possible because you still get solar production even on a rainy/cloudy day, it still heats it up the water. It just takes longer to do its job.
image

There are interesting trade offs with all this. Even on sunny days, there are times when I can use all my production (on aircond, pool heater etc), and there would be hell to pay if there were no hot water at the end of the day! But judging by my bills, my average controlled load usage is about $35pm, so there are some savings to be had (monetarily and planet-wise).

Sorry, I meant what HA component do you use to produce the graphs…

How many consecutive days are there where you export less than 10 kWh?

I have just gone over my old bills.
My daily average hot water energy use was 10 kWh in winter last year and 5 kWh in summer (before I had Paladin).

Ah that makes sense now.
This one (built in)

As for my pool, I have setup an automation to only run the pool pump after the hot water system is done and home assistant finally sees enough power being exported to the grid to power the pool pump (at least 1100W for 10 minutes). If the pool pump has not run that day, I have an automation to run the pool pump at 2am-7am on the off peak tariff to make up for what I couldn’t use from solar the day before.

Mine’s around 10-12kWh too. Over the past several months, there have been up to 4 days with less excess than that, but more often 1 or 2.

Thanks for the info on the graph card. Hadn’t actually looked at that one yet!

Just saw this bit. That is interesting. So once you see 1100W for 10 minutes, you will run the pump for it’s normal 5 hours or whatever? I have a pool heat pump which consumes up to 6000W. So far, I’m into looking at the solar forecast for the next day at 10pm to decide whether to run it (and the filter pump) overnight, or during the next day. I could possible run it during the day if I see that much excess power for a period of time, but that could be counterproductive if I end up running it into the peak much past 2pm and the sun has gone away. So many options!

I run it until I see 200W being imported for 5 minutes then I turn it off.
If this happens before 3:45pm, it will try turn on again after 10 mins of 1100W export is seen. after 3:45pm, it will not try to turn on again that day.

Nice. I guess the only problem is you might not get enough running hours for the day (unless you keep track of that too, and make up for it overnight, which, knowing you, you probably do!).

Any further comments on my previous reply re consecutive days producing less than 11kWh?