Charging Tesla with Tesla Wall Charger during off peak hours

Wanted to share my automations to charge the car only during the allowed hours (two periods), stop charging if the car is plugged in during peak hours, resume charging after peak hours period ends.

My electricity provider has peak rates during 07:00am - 10:00am and 05:00pm-08:00pm.
The goal is to charge only during off peak hours.

This script turns off charging if you plug in the car during peak hours:

alias: Turn off Charging if plugged in during peak hours
description: ""
trigger:
  - type: charging
    platform: device
    device_id: XXX
    entity_id: XXX
    domain: binary_sensor
condition:
  - condition: or
    conditions:
      - condition: time
        after: "07:00:00"
        before: "10:00:00"
        weekday:
          - sun
          - mon
          - wed
          - tue
          - thu
          - fri
          - sat
      - condition: time
        before: "20:00:00"
        after: "17:00:00"
        weekday:
          - sat
          - fri
          - thu
          - wed
          - tue
          - mon
          - sun
action:
  - service: switch.turn_off
    data: {}
    target:
      area_id: garage
      device_id: XXX
      entity_id: switch.laila_charger
mode: single

This script resumes charging after peak hours end:

alias: Turn on Charger to continue charging off peak hours
description: ""
trigger:
  - platform: time
    at: "10:00:00"
  - platform: time
    at: "20:00:00"
condition: []
action:
  - service: switch.turn_on
    data: {}
    target:
      area_id: garage
      device_id: XXX
      entity_id: switch.laila_charger
mode: single

Here we stop in-progress charging when the peak hours start:

alias: Turm Off Charging before peak hours start
description: ""
trigger:
  - platform: time
    at: "07:00:00"
  - platform: time
    at: "17:00:00"
condition:
  - condition: state
    entity_id: binary_sensor.tesla_wall_connector_contactor_closed
    state: "on"
action:
  - service: switch.turn_off
    data: {}
    target:
      area_id: garage
      device_id: XXX
      entity_id: switch.laila_charger
mode: single

This is the very first automation attempt, hope this will be helpful.

1 Like