API integration

This gives me hope around some of the ideas I want to play with when my car arrives.

Even if I can just ask a home assistant what the state of charge is before I get into the car, it would be helpful, or look at my calendar and see what trip is planned and worn if the charge status isn't good enough.

Next thing I will do is trying to make the MG do adaptive charging to available cheap energy. I guess I need to stop charging, then change, then start again - but it's not done yet. Cycles are long. 17 secs to get a response from the API. When applying power (to my mobile charger - it takes 45 secs until the car starts charging. So all super slow. All while, clouds alter my energy production in 10 seconds by 75%...
 
I have a single rate so its the same price whenever I charge.

I can see the logic of getting a wall box and a variable rate, but then you're boxed into only about four hours charging per night, and running your washing machine and dishwasher at that time too, and the cost of your daytime usage is going to be higher. I haven't done the sums but I'm not sure it's worth it for my mileage.

There's a great convenience to being able to charge your car and run other appliances any time you want to.
I'm assuming you've checked this out, but it's worth doing the sums. I'm on intelligent octopus and while day rate is slightly more expensive in my area (~29p v ~26p ish) the cheap off peak rate (7.5p) more thank makes up for it.

In my monthly bill it calculates your average unit cost once all the charging / off-peak shenanigans have happened and last month that worked out at 16p per kWh. Other than the dishwasher which is the push of a button we don't make any conscious effort to load shift (2 young kids make that hard!!) But do charge overnight. We don't do a mad amount of miles (maybe 200 a week or so?) So aren't heavy users of the charger.

Obviously we stumped up for the wallbox needed for this (£1000 all in) but we don't have any outside / garage sockets so granny charging was a faff anyway (and slow!)
 
I'm using the python gateway with home assistant, evcc and tibber. Works very well for me!

The python gateway uses mqtt auto discovery, so there is no need to configure some sensors or switches.

BTW:
The developers added some filters and fixes to the mqtt gateways to make everything more reliable. But the http gateway is quiet old (april) and won't get any updates in future.
 

Attachments

  • Screenshot 2023-10-27 01.00.08.png
    Screenshot 2023-10-27 01.00.08.png
    96 KB · Views: 171
  • Screenshot 2023-10-27 00.59.42.png
    Screenshot 2023-10-27 00.59.42.png
    183 KB · Views: 165
  • Screenshot 2023-10-27 01.01.51.png
    Screenshot 2023-10-27 01.01.51.png
    120.2 KB · Views: 169
How much does Tibber charge ?They give you the price from the
Evcc calculates the charging time based on soc and charging current. In my config the wallbox current is 20A, but the MG5 has only 16A. So the time is not so accurate.

I'm using the charging station plugin to wake the gateway for charging.
 

Attachments

  • Screenshot_20231027-090108.png
    Screenshot_20231027-090108.png
    153.8 KB · Views: 168
Evcc calculates the charging time based on soc and charging current. In my config the wallbox current is 20A, but the MG5 has only 16A. So the time is not so accurate.

I'm using the charging station plugin to wake the gateway for charging.
Hi,

while waiting for my MG to be delivered, I am already busy preparing a charging point at home.
It looks like that you already have the configuration which i have in mind using the lowest prices for charging. But instead of tibber I am using awattar via EPEX integration in HA.
Your HA cards are looking very nice., would love to implement similar in my HA.
Any chance to PM me your cards- & automation files?
BTW: What charging station are you using?

Thanks in advance
 
Hi,

while waiting for my MG to be delivered, I am already busy preparing a charging point at home.
It looks like that you already have the configuration which i have in mind using the lowest prices for charging. But instead of tibber I am using awattar via EPEX integration in HA.
Your HA cards are looking very nice., would love to implement similar in my HA.
Any chance to PM me your cards- & automation files?
BTW: What charging station are you using?

Thanks in advance

At the moment my charging station is a Vestel EVC04, but I ordered a easee lite yesterday.
The EVC04 can't auto-switch from 3 to 1 phase charging, so I think the easee is a little bit better.

My MG5 can charge 32A with 230V or 16A with 400V. So it's a good idea to invest in a 22kW charging station :)

Give me some days to prepare my code.
 
At the moment my charging station is a Vestel EVC04, but I ordered a easee lite yesterday.
The EVC04 can't auto-switch from 3 to 1 phase charging, so I think the easee is a little bit better.

My MG5 can charge 32A with 230V or 16A with 400V. So it's a good idea to invest in a 22kW charging station :)

Give me some days to prepare my code.
I really appreciate that - tia

Right now OpenWB and Keba P30 x-series area on my shortlist - both with 22kW for sure, although I just have a 16A/400V circuit available (no PV). But I'll have a look on easee now.
One of the topics is a good integration to HA
 
Last edited by a moderator:
Just a cold comment when I read this interesting topic, not for hijacking.

I saw videos of car thefts from our neighbourhood watch group. I guess the thieves hacked into car system. Car lights were turned on several times before they got into the car.

They were not MG cars. One was Korean. One was a luxury brand. It looked like the thieves tapped into car near front wheel in both cases. Could that be CAN bus API security.
 
Perhaps those cars had OBD2 / OBD11 Bluetooth adapters fitted to them, and they hacked the cars that way?
 
Perhaps those cars had OBD2 / OBD11 Bluetooth adapters fitted to them, and they hacked the cars that way?
I do not think the thieves controlled the cars wirelessly. I saw thieves crouched down at front corner of car. Maybe wires are clipped under wheel arch where they could cut open and tap?
 
Evcc calculates the charging time based on soc and charging current. In my config the wallbox current is 20A, but the MG5 has only 16A. So the time is not so accurate.

I'm using the charging station plugin to wake the gateway for charging.
add to this that the current at a smart meter (maybe also the wallbox) is higher than what the car actually takes in.

I am of the opinion that the Wallbox business dies.
Cars will have the API to start / change current / stop as you want and all you need is your max power to the car.

Did someone already try to set the charging current of the MG4 via API ?
It is possible via the display and doing it manually the reaction is instant.
In GitHub - SAIC-iSmart-API/documentation

my assumption is the fields altngChrgCrntReq would make sense as abbreviation
for "altering Charging Current" .
For MG4 sensible values would be: 6,8,16,32 for 6A, 8A, 16A - and the displayed "max" is possible 32A
The app can't do it - which doesn't mean the API won't work ...

Next thing I will do is trying to make the MG do adaptive charging to available cheap energy. I guess I need to stop charging, then change, then start again - but it's not done yet. Cycles are long. 17 secs to get a response from the API. When applying power (to my mobile charger - it takes 45 secs until the car starts charging. So all super slow. All while, clouds alter my energy production in 10 seconds by 75%...
when power is applied permanently to my mobile charger, and the cable is plugged into the car - start / stop charging delays are: 15 secs / 7 secs.
 
I'm assuming you've checked this out, but it's worth doing the sums. I'm on intelligent octopus and while day rate is slightly more expensive in my area (~29p v ~26p ish) the cheap off peak rate (7.5p) more thank makes up for it.

In my monthly bill it calculates your average unit cost once all the charging / off-peak shenanigans have happened and last month that worked out at 16p per kWh. Other than the dishwasher which is the push of a button we don't make any conscious effort to load shift (2 young kids make that hard!!) But do charge overnight. We don't do a mad amount of miles (maybe 200 a week or so?) So aren't heavy users of the charger.

Obviously we stumped up for the wallbox needed for this (£1000 all in) but we don't have any outside / garage sockets so granny charging was a faff anyway (and slow!)
I agree Octopus Intelligent Go seems very cost-effective for an EV owner.

I'm not sure that many people have figured it out yet but although the "official cheap 7.5 pence rate" is normally only available from 23.30 until 05.30, if you have an Ohme Charger (not sure about others) when you plug in your EV in the evening just after 17.00 you get a message on your Ohme App asking you to approve a smart charge session. Apparently, smart charging is how Octopus helps balance the grid by using excess power.

Once I approve, I get a smart charge schedule sent to my phone and my car generally (not always) starts to charge straight away. Octopus then charges me the cheap rate (7.5 pence) for the whole house whilst charging the car.

To be fair, Octopus warns that the smart charge schedule is subject to sudden change but in my experience it rarely does. Like tkmax5 I worked out my monthly average tariff was around 16 pence.

To ensure I can get the best from smart charging, I have written a simple Node-Red script that checks the power going to my Ohme Charger between 17.00 and 23.30 and if it exceeds 100 Watts it assumes that I am smart charging and therefore my home is getting the cheap rate.

The script switches on my Heat Pump and Battery Storage and tells me via Alexa and HA that the cheap rate is available if I want to use other high-power devices before 23.30.

It also automatically switches off the battery storage, Heat Pump, and high power devices if I lose the cheap rate. Seems to work quite well.
 
I agree Octopus Intelligent Go seems very cost-effective for an EV owner.

I'm not sure that many people have figured it out yet but although the "official cheap 7.5 pence rate" is normally only available from 23.30 until 05.30, if you have an Ohme Charger (not sure about others) when you plug in your EV in the evening just after 17.00 you get a message on your Ohme App asking you to approve a smart charge session.
Not true, you get 23:30 to 05:30 no matter what charger you have. You must however have either a compatible or compatible charger to be able to get the tariff, once youve got it doesnt matter what you connect to it etc you always get the 23:30 to 05:30 @ 7.5p for all what you use. Mine gets hammered for 6 hours with cars, batteries, heatpumps etc.

Apparently, smart charging is how Octopus helps balance the grid by using excess power.
Correct, they actually give more time on 7.5p when they have excess energy available.

Once I approve, I get a smart charge schedule sent to my phone and my car generally (not always) starts to charge straight away. Octopus then charges me the cheap rate (7.5 pence) for the whole house whilst charging the car.
Correct, some people try to milk the system which will get stopped, they set 100% charge needed by 23:30 in the hope they will get the additional charging time from Octopus, I believe their disappointment will be rising when Octopus guard against this sort of abuse.

To be fair, Octopus warns that the smart charge schedule is subject to sudden change but in my experience it rarely does. Like tkmax5 I worked out my monthly average tariff was around 16 pence.
My average is usually between 8p and 9.2p per kWh, this month its at 7.9p so far (if you download the Octoplus app it gives all this sort of stats).

To ensure I can get the best from smart charging, I have written a simple Node-Red script that checks the power going to my Ohme Charger between 17.00 and 23.30 and if it exceeds 100 Watts it assumes that I am smart charging and therefore my home is getting the cheap rate.

The script switches on my Heat Pump and Battery Storage and tells me via Alexa and HA that the cheap rate is available if I want to use other high-power devices before 23.30.

It also automatically switches off the battery storage, Heat Pump, and high power devices if I lose the cheap rate. Seems to work quite well.
Same here but all on HA. I've also added appropriate routines for saving sessions, 3 hours before consume power until 1 hour before, then during the saving session run on batteries. Last year I made some quite good money from this regime.
 
Not true, you get 23:30 to 05:30 no matter what charger you have. You must however have either a compatible or compatible charger to be able to get the tariff, once youve got it doesnt matter what you connect to it etc you always get the 23:30 to 05:30 @ 7.5p for all what you use. Mine gets hammered for 6 hours with cars, batteries, heatpumps etc.
Just realised I needed a full stop, and not a comma in my first paragraph to make it entirely clear.

I had not intended to suggest you needed an Ohme charger to get Octopus Intelligent Go but rather to point out that I knew the Ohme charger worked with "Smart Charging" but was unsure if other chargers also worked. On my Octopus App, it specifically mentions the need to have an Ohme charger but others may see a different message.

I have also heard suggestions of people trying to milk the system but personally, I'm not sure I see the sense or benefit in setting your car to fully charge by 11.30 just to force Smart Charging.

In my admittedly short (2 months) experience of using Octopus Smart Charging, I plug my car in when I get home around 17.00 and have the schedule set to have my car fully charged by 09.00 the following morning. I initially expected to see most of the charging taking place in the "wee hours" but instead Octopus generally start to charge my car by 17.30 and continued to charge it until around 03.00. The charge rate varies and as I mentioned above the smart charging occasionally switches off for 15/30 min but generally is mostly on until 23.30 regardless so see no need to "game" the system.

Anyway, if I understand correctly Octopus, who put out a press release to this effect are trying to use Smart charging as a way of using excess energy that would go to waste anyway. They, from what I have seen can and do vary the charge rate during the Smart Charge period so it works to their advantage.

I really applaud the Octopus approach for being innovative and can see benefits for EV drivers. I no longer bother with free charging (I live in a part of Scotland that still has free charging) as the Octopus rates are so good. If the weather gets particularly cold I can also use the MG's V2L capability to run (on a separate island cct) a couple of modern electric radiators to boost my heating.

For anyone who is interested, I measure the current in my charger cable with a current clamp that feeds into my Efergy Engage energy monitoring system. I then read the Efergy API which splits out my various clamps and feeds the current (wattage) from the charger into a Node-Red script to measure and take action on. It's a fairly simple script which I would be happy to share. Reading the current to the charger could be done by various methods including the MG API mentioned in other posts.
 
Has their been any update on this? I miss my Leaf's API too! My Ohme Charger is dumb without it!
I did it. I am into fine-tuning.
First, there is no one filed that you can reliably read to get SOC. But after weeks of studies in various scenarios I think I rigot the right combination to always display the right SOC.

Second, I wanted to get adaptive charging going: based on cheap electricity, including solar.My team has achieved to make that happen. So now you can just buy a dumb plug good for 32A,
and then the charging control does the rest. Go up in steps like: 0, 6A, 8A, 16A, max and down the other way. These are the steps for the MG4.

Third, the benefit is you can use the site for free and have as many "apps" as you want for your car.
Not just one.

In my opinion people only look at the SOC in % and the corresponding km/miles. Let me know if I am wrong.

Any other info is relevant in the car only: Alerts, low pressure on tires, etc is relevant - but if you want to take care of it / repair it you have to go into the car anyway... so seeing it in the app is not relevant, imho.
 

Are you enjoying your MG4?

  • Yes

    Votes: 538 79.1%
  • I'm in the middle

    Votes: 91 13.4%
  • No

    Votes: 51 7.5%
Support us by becoming a Premium Member

Latest MG EVs video

MG3 Hybrid+ & Cyberster Configurator News + hot topics from the MG EVs forums
Subscribe to our YouTube channel
Back
Top Bottom