Welcome to Tesla Motors Club
Discuss Tesla's Model S, Model 3, Model X, Model Y, Cybertruck, Roadster and More.
Register
  • We just completed a significant update, but we still have some fixes and adjustments to make, so please bear with us for the time being. Cheers!

Node-Red Sleep Charging Flow for Octopus or Time of Use Electricity

chrisgla

Member
Aug 11, 2019
17
10
Glasgow, UK
Hello all!

I am trying to integrate my Modbus charger, Octopus Energy and Tesla API to charge at best time.

I've only been using Node-Red for a month and not a developer so surprised how far I'm getting!

I have the charger integrated. able to get best charging times from Octopus API and using Node-Red-contrib-Tesla I can see vehicle data but I've not quite got the logic right to avoid vampire drain.

Does anyone have flows they can share on how they implemented anti-vampire measures?

I have most of the not waking vehicle up bit working based on checking if vehicle is online and outside temperature is not a number- the main thing I'm struggling with is how to watch for the vehicle waking so I know I can change from vehicle "offline" query to a full all data query.
It should be simple- but in these things so am I!

Part of the reason is I did use TeslaFi, but it doesn't have capability to feed in actually half hourly electricity prices to work out how much a charge actually cost. Later stage...
 

denouche

Member
Apr 25, 2020
25
10
FRANCE
Hello,
You have different API endpoints.
You can find the list here:
List
State And Settings
Commands

The endpoints GET /vehicles and GET /vehicles/{id} does not prevent the car to go asleep.
These 2 endpoints also give you the current vehicle "state" (asleep, online).
If the vehicle is "online" you can call the endpoint GET /vehicle/{id}/vehicle_data (otherwise you will get a 408 response error)
In this endpoint you will have a lot of informations you can use.
You can poll this endpoint (for example every 1 or 2 minutes).
To know if the car want to go to sleep, you can check the "drive_state.shift_state" field. If it's null, it's because the vehicle is parked and want to go to sleep. At this moment, stop polling and wait the vehicle state is "asleep" (in the GET /vehicle/{id} response).
When the vehicle is asleep, start again polling until the vehicle is back online.

There is some others fields you can check to determine if the vehicle want to go asleep:
- if vehicle_state.sentry_mode is true, the vehicle will never go to sleep (even if shift_state is null)
- if charge_state.charging_state is "Charging", same thing
In these cases you can continue polling the vehicle_data endpoint.
 

About Us

Formed in 2006, Tesla Motors Club (TMC) was the first independent online Tesla community. Today it remains the largest and most dynamic community of Tesla enthusiasts. Learn more.

Do you value your experience at TMC? Consider becoming a Supporting Member of Tesla Motors Club. As a thank you for your contribution, you'll get nearly no ads in the Community and Groups sections. Additional perks are available depending on the level of contribution. Please visit the Account Upgrades page for more details.


SUPPORT TMC
Top