homeassistant:
# customize:

# The scan_interval is now set to 6 hours
# Leaving it to the default (which is 5 minutes, or 300 seconds) will drain battery at a rate of
# 10 miles per day (or 3% battery use) on an average. Use this setting carefully!

tesla:
  username: !secret tesla_username
  password: !secret tesla_password
  scan_interval: 21600
###############################################################################
#                _                        _   _
#     /\        | |                      | | (_)
#    /  \  _   _| |_ ___  _ __ ___   __ _| |_ _  ___  _ __  ___
#   / /\ \| | | | __/ _ \| '_ ` _ \ / _` | __| |/ _ \| '_ \/ __|
#  / ____ \ |_| | || (_) | | | | | | (_| | |_| | (_) | | | \__ \
# /_/    \_\__,_|\__\___/|_| |_| |_|\__,_|\__|_|\___/|_| |_|___/
#
###############################################################################

automation:
  - alias: Notify Charging Status
    initial_state: true
    trigger:
      - platform: state
        entity_id: binary_sensor.tesla_model_3_charger_sensor
    action:
      - service: script.notify_me
        data_template:
          message: "Tesla Car Charge Status changed to: {{ trigger.to_state.state| upper }}"

  - alias: Notify Door Status
    initial_state: true
    trigger:
      - platform: state
        entity_id: lock.tesla_model_3_door_lock
    condition:
      - condition: template
        value_template: '{{ trigger.from_state.state | lower != "unknown" }}'
    action:
      - service: script.notify_me
        data_template:
          message: "Tesla Door is now: {{ trigger.to_state.state | upper }}"

  - alias: Notify Charger Switch State
    initial_state: true
    trigger:
      - platform: state
        entity_id: switch.tesla_model_3_charger_switch
    condition:
      - condition: template
        value_template: '{{ trigger.from_state.state | lower != "unknown" }}'
    action:
      - service: script.notify_me
        data_template:
          message: "Tesla Door is now: {{ trigger.to_state.state| upper }}"
