How to use Home Assistant to get an alert if your Tesla is not plugged in at night

I bought a Tesla Model 3 last year and it has been the best car I’ve ever owned, by far! Feel free to use my referral link if you want to purchase one also and get 1000 free Supercharger miles.

One of the best parts of owning it is that it never needs to be filled up for most daily driving. I don’t have to wonder if I have enough gas to go do daily chores. It charges up every night and is ready to go every morning.

This means that you have to remember to plug the car in every night. Normally, I plug it in when I get home from work (even though it is not scheduled to charge until later in the night). However, there are times when it doesn’t get plugged in for whatever reason (kids throwing a fit as soon as we get home, for instance).

I needed a way to make sure I always plugged the car in so it would charge during the night. Luckily, this is a simple automation in Home Assistant.

First, you need to configure the Tesla integration. This will give Home Assistant the ability to query your car to see if it is plugged in. It also gives you a lots of useful metrics about your car in the dashboard. Fun aside, my kids were so impressed with the speed of the car compared to my truck that they named my car Red Rocket! Therefore, lots of the entities have some reference to that name.

  • You can add the Tesla integration by clicking on Configuration then Integrations.
  • Click on the Add button in the lower right-hand side and search for Tesla.
  • Enter your username and password. Ensure the integration is able to successfully login to your Tesla account.
  • After the Tesla integration is finished configuring, you will see a large number of new entities. You can view them by searching for the Tesla integration in the Integrations page and clicking on Entities (I have renamed some of mine to make it more obvious what they were, so your entity names will vary).

The most important one for our purposes is the binary_sensor.red_charger_sensor as this one indicates whether or not the car is plugged into the charger.

Now that we have Home Assistant configured to communicate with your Tesla, the automation code is easy to write. In your automations.yaml file (or the GUI if you are so inclined), you will need to add the following code.

- alias: Notify if Tesla not plugged in at night
  initial_state: True
    - platform: time
      at: "19:30:00"
    condition: and
      - condition: state
        entity_id: binary_sensor.red_charger_sensor
        state: 'off'
      - condition: template
        value_template: "{{ is_state_attr('binary_sensor.red_parking_brake_sensor', 'shift_state', 'P')}}"
    service: notify.notify
      message: "Tesla Model 3 not plugged in!"
      title: "Alarm"

trigger – This automation will fire at 7:30 PM every night (if I am still at the office by this time, I am working too hard!).

condition – I need to both check both that the Tesla is not plugged in (by virtue of the binary_sensor.red_charger_sensor being in the off state) and that the car is in Park (as indicated by the binary_sensor.red_parking_brake_sensor.shift_state being equal to P). I don’t want this automation to go off if I am driving.

I could have added a check to make sure I am home, but I still wanted the reminder in case I am traveling and need to ensure the car is plugged in.

action – I use the default notify.notify since this will send a notification to both my phone as well as my wife’s phone.

As you can see, this is a simple automation to add, but it has saved me from not having a charged car many times.