Tesla component: set charge limit

Hi folks

The Tesla component is great but it’d be awesome if the charge limit could be set. I’d use this in an automation, e.g. when home, set charge limit to 50%; when at work, set it to 90%.

We sort of have this with the max limit switch (which sets 100%) but it’d be awesome to pass through an actual value. I can’t imagine it is too far away from what we have already.

cheers!
W

@zabuldon Is it possible to set the charge limit to a certain number instead of max range? This would be helpfull if you want to make an automation warm up the batteries an hour before you leave. You would charge to 80% and then an hour before you need to leave set the charge limit to 90%. This way the batteries will be warm, which is better for the range in cold weather.
Being able to put in a percentage would make it much more flexible!

@swoody sorry for the late response.
@Try2Fly Thanks for tagging me.

Regarding the request. I don’t think any problems to implement something like this, but I want to focus on bug-fixes now, as I can see Tesla partially broken for now. So, going to fix current issues first and then check if I can do something like you described.

I totally understand! I also thought of another way to do this with the current option of max charge switch. But it requires more automation.

Turn on max charge and turn off charging when wanted limit is reached for example 80%. Then turn max charge on when you want to charge to 90% and turn charging off when this is reached.

Still have to implement this to see if it works. But I see no reason why it should not work. However it is a bit more cumbersome than just setting a charge limit.

I’ve been playing around with this, and with a little help from a Node-Red palette, have it almost working. Being able to set charge level to a specific value is hugely helpful. I really only charge in 5 places, and being able to leverage the fact that HA knows when I’m there means I don’t have to manually move the charge level to a specific point.

I’ve been able to set the charge limit via the Node Red Tesla plugin: https://flows.nodered.org/node/node-red-contrib-tesla

This allows me to charge to some base level (say, 60%) on offpeak power, and, if the car is home during the day, top it off to 80% from available solar (via TWCManager).

@deece - Mind sharing that flow? I’d be interested to see how you’re calling that.

Here you go.

Redacted info is replaced with ‘12345’

Some info that isn’t captured in the flow:
I have TWCManager tracking solar availability during the day, so if the sun is up, the car only gets enough power to bring my grid interaction to 0W. TWCManager is configured so that during off-peak times at night, it allows the car to charge at maximum power (16kW).

Between this and the flow, the car will charge to 60% at night, giving me another 20kWh of storage that I can dump energy into if the car is at home.

[
    {
        "id": "20240160.b1b68e",
        "type": "tab",
        "label": "Tesla Charging",
        "disabled": false,
        "info": ""
    },
    {
        "id": "8912aea0.f42bb8",
        "type": "tesla-api",
        "z": "20240160.b1b68e",
        "teslaConfig": "df12fc74.fb2de8",
        "command": "setChargeLimit",
        "name": "Set Charge Limit",
        "x": 680,
        "y": 606,
        "wires": [
            []
        ]
    },
    {
        "id": "bedb0918.a0cd2",
        "type": "function",
        "z": "20240160.b1b68e",
        "name": "Set Amount",
        "func": "isHome = msg.location.inarea;\nisGridCharging = msg.timer == \"on\";\n\nchargeLevel = 80;\n\nif (isHome && isGridCharging) {\n    chargeLevel = 60;\n}\n\nmsg.payload = {};\nmsg.commandArgs = {};\nmsg.commandArgs.amt = chargeLevel;\n\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "x": 417,
        "y": 609,
        "wires": [
            [
                "8912aea0.f42bb8"
            ]
        ]
    },
    {
        "id": "303b7f9d.6f40a",
        "type": "bigtimer",
        "z": "20240160.b1b68e",
        "outtopic": "schedule",
        "outpayload1": "",
        "outpayload2": "",
        "name": "Charge limit Schedule",
        "comment": "Restrict grid charing to 60%",
        "lat": "-35.31301",
        "lon": "149.13031",
        "starttime": "1380",
        "endtime": "1140",
        "starttime2": 0,
        "endtime2": 0,
        "startoff": 0,
        "endoff": 0,
        "startoff2": 0,
        "endoff2": 0,
        "offs": 0,
        "outtext1": "on",
        "outtext2": "off",
        "timeout": 1440,
        "sun": true,
        "mon": true,
        "tue": true,
        "wed": true,
        "thu": true,
        "fri": true,
        "sat": true,
        "jan": true,
        "feb": true,
        "mar": true,
        "apr": true,
        "may": true,
        "jun": true,
        "jul": true,
        "aug": true,
        "sep": true,
        "oct": true,
        "nov": true,
        "dec": true,
        "day1": 0,
        "month1": 0,
        "day2": 0,
        "month2": 0,
        "day3": 0,
        "month3": 0,
        "day4": 0,
        "month4": 0,
        "day5": 0,
        "month5": 0,
        "day6": 0,
        "month6": 0,
        "day7": "",
        "month7": "",
        "day8": "",
        "month8": "",
        "day9": "",
        "month9": "",
        "day10": "",
        "month10": "",
        "day11": "",
        "month11": "",
        "day12": "",
        "month12": "",
        "d1": 0,
        "w1": 0,
        "d2": 0,
        "w2": 0,
        "d3": 0,
        "w3": 0,
        "d4": 0,
        "w4": 0,
        "d5": 0,
        "w5": 0,
        "d6": 0,
        "w6": 0,
        "xday1": 0,
        "xmonth1": 0,
        "xday2": 0,
        "xmonth2": 0,
        "xday3": 0,
        "xmonth3": 0,
        "xday4": 0,
        "xmonth4": 0,
        "xday5": 0,
        "xmonth5": 0,
        "xday6": 0,
        "xmonth6": 0,
        "xd1": 0,
        "xw1": 0,
        "xd2": 0,
        "xw2": 0,
        "xd3": 0,
        "xw3": 0,
        "xd4": 0,
        "xw4": 0,
        "xd5": 0,
        "xw5": 0,
        "xd6": 0,
        "xw6": 0,
        "suspend": false,
        "random": false,
        "repeat": true,
        "atstart": true,
        "odd": false,
        "even": false,
        "x": 190,
        "y": 241,
        "wires": [
            [],
            [],
            [
                "84cabde5.a81f08"
            ]
        ]
    },
    {
        "id": "324c1a68.0d5fbe",
        "type": "tesla-api",
        "z": "20240160.b1b68e",
        "teslaConfig": "df12fc74.fb2de8",
        "command": "driveState",
        "name": "Get Drive State",
        "x": 410,
        "y": 383,
        "wires": [
            [
                "1b4b4b0.255fab5"
            ]
        ]
    },
    {
        "id": "1b4b4b0.255fab5",
        "type": "function",
        "z": "20240160.b1b68e",
        "name": "Extract location",
        "func": "msg.location = {}\n\nmsg.location.lat = msg.payload.latitude\nmsg.location.lon = msg.payload.longitude\n\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "x": 431,
        "y": 467,
        "wires": [
            [
                "64b057de.7fc09"
            ]
        ]
    },
    {
        "id": "84cabde5.a81f08",
        "type": "function",
        "z": "20240160.b1b68e",
        "name": "Set timer state",
        "func": "msg.timer = msg.payload\n\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "x": 414,
        "y": 307,
        "wires": [
            [
                "324c1a68.0d5fbe"
            ]
        ]
    },
    {
        "id": "64b057de.7fc09",
        "type": "geofence",
        "z": "20240160.b1b68e",
        "name": "Is home",
        "mode": "circle",
        "inside": "both",
        "rad": 104.10912694410138,
        "points": [],
        "centre": {
            "latitude": -12345,
            "longitude": 12345
        },
        "x": 412,
        "y": 545,
        "wires": [
            [
                "bedb0918.a0cd2"
            ]
        ]
    },
    {
        "id": "df12fc74.fb2de8",
        "type": "tesla-config",
        "z": "",
        "vehicleID": "12345"
    }
]
2 Likes

Yeah, that works!

I still think it’s a great function that would be nice to see in the HA integration, but I drive all of this off Node-Red anyway, so doing this part there is not really extra effort.

Thanks.

Also looking for this feature, for Tesla’s with LFP batteries it’s recommended to charge to 100% over per week.
So wanting to automated switching between 80% amd 100% based on the day of week.

Thank you for all your work on this project!

My understanding while reading and downloading components is that the Node Red Tesla plugin requires the TWCManager.py component to function. If this is correct, then the plugin won’t work with Generation 3 TWC’s. Am I missing something?

Just want to be organized before I go about getting API access tokens generated, etc. for our TWC to make HA functionality work.

Thanks again for taking on this very cool project.