You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

109 lines
4.4 KiB

######################################################################
# @CCOSTAN - Follow Me on X
# For more info visit https://www.vcloudinfo.com/click-here
# Original Repo : https://github.com/CCOSTAN/Home-AssistantConfig
# -------------------------------------------------------------------
# Tesla Model Y - Arrival and nightly plug-in reminders
# Garage speech + parents push reminders when the Tesla comes home low.
# -------------------------------------------------------------------
# Related Issue: 1279
# Notes: Expects Tesla Fleet UI entities `sensor.spaceship_battery_level`
# and `switch.spaceship_charge`.
# Notes: Uses `cover.large_garage_door` closing as the arrival proxy so
# Tesla location drift does not suppress reminders.
# Notes: The nightly parents reminder starts at 8 PM or after a post-8 PM
# garage close, then loops every 30 minutes via a custom event while the
# latest garage-arrival signal is recent and the car still is not charging.
######################################################################
input_datetime:
tesla_model_y_last_garage_close:
name: Tesla Model Y Last Garage Close
has_date: true
has_time: true
automation:
- alias: "Tesla Model Y - Garage Plug In Reminder"
id: 6a873341-c823-4d5d-9d42-fc2df52b93db
mode: restart
trigger:
- platform: state
entity_id: cover.large_garage_door
from: 'open'
to: 'closed'
for: '00:03:20'
action:
- service: input_datetime.set_datetime
target:
entity_id: input_datetime.tesla_model_y_last_garage_close
data:
datetime: "{{ now().strftime('%Y-%m-%d %H:%M:%S') }}"
- condition: template
value_template: >-
{% set battery = states('sensor.spaceship_battery_level') %}
{{ battery not in ['unknown', 'unavailable', 'none', ''] and
(battery | float(100)) < 50 and
is_state('switch.spaceship_charge', 'off') }}
- service: notify.alexa_media_garage
data:
message: >-
Reminder: the Tesla battery is at
{{ states('sensor.spaceship_battery_level') | float(0) | round(0) }} percent.
Please plug in the Model Y.
data:
type: announce
- service: script.send_to_logbook
data:
topic: "TESLA"
message: >-
Garage reminder announced to plug in the Model Y at
{{ states('sensor.spaceship_battery_level') | float(0) | round(0) }} percent.
- alias: "Tesla Model Y - Nightly Plug In Reminder"
id: 8b243b63-f5c3-4436-b596-0ec00a2108ab
mode: single
trigger:
- platform: time
at: '20:00:00'
id: nightly
- platform: event
event_type: event_tesla_model_y_nightly_loop
id: loop
- platform: state
entity_id: cover.large_garage_door
from: 'open'
to: 'closed'
for: '00:03:20'
id: garage_closed
action:
- condition: template
value_template: >-
{% set last_close = states('input_datetime.tesla_model_y_last_garage_close') %}
{% set last_close_ts = as_timestamp(last_close, 0) %}
{% set recent_garage_close = trigger.id == 'garage_closed' or
(last_close_ts > 0 and (as_timestamp(now()) - last_close_ts) < 43200) %}
{% set after_8_pm = now().hour >= 20 or now().hour < 5 %}
{% set battery = states('sensor.spaceship_battery_level') %}
{{ recent_garage_close and
(trigger.id != 'garage_closed' or after_8_pm) and
battery not in ['unknown', 'unavailable', 'none', ''] and
(battery | float(100)) < 50 and
is_state('switch.spaceship_charge', 'off') }}
- service: script.notify_engine
data:
title: "Tesla Plug In Reminder"
value1: >-
The Model Y recently came in through the garage, is below 50 percent,
and is not plugged in.
Current battery:
{{ states('sensor.spaceship_battery_level') | float(0) | round(0) }} percent.
who: 'parents'
group: 'Tesla_Model_Y'
- service: script.send_to_logbook
data:
topic: "TESLA"
message: >-
Nightly plug-in reminder sent because the Model Y recently came in through the garage below 50 percent and is not charging.
- delay: '00:30:00'
- event: event_tesla_model_y_nightly_loop

Powered by TurnKey Linux.