DIY smart grid: EV (Tesla) charging on excess solar power production

I’ve used something similar in an automation for my pool heater. I created a buffer overrun value that stops the automation shutting it down until the buffer is exhausted. As a high draw item (3kW) it doesn’t make sense to keep shutting it off when importing just 0.5kW.

The problem I see here with the car automation, is the charge rate is flexible. So what rate would you want it to charge when your solar is at max compared to when it’s not?

3kW solar - Charge at 3kW
1kW solar - Charge at 3kW?
0kW solar - Turn off?

Or are you thinking more like charging at whatever the solar generation is + (x)kW?

If the first, it would be much simpler to create a new automation that just turns your charger on and off when you have solar generation as no adjustment of charge rate is needed.

Let me try to clarify. my solar installation provides 4kw max (to be upgraded later). My car charger charges minimum 4kw @ 5A ( 3phase 400V+N).
Therefore If I stop charging when all solar is used up I won’t be able charge at all since my house also uses some power. On the other hand, charging with some solar during peak time is still more beneficial then charging without solar during off-peak. However, we (in belgium/flanders) have a capacity tarif, meaning you are charged more when you grab lots of electricity from the grid over a prolonged amount of time. Hence, I don’t want to charge my car when my house needs over xkw.
So my logic is essentially.
If solar can’t meet minimum charge rate, then keep charging unless grid draw is over 4kw (for x min).

Are you sure? It’s the car that can adjust the charge rate (The charger is actually in the car, the thing attached to your house is just a glorified outlet).

Although the app will only let you select down to 5A, the API allows you to go all the way down to 1A.

Do keep in mind: not all external chargers / charge connectors allow for a setting <5A. I believe it was a new worldwide standardization requirement somewhere from 2020/2021 and up (it is discussed somewhere in this thread). For those charge connectors I’m not sure wether setting <5A through the API returns an error or just returns a setting of 5 amps.

I might be mistaken, but “4kw @ 5A ( 3phase 400V+N)” doesn’t seem quite correct. Although power differential between 2 phases is 400V, the car charger draws 230V per each phase. So that would equate to a 23035=3,45kW minimal power draw.

If I understand your case correctly, you both have a small solar array (which possibly might not even reach the minimum charging treshold of 3450 Watts(?)) and you want to avoid a 4kW power draw for a prolonged period. The simple way to go about this is to offset the grid draw calculations 0-point from 0 watts to -4kw. All should then function exactly the same.

Heads up.

This whole fun will end without a paid for service.

The Tesla Fleet API is now rate limited.

Where is this news from?

I can validate it is definitely rate limited - I get a 429 error and header provides a retry timer (24 hrs later).

Such a shame as I only just finished the automation for charging based on solar tracking today! I’m now forced to lengthen my polling interval.

I’m unsure what the rate limits are because this article doesn’t match up with what I’ve counted in terms of the charging commands I sent. I estimate that I got capped at around 25-30 charging API requests. Unless charging amps count as “command limits”?

Have you tried using the old API. I haven’t seen any rate limits (yet) but my car still works with the old API. In fact I couldn’t actually get it working with the Fleet API…

Thinking about it now, maybe it didn’t work as it was rate limited. That’d make sense.

MCU1 cars all of a sudden better than MCU2 :rofl: (yeh ok, not really).

No, I’m on the new Model 3 Highland and it only takes Fleet API apparently.

Same here.

Was wondering why the automation controlled the amps down but then couldn’t control anything at all…

Very frustrating.

Will give up on it and get an OCPP charger instead. Only $800AUD…

This may be the answer…

teslamotors/fleet-telemetry (github.com)

I am not too familiar with it: does the OCPP protocol support imposing the amp setting from the external charger to the car?

Good morning everyone, I just picked up a 2024 Model Y and I want to control the charging amperage via Home Assistant. Due to the language barrier (I am Italian), I am not sure if this is still possible, if I need to install and configure tesla_http_proxy, or if it is currently not possible at all. In the next few days, they will install the Gen 3 Wall Connector for me, is it possible to do it from that?

I got my 2024 Model Y two weeks ago, there was no need to setup a proxy. I just installed GitHub - alandtse/tesla: Tesla custom integration for Home Assistant. This requires a refresh token be generated by third-party apps to login. , got a token with the Chrome app (if I remember correctly) and it worked out of the box

Since several days (perhaps since switching to Fleet API) I can’t really change charging speed in tesla mobile app. Do you guys have the same experience? The error message it shows is (translated from Polish) “Wrong command: Set charging power”. It’s really annoying now and I can’t find any information about the issue.

Hi everyone,

I’m using the [dazboj]'s Tesla-Smart-Charging blueprint, wich is working flawlessly. As you can see, it manages to harvest almost every watt from solar production to charge Tesla:

image.

Even when there are clouds I have a nice tracking of the power curve:

This week I installed a 5kW Luna2000 battery on my SUN2000 inverter configured for “maximum self sufficiency”.
Now the problems are comming having a solar battery which is managed by the inverter itself (charging/discharging). It seems the automation is not working since it doesn’t know if the charging amperes are comming only from the solar pannels or from the solar panels + solar battery, The inverter thinks that power demand of the house is bigger than the real one (Tesla is charging) and provide power from battery depleting it very fast (2500w max.)

Case 1: - Solar production 3 kW
- House consumption 1kW, remaining surplus for Tesla charging 2kW
- Suddenly I turn on another new consumer having 2 kW
- The inverter compensate the new consumer power, taking the necessary power from battery (2kW)
- The Tesla Charging automation does not react (to stop charging), thinking that there is still sufficient power to continue charging with 2kW, because the inverter reacted rapidly and activated the battery.
- The new consumer is turned off, Tesla Smart Charging Thinks : “Oh, suddenly I have 2 more kW as surplus, let’s use them and charge with 4 kW now”.
- The result is that LUNA2000 is depleting quickly, the purpose of it is to provide energy to the house during the night time for small consummers.

Case 2: - Luna2000 SoC is 50%
- Solar production 4.5 KW
- House consumption 1 kW
- 2.5kW remaining for LUNA 2000 charging, which is maximum charging rate
- Tesla remaining charging power : 1kW
- Suddenly a new consummer comes in with 2kW consumption, inverter compensate this power demand by decreasing LUNA2000 charging rate at 500W (here the automation should live place for LUNA 2000 charging and stop Tesla’s charging).
- The new consumer turns off resulting 2 kW as surplus power, Tesla Smart Charging thinks the same “Oh, suddenly I have 2 more kW as surplus, let’s use them and charge with 3 kW now”.
- The result is that those spare 2 kW now are used to charge Tesla and not LUNA2000.

These facts are speciffic facts for a better understanding, in real life all those values are fluctuating almost in real time (I have 1 second refresh rate on all the sensors and entityes which are comming from the inverter) and I am sure that there are other cases as well.

The result is that the whole “closed loop control” of the Tesla Smart Charging (if I can call it like this) becomes very unbalanced :

image

Does anyone has experienced such behavior having batteries connected to the inverter?

Any help will be highly appreciated. Thank you.

1 Like

As you’ve established, the automation won’t work because it’s fighting against the automation of the battery. The only way I can see you getting it to work, is if you can pull live information from the battery/inverter API?

If you have access to a live figure of what’s going in or out of the battery at any point, you can add it to the calculation done in the Tesla automation.

Hi,
Thank you for answering. Everything is localy integrated with wlcrs Huawei solar integration, I used the screen shots from Fusion Solar app because I did not implemented any Apex charts cards yet on my energy dashboard.

Available entities:

Smart meter:

battery :

inverter as well:

Unfortunately my skills are not so strong in terms of codding, I will give it a try, and let you konw guys about the results. Thank you .

Is the battery Charge/Discharge power the actual AC power?

What I’d do is adjust the variables section of the automation:

Add a variable to use the current battery power:

current_battery_power: "{{ states('sensor.battery_power') | float(0) }}"

Then adjust the calculation for spare_amps to something like this:

spare_amps: "{{ ((spare_energy + current_battery_power) / grid_voltage) | round(0, 'floor') | int }}"

You can use the Traces section of the automation UI to view what these are getting set to as I’m unsure if you’ll need to plus or minus the battery power. But something for you to play around with.

Thats ok, I am a bit of a newbie hence the UI as a starting point.

I have been playing around with automation yamal editing which has been good so far except i can’t perfect the charge rate adjustment (a bit erratic) while using the tessie integration.

My downfall is the limited experience in yamal and no one to help proofread.

I would like to use your code as it would take some pressure off myself but not sure how to adapt, I have these following entities available.

input_number.deadband

input_number.dynamic_deadband_threshold

input_number.min_charge_rate

number.thunder_charge_current

input_number.input_number_adaptive_adjustment_counter

input_number.adaptive_adjustment_counter

input_number.adaptive_deadband_threshold

input_number.input_number_adaptive_deadband_threshold

sensor.sn_3009010635_metering_power_absorbed (From Grid)

sensor.sn_3009010635_pv_power (Generated production)

sensor.sn_3009010635_metering_power_supplied (Feed in)

sensor.grid_solar_consumed_total (Grid and Solar Consumption)

sensor.net_grid_import_export (Combines from grid and grid feed in, negative value feed in, positive value from grid).