Robust garage: use input_boolean to track car departure
- Replace fragile Tesla tracker state check with input_boolean.left_home_by_car - Set boolean ON when leaving by car (speed > 0), check it on arrival - Add separate car_arriving trigger as backup for WiFi-first phone - Fixes: garage not opening on arrival due to slow Tesla tracker updates
This commit is contained in:
@@ -2,7 +2,8 @@
|
|||||||
alias: Garage auto Claus
|
alias: Garage auto Claus
|
||||||
description: >
|
description: >
|
||||||
Åbn garage ved ankomst i bil, luk ved afrejse.
|
Åbn garage ved ankomst i bil, luk ved afrejse.
|
||||||
Trigger på både telefon og bil-tracker for at fange begge signaler.
|
Bruger input_boolean.left_home_by_car til at huske at afrejsen var i bil,
|
||||||
|
så ankomst-logikken ikke afhænger af at Tesla-trackeren opdaterer hurtigt.
|
||||||
|
|
||||||
trigger:
|
trigger:
|
||||||
# Telefon ankommer hjem (debounce 10s mod GPS-flimmer)
|
# Telefon ankommer hjem (debounce 10s mod GPS-flimmer)
|
||||||
@@ -13,11 +14,11 @@
|
|||||||
seconds: 10
|
seconds: 10
|
||||||
id: arriving
|
id: arriving
|
||||||
|
|
||||||
# Bil ankommer hjem (fanger tilfælde hvor telefon allerede var "home" via WiFi)
|
# Bil ankommer hjem (backup hvis telefon allerede var "home" via WiFi)
|
||||||
- platform: state
|
- platform: state
|
||||||
entity_id: device_tracker.snowywhite_location_tracker
|
entity_id: device_tracker.snowywhite_location_tracker
|
||||||
to: "home"
|
to: "home"
|
||||||
id: arriving
|
id: car_arriving
|
||||||
|
|
||||||
# Telefon forlader hjemmet (debounce 10s mod GPS-flimmer)
|
# Telefon forlader hjemmet (debounce 10s mod GPS-flimmer)
|
||||||
- platform: state
|
- platform: state
|
||||||
@@ -35,7 +36,7 @@
|
|||||||
action:
|
action:
|
||||||
- choose:
|
- choose:
|
||||||
|
|
||||||
# ÅBN: garage lukket + telefon hjemme + bil netop ankommet
|
# ÅBN via telefon: garage lukket + forlod hjemmet i bil
|
||||||
- conditions:
|
- conditions:
|
||||||
- condition: trigger
|
- condition: trigger
|
||||||
id: arriving
|
id: arriving
|
||||||
@@ -44,31 +45,54 @@
|
|||||||
entity_id: binary_sensor.garageport
|
entity_id: binary_sensor.garageport
|
||||||
state: "off"
|
state: "off"
|
||||||
|
|
||||||
# Telefon skal være hjemme
|
# Vi ved at brugeren kørte hjemmefra
|
||||||
- condition: state
|
- condition: state
|
||||||
entity_id: device_tracker.claus_iphone_15pro
|
entity_id: input_boolean.left_home_by_car
|
||||||
state: "home"
|
state: "on"
|
||||||
|
|
||||||
# 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:
|
sequence:
|
||||||
- service: cover.toggle
|
- service: cover.toggle
|
||||||
target:
|
target:
|
||||||
entity_id: cover.anne
|
entity_id: cover.anne
|
||||||
|
|
||||||
|
- service: input_boolean.turn_off
|
||||||
|
target:
|
||||||
|
entity_id: input_boolean.left_home_by_car
|
||||||
|
|
||||||
- service: notify.mobile_app_claus_iphone_15pro
|
- service: notify.mobile_app_claus_iphone_15pro
|
||||||
data:
|
data:
|
||||||
message: "Garage åbnet (ankomst i bil)"
|
message: "Garage åbnet (ankomst i bil)"
|
||||||
|
|
||||||
|
# ÅBN via bil-tracker: telefon allerede hjemme + forlod i bil
|
||||||
|
- conditions:
|
||||||
|
- condition: trigger
|
||||||
|
id: car_arriving
|
||||||
|
|
||||||
|
- condition: state
|
||||||
|
entity_id: binary_sensor.garageport
|
||||||
|
state: "off"
|
||||||
|
|
||||||
|
- condition: state
|
||||||
|
entity_id: device_tracker.claus_iphone_15pro
|
||||||
|
state: "home"
|
||||||
|
|
||||||
|
- condition: state
|
||||||
|
entity_id: input_boolean.left_home_by_car
|
||||||
|
state: "on"
|
||||||
|
|
||||||
|
sequence:
|
||||||
|
- service: cover.toggle
|
||||||
|
target:
|
||||||
|
entity_id: cover.anne
|
||||||
|
|
||||||
|
- service: input_boolean.turn_off
|
||||||
|
target:
|
||||||
|
entity_id: input_boolean.left_home_by_car
|
||||||
|
|
||||||
|
- service: notify.mobile_app_claus_iphone_15pro
|
||||||
|
data:
|
||||||
|
message: "Garage åbnet (bil-tracker ankomst)"
|
||||||
|
|
||||||
# LUK: garage åben + forlader hjemmet + bil kører
|
# LUK: garage åben + forlader hjemmet + bil kører
|
||||||
- conditions:
|
- conditions:
|
||||||
- condition: trigger
|
- condition: trigger
|
||||||
@@ -78,12 +102,17 @@
|
|||||||
entity_id: binary_sensor.garageport
|
entity_id: binary_sensor.garageport
|
||||||
state: "on"
|
state: "on"
|
||||||
|
|
||||||
# Bil skal faktisk have fart (> 0), ikke bare "speed eksisterer"
|
# Bil skal faktisk have fart (> 0)
|
||||||
- condition: template
|
- condition: template
|
||||||
value_template: >
|
value_template: >
|
||||||
{{ (state_attr('device_tracker.snowywhite_location_tracker', 'speed') | float(0)) > 0 }}
|
{{ (state_attr('device_tracker.snowywhite_location_tracker', 'speed') | float(0)) > 0 }}
|
||||||
|
|
||||||
sequence:
|
sequence:
|
||||||
|
# Markér at vi kørte hjemmefra (bruges ved ankomst)
|
||||||
|
- service: input_boolean.turn_on
|
||||||
|
target:
|
||||||
|
entity_id: input_boolean.left_home_by_car
|
||||||
|
|
||||||
- delay: "00:00:30"
|
- delay: "00:00:30"
|
||||||
|
|
||||||
# Dobbelttjek at garagen stadig er åben efter forsinkelsen
|
# Dobbelttjek at garagen stadig er åben efter forsinkelsen
|
||||||
|
|||||||
@@ -0,0 +1,4 @@
|
|||||||
|
left_home_by_car:
|
||||||
|
name: Forlod hjemmet i bil
|
||||||
|
icon: mdi:car
|
||||||
|
initial: false
|
||||||
Reference in New Issue
Block a user