Files
N22/include/automations/open_garage_when_car_arrives.yaml
T
claus d39e0051db Fix TTS google_translate→google_ai_tts, robust garage automation
- Replace broken media_player.play_media/google_translate TTS with tts.speak/google_ai_tts
  in doerklokke_for.yaml (4x), doerklokke_bag2.yaml (3x), doorbell.yaml (1x)
- Garage automation: add GPS debounce, dual trigger (phone+car), cover.toggle,
  post-delay re-check, last_changed guard against false opens
- Remove duplicate doerklokke_bag.yaml (replaced by doerklokke_bag2.yaml)
2026-04-19 18:40:14 +02:00

104 lines
3.0 KiB
YAML

- id: garage_auto_claus_presence
alias: Garage auto Claus
description: >
Åbn garage ved ankomst i bil, luk ved afrejse.
Trigger på både telefon og bil-tracker for at fange begge signaler.
trigger:
# Telefon ankommer hjem (debounce 10s mod GPS-flimmer)
- platform: state
entity_id: device_tracker.claus_iphone_15pro
to: "home"
for:
seconds: 10
id: arriving
# Bil ankommer hjem (fanger tilfælde hvor telefon allerede var "home" via WiFi)
- platform: state
entity_id: device_tracker.snowywhite_location_tracker
to: "home"
id: arriving
# Telefon forlader hjemmet (debounce 10s mod GPS-flimmer)
- platform: state
entity_id: device_tracker.claus_iphone_15pro
from: "home"
for:
seconds: 10
id: leaving
condition:
- condition: time
after: "05:00:00"
before: "23:00:00"
action:
- choose:
# ÅBN: garage lukket + telefon hjemme + bil netop ankommet
- conditions:
- condition: trigger
id: arriving
- condition: state
entity_id: binary_sensor.garageport
state: "off"
# Telefon skal være hjemme
- condition: state
entity_id: device_tracker.claus_iphone_15pro
state: "home"
# Bil skal være hjemme
- condition: state
entity_id: device_tracker.snowywhite_location_tracker
state: "home"
# Bilen skal have skiftet til "home" for nylig (< 5 min)
# Forhindrer åbning hvis du går hjem og bilen allerede stod i garagen
- condition: template
value_template: >
{{ (now() - states.device_tracker.snowywhite_location_tracker.last_changed).total_seconds() < 300 }}
sequence:
- service: cover.toggle
target:
entity_id: cover.anne
- service: notify.mobile_app_claus_iphone_15pro
data:
message: "Garage åbnet (ankomst i bil)"
# LUK: garage åben + forlader hjemmet + bil kører
- conditions:
- condition: trigger
id: leaving
- condition: state
entity_id: binary_sensor.garageport
state: "on"
# Bil skal faktisk have fart (> 0), ikke bare "speed eksisterer"
- condition: template
value_template: >
{{ (state_attr('device_tracker.snowywhite_location_tracker', 'speed') | float(0)) > 0 }}
sequence:
- delay: "00:00:30"
# Dobbelttjek at garagen stadig er åben efter forsinkelsen
- condition: state
entity_id: binary_sensor.garageport
state: "on"
- service: cover.toggle
target:
entity_id: cover.anne
- service: notify.mobile_app_claus_iphone_15pro
data:
message: "Garage lukket (afrejse i bil)"
mode: single
max_exceeded: silent