Feature requeust, API 'Charge Cost' to reflect time of use

I use home assistant to capture charge cost and divide by energy used to work out a cost per kWh. This is mostly because of the limtations around the solar charging where the E2 spends more time switching on and off with each passing cloud than charging, so I allow a significant amount of grid import to stop the charge from ending too quickly. By calculating the actual cost to charge I can check what my configuration is costing me in realtime. Well five min intervals anyway.

The problem is that while the app and CP-link page show an accurate amount, that matches the off peak time of use grid charge as an example, the charge cost received via API into home assistant tends towards using the peak rate for the same session. I say tends towards, as it starts out correct with a value similar to the off-peak rate but very quicly increases to exactly the peak rate, even though the whole session could be off-peak such as during an overnight charge. It would appear the charge cost delivered via API does not accurately match the configured energy cost for that time period.

I could do a calculation in HA but that would mean trying to work out what amount of energy is coming from the solar and how much from the grid before applying my own known energy cost. It would be nice and easier for me if the charge cost delivered by API could accurately represent the time of use cost.

Hi Simon.

The app and Home Assistant use the same API and data source so if it’s right in the app then I suspect something is going wrong at the Home Assistant end. Evnex doesn’t maintain that so you would be best off getting in touch with the people who have been contributing to that.

Kind regards,

Tom

Thanks Tom,
I will go back to them but as far as I can see in the code the value received is not manipulated at all. Which had me thinking the App was doing something more comprehensive using the rest of the data. I will also add some debugging to check the exact values I am receiving via the API to ensure HA is not doing something behind the scene.

1 Like

Hi Tom,
I have just called the API directly to get the charge point session data and luckily for me it does show the issue.
Hopefully the following makes sense. The wrong starting rate seems to be included in the data returned and the cost contained in the response used by HA does not match what is displayed in the App.

I’m pretty sure that’s a legacy cost calculation which is used by an old version of the app (which also captures tariff information differently). So the current version of the app no longer looks at it.

It’s there for people who are stuck on an older version of the app due to an unsupported OS.

Thanks Tom,
By that do you mean that there is not a correct cost value that is being delivered via the API? If so that is why I created this as a Feature request.

Or am I simply looking at an older version of the API and I need to connect to a newer version API, where the newer API includes all the configured tarrif’s, to a greater precision and a correct cost?

As you say there is enough information in the API response I posted, primarily distributionByTariff which gives the grid/solar split, to work it out yourself. Provided of course you have all your ToU tarrifs configured in whatever application you are using, as there is only the one Flat tarrif provided by API.

It seems like a good project for me to pull that info out using HA as distributionByTariff seems to be about the only thing it does not extract, and see if I can get it to work.

Thanks for your time.

Tom, thanks for putting up with the questions. I have it all sorted now. My Session Cost now tracks the Evnex App and I have a near realtime view of actual cost per kwh. I also have a representation of how much grid I am using when the clouds pass by.
I realise this was all in the App, but now I can start doing something useful with it until you look at adding the timer for stopping charging in low solar conditions rather than just an import limit.