Skip to content

Scheduled Charging and Departure

InTheDaylight14 edited this page Jan 5, 2023 · 2 revisions

Scheduled Charging Service Call

A custom api call can be setup to enable or disable scheduled charging. Details:

  • email: is optional if only 1 car has been added to Home Assistant
  • vehicle_id: This can be hard coded as opposed to the template below. Find your vehicle ID through the Online sensor attribute "ID".
  • enable: "true" to enable. "false" to disable.
  • time: minutes after midnight. 480 = 8am, 420 = 7am, etc.
  • wake_if_sleep: true to make sure that the car gets the information. Will wake up the vehicle.
service: tesla_custom.api
data:
  email: <[email protected]>
  command: SCHEDULED_CHARGING
  parameters:
    path_vars:
      vehicle_id: >-
        {{ state_attr('binary_sensor.<vehicle_name>_online', 'id') }}
    enable: true
    time: 480
    wake_if_asleep: true

Scheduled Departure Service Call

This one has a few more options to add to the service call:

  • email: is optional if only 1 car has been added to Home Assistant
  • vehicle_id: This can be hard coded as opposed to the template below. Find your vehicle ID through the Online sensor attribute "ID".
  • enable: "true" to enable. "false" to disable.
  • departure_time: minutes after midnight. 480 = 8am, 420 = 7am, etc.
  • preconditioning_enabled: "true" to enable preconditioning. "false" to disable preconditioning.
  • preconditioning_weekdays_only: "true" to precondition only on weekdays. "false" to precondition all days of the week.
  • off_peak_charging_enabled: "true" to enable off-peak charging. "false" to disable off-peak charging.
  • off_peak_charging_weekdays_only: "true" to off-peak charge only on weekdays. "false" to off-peak charge all days of the week.
  • end_off_peak_time: time in minutes after midnight that off-peak rates end.
  • wake_if_sleep: true to make sure that the car gets the information. Will wake up the vehicle.
service: tesla_custom.api
data:
  email: <[email protected]>
  command: SCHEDULED_DEPARTURE
  parameters:
    path_vars:
      vehicle_id: >-
        {{ state_attr('binary_sensor.<vehicle_name>_online', 'id') }}
    enable: true
    departure_time: 480
    preconditioning_enabled: true
    preconditioning_weekdays_only: true
    off_peak_charging_enabled: false
    off_peak_charging_weekdays_only: false
    end_off_peak_time: 420
    wake_if_asleep: true

Using Input Datetime Entity

Input_datetime entities could be used for the scheduled departure / charging time and end off peak time. Start by creating an input_datetime helper in HA with the TIME selected. We do not want the entity to be a "Date", or a "Date and time".

image

Use the following template structure in place of the hard-coded time in the custom_api call:

{{states('input_datetime.<my_entity>')[0:2] | int * 60 + states('input_datetime.<my_entity>')[3:5] | int}}

End result should look close to this:

departure_time: {{states('input_datetime.<my_entity>')[0:2] | int * 60 + states('input_datetime.<my_entity>')[3:5] | int}}