Home Assistant page showing all charges including the charged kWh and the price. Still ugly behind the UI though ^^ #943
dreimer1986
started this conversation in
Show and tell
Replies: 1 comment 2 replies
-
Fixed one problem: We had no Internet for a day and I realized that this causes nothing good with my Python script asking on the external address. Thus I edited it to the local one and it works of course. Changed accordingly here. I found out that the from time to time happening state "unavailable" is a lil flaw, too. I might have a solution for that, but first I need to recharge the car once more before I add it here ^^ |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
So, first some backstory. My EVBox Elvi has no electricity meter included (yet) and thus most values I can get regarding electricity are 0 by now. This will change soon as the first box of two in our family was already converted to the more expensive model WITH meter inside. It works like a charm in a quick test in this addon and as soon as I have mine modified, too I will post the result in my (closed) report I sometimes fill with new stuff. #221
I only will get this changed if I change to some charge controlling service was the first thing I was told. Why? It's not really MY wallbox tbh ^^ Anyways I was told that some externally available CSV downloads would be fine already. So this was the first thing I did.
Now for my showoff with some ugliness and hopefully some suggestions from you all.
automations.yaml:
configuration.yaml:
This creates two CSV files. Both available from external by https://externaldomain.tld/local/ocppexport1.txt or ocppexport2.txt. One if I use my ID key and one if any other is used. That is still WIP as I don't know the ID of the 2nd key yet. Planned are two separate CSV for me and later my brother, too. Ignore the "- service: shell_command.loadocppcsv" for now. This will come later.
This results in nice CSV files that I hand edited for validity. Line 1 had a line like "Made from Home Assistant at..." and that I replaced with "date;time;sessiontime;token;charged" to make this thing really a csv file.
In theory this was all that was asked for, but I was on fire and wanted to see how far I can get that. Thus I looked for a nice custom addin for list support in HA and found this one: https://github.com/iantrich/list-card
But I had a csv and this thing wanted a sensor... the HA community forums were the savior in this case: https://community.home-assistant.io/t/reading-multiple-rows-from-csv/326335
I heavily extended the script to make things for two separate data streams, ONLY for the charge sessions of the current month instead of 30 days and some calculation work, too:
ocpp_ui.py:
This script is a MESS I know, but it works as it seems. This is where "- service: shell_command.loadocppcsv" comes in. It runs in four cases, the four already shown above. Otherwise the temporary sensors I made with the API would be gone or be outdated.
configuration.yaml:
Now I made a new space on Lovelace and threw two of these in there:
One for "sensor.ocpp1_energy" and one for "sensor.ocpp2_energy". While we are at it I added a Glances tile with sensor.ocpp1_energy
and sensor.ocpp2_energy shwoing the kWh charged in this month. Now for the cost... I first hoped that I can get them off the energy settings already inside HA, but nope, so I made things quick and dirty... (0.25 €/kWh btw). These need a input_number.energy_cost helper, too. EUR/kWh is the Unit for it and the price you have to pay goes in there. This one can be used for the Energy Dash, too and this way the cost are always on one spot.
configuration.yaml:
End result:
And yes, the kWh values are hand edited to make a nice show off. Right now I still get 0.0 there as already explained above. But as it seems, it really works as expected in my first test.
Now my questions.
I hope that my automations filling the CSVs are really all cases where a charge session ends. I hope so, but I am open for a more secure way to detect the end of a charge session. So if anyone has another good idea... tell me. What I hate the most is that the session ends not with charge end, but removal of the cable...
My Python script is a bit messy. Any optimization suggestions there are very welcome, too.
Anything else? Tell me. I want this thing to work fine and safe and thus am happy about any suggestions.
Beta Was this translation helpful? Give feedback.
All reactions