I built this: Charge the car and ignore energy prices if there's an appointment coming up

TLDR;
Problem:
You charge your car automatically when energy is cheap(great!) but you have a scheduled appointment and need a “fully” charged car in the morning, no matter the energy cost.

Solution:
Check Battery level and calendar events daily and force charging if needed!

So, my GF has to travel around 150km per day if she plans to work at the office and not at home.
At the same time, the car is only charged if energy prices are low - that could lead to the car hanging around at 25% for 2-3 days.
2 office days in a row are no problem, 3 become an issue. So I built this automation to check the calendar for events that have the office’s location set and then force charge the car and ignore energy prices, if necessary.

this automation uses:

  • the calendar integration and our shared calendar events
  • the Wallbox API, a go-e charger
  • the Tesla integration to check battery level and set the charging limit
  • a proximity sensor to determine if the car is even at home
alias: Fuchur - Laden für Hamburg-Trip
description: >-
  Check if the car is low on battery and needs to travel a long distance today
  and should be charged
trigger:
  - platform: time
    at: "00:05:00"
condition:
  - condition: numeric_state
    entity_id: sensor.home_tesla_location_distance
    below: 50
  - condition: state
    entity_id: binary_sensor.tesla_plugged_in
    state: "on"
  - condition: numeric_state
    entity_id: sensor.tesla_battery_level
    below: 65
action:
  - sequence:
      - alias: Heutige Termine abrufen
        action: calendar.get_events
        target:
          entity_id: calendar.the_calendar
        data:
          duration:
            hours: 24
        response_variable: agenda
      - alias: Prüfen ob einer der Termine in Hamburg stattfindet
        if:
          - condition: template
            value_template: >
              {% set ns = namespace(found=false) %} {% for event in
              agenda["calendar.the_calendar"].events %}
                {% if event.location is defined and 'hamburg' in event.location | lower %}
                  {% set ns.found = true %}
                  {% break %}
                {% endif %}
              {% endfor %} {{ ns.found }}
        then:
          - alias: Wallbox Modus auf Default setzen & Eco Mode deaktivieren
            data:
              option: Default
            target:
              entity_id: select.wallbox_garage_logic_mode
            action: select.select_option
          - alias: Notify Phones
            data:
              title: 🪫 Unzureichende Fahrzeugladung erkannt!
              message: >-
                Anstehender Termin in Hamburg erkannt, Fahrzeug wird
                strompreisunabhängig ausreichend geladen!
            action: notify.phones
          - alias: Charge Limit auf 80% setzen
            target:
              entity_id: number.tesla_charge_limit
            data:
              value: 80
            action: number.set_value
mode: restart