When I had my Tesla Model Y I had it hooked up to TeslaFi. There were a lot of stats in there and I wanted to expose some of that data in Home Assistant for easy consumption. I also wanted to utilize the TeslaFi API to allow me to turn on the climate controls in my Tesla using Home Assistant and any voice control devices that I may be utilizing (Siri in my case). I wanted to capture my config in case it helps someone else.

Sensor for TeslaFi API

This REST sensor will poll the TeslaFi API and expose all JSON items as attributes in Home Assistant:

# TeslaFi

- platform: rest
  name: TeslaFi Report
  resource: "https://www.teslafi.com/feed.php"
  scan_interval: 60
  params:
    token: YOUR TESLAFI API TOKEN HERE
    command: lastGood
  value_template: "{{ value_json.display_name }}"
  json_attributes:
    - api_version
    - autopark_state
    - autopark_state_v2
    - autopark_style
    - battery_current
    - battery_heater
    - battery_heater_on
    - battery_level
    - battery_range
    - calendar_enabled
    - calendar_supported
    - car_type
    - car_version
    - carState
    - center_display_state
    - charge_current_request
    - charge_current_request_max
    - charge_enable_request
    - charge_energy_added
    - charge_limit_soc
    - charge_limit_soc_max
    - charge_limit_soc_min
    - charge_limit_soc_std
    - charge_miles_added_ideal
    - charge_miles_added_rated
    - charge_port_cold_weather_mode
    - charge_port_door_open
    - charge_port_latch
    - charge_port_led_color
    - charge_rate
    - charge_to_max_range
    - chargeNumber
    - charger_actual_current
    - charger_phases
    - charger_pilot_current
    - charger_power
    - charger_voltage
    - charging_state
    - climate_keeper_mode
    - color
    - conn_charge_cable
    - currency
    - data_id
    - Date
    - defrost_mode
    - df
    - display_name
    - dr
    - driveNumber
    - driver_temp_setting
    - driver_temp_settingF
    - elevation
    - est_battery_range
    - eu_vehicle
    - exterior_color
    - fan_status
    - fast_charger_brand
    - fast_charger_present
    - fast_charger_type
    - fd_window
    - fp_window
    - ft
    - gps_as_of
    - gui_24_hour_time
    - gui_charge_rate_units
    - gui_distance_units
    - gui_range_display
    - gui_temperature_units
    - heading
    - homelink_nearby
    - id
    - id_s
    - ideal_battery_range
    - idleNumber
    - idleTime
    - in_service
    - inside_temp
    - inside_tempF
    - is_auto_conditioning_on
    - is_climate_on
    - is_front_defroster_on
    - is_preconditioning
    - is_rear_defroster_on
    - is_user_present
    - last_autopark_error
    - latitude
    - left_temp_direction
    - location
    - locked
    - longitude
    - managed_charging_active
    - managed_charging_start_time
    - managed_charging_user_canceled
    - max_avail_temp
    - max_range_charge_counter
    - maxRange
    - measure
    - min_avail_temp
    - motorized_charge_port
    - newVersion
    - newVersionStatus
    - not_enough_power_to_heat
    - Notes
    - notifications_enabled
    - notifications_supported
    - odometer
    - odometerF
    - option_codes
    - outside_temp
    - outside_tempF
    - parsed_calendar_supported
    - passenger_temp_setting
    - perf_config
    - pf
    - polling
    - power
    - pr
    - rangeDisplay
    - rd_window
    - rear_seat_heaters
    - remote_start
    - remote_start_enabled
    - remote_start_supported
    - rhd
    - right_temp_direction
    - roof_color
    - rp_window
    - rt
    - scheduled_charging_pending
    - scheduled_charging_start_time
    - seat_heater_left
    - seat_heater_rear_center
    - seat_heater_rear_left
    - seat_heater_rear_left_back
    - seat_heater_rear_right
    - seat_heater_rear_right_back
    - seat_heater_right
    - seat_type
    - sentry_mode
    - shift_state
    - side_mirror_heaters
    - sleepNumber
    - smart_preconditioning
    - speed
    - spoiler_type
    - state
    - steering_wheel_heater
    - sun_roof_installed
    - sun_roof_percent_open
    - sun_roof_state
    - temperature
    - third_row_seats
    - time_to_full_charge
    - timestamp
    - trip_charging
    - usable_battery_level
    - user_charge_enable_request
    - valet_mode
    - valet_pin_needed
    - vehicle_id
    - vehicle_name
    - vin
    - wheel_type
    - wiper_blade_heater

Template Sensors

I then created a few template sensors to expose data I would use later on or wanted to see/track more quickly.

- binary_sensor:
    - unique_id: teslafi_terry_hvac_status
      name: "{{ state_attr('sensor.teslafi_report', 'vehicle_name') + ' HVAC Status' }}"
      state: "{{ state_attr('sensor.teslafi_report', 'is_climate_on') }}"
- sensor:
    - unique_id: teslafi_terry_date
      name: "{{ state_attr('sensor.teslafi_report', 'vehicle_name') + ' Last Reading' }}"
      state: "{{ as_datetime(state_attr('sensor.teslafi_report', 'Date')).isoformat() }}"
      device_class: timestamp
    - unique_id: teslafi_terry_odometer
      name: "{{ state_attr('sensor.teslafi_report', 'vehicle_name') + ' Odometer' }}"
      state: "{{ state_attr('sensor.teslafi_report', 'odometer') | round(1) }}"
      unit_of_measurement: "mi"
      icon: mdi:counter
    - unique_id: teslafi_terry_battery
      name: "{{ state_attr('sensor.teslafi_report', 'vehicle_name') + ' Battery' }}"
      state: "{{ state_attr('sensor.teslafi_report', 'battery_level') | int }}"
      unit_of_measurement: "%"
      icon: mdi:battery-80
    - unique_id: teslafi_terry_range
      name: "{{ state_attr('sensor.teslafi_report', 'vehicle_name') + ' Battery Range' }}"
      state: "{{ state_attr('sensor.teslafi_report', 'battery_range') | float }}"
      unit_of_measurement: "mi"
      icon: mdi:gauge
    - unique_id: teslafi_terry_car_state
      name: "{{ state_attr('sensor.teslafi_report', 'vehicle_name') + ' Car State' }}"
      state: "{{ state_attr('sensor.teslafi_report', 'carState') }}"

Switches

I then created two switches to control the HVAC status of Terry the Tesla:

# TeslaFi Switches
- platform: command_line
  switches:
    teslafi_terry_climate_cli:
      command_on: '/usr/bin/curl -X GET "https://www.teslafi.com/feed.php?token=YOUR API TOKEN HERE&command=auto_conditioning_start&wake=40"'
      command_off: '/usr/bin/curl -X GET "https://www.teslafi.com/feed.php?token=YOUR API TOKEN HERE&command=auto_conditioning_stop"'
      friendly_name: Terry HVAC Command Line

- platform: template
  switches:
    teslafi_terry_climate:
      friendly_name: Terry HVAC
      value_template: "{{ is_state('binary_sensor.template_teslafi_terry_hvac_status', 'on') }}"
      turn_on:
        service: switch.turn_on
        target:
          entity_id: switch.teslafi_terry_climate_cli
      turn_off:
        service: switch.turn_off
        target:
          entity_id: switch.teslafi_terry_climate_cli

I hope this helps someone! If you have any questions please ask in the comments.