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"
}
]