Teslemetry Pre-condition Script

Hi all,

I use the Teslemetry integration for my Powerwalls and Tesla vehicles. I have a script that pre-conditions the cars. This script can be called manually or from an automation.

I had noticed that sometimes I’d see connection issues or time-outs that would cause the vehicle to fail to precondition.

So I wrapped it in some retry logic. I was just curious for others using the integration, if you do something similar, or any tips or tricks. I think when the vehicle is in a deep sleep it doesn’t always work.

Cheers!
Matt

  turn_on_vehicle_climate:
    fields:
      vehicle_climate:
        name: Vehicle climate entity
        description: Tesla climate entity to precondition
        selector:
          entity:
            filter:
              domain: climate
    sequence:
      - repeat:
          until: "{{ is_state(vehicle_climate, 'heat_cool') or repeat.index > 3 }}"
          sequence:
            - action: climate.set_temperature
              data:
                entity_id: "{{ vehicle_climate }}"
                temperature: >
                  {% set seasonalHeat = is_state('input_select.seasonal_hvac_mode', 'Heat') %}
                  {% set seasonalAC = is_state('input_select.seasonal_hvac_mode', 'Cool') %}
                  {% if seasonalHeat %}
                    72
                  {% elif seasonalAC %}
                    68
                  {% else %}
                    70
                  {% endif %}
                hvac_mode: heat_cool
            - delay: "00:00:30"
1 Like