How do I get this working? I wish to have TTS but only if I’ve been away for 3 hours or more. The automation executes fine when i call it, it just does not trigger
automation:
- alias: "Colms Home"
trigger:
- platform: state
entity_id: device_tracker.colmoneplus5_localdomain
from: 'not_home'
to: 'home'
condition:
- condition: state
entity_id: device_tracker.colmoneplus5_localdomain
state: 'not_home'
for:
minutes: 180
action:
service: tts.google_say
entity_id:
- media_player.sitting_room_display
- media_player.kitchen_speaker
data_template:
message: "Yay, welcome home colm, the house is {{states('sensor.hallway_sensor_temperature')}} degrees. You have taken {{states('sensor.google_fit_steps')}} steps today covering {{states('sensor.google_fit_distance')}} kilometers and burning {{states('sensor.google_fit_calories')}} calories"
Thats not going to work, the automation will only trigger when you are home, so your condition of checking if you are currently away for at least 3 hours will always block it.
The best that comes to mind at the moment is an automation to record the timestamp when you leave and then use a template sensor to calculate how long its been since that timestamp is greater than 3 hours.
Something using a trigger.last_state.attribute.last_changed might also be possible.
That will only trigger once - when you are away for 3 hours. And because you are away, a condition of when you change from away to home would block it from ever firing.
Automation’s record when they last fire, you could create an automation that does something (or nothing, leave it blank) which fires when you (or create a group for everyone) leaves the house. You could use a trigger for when you arrive home, and you could then use a template condition that does this:
I’ve been trying this^^ and it’s not going to work as is. My device tracker is nmap so if my wifi drops the dummy automation gets triggered. How do i add a condition to this dummy automation that it must be in this state for 3 hours?
This is what I have
- alias: "Colms away"
trigger:
- platform: state
entity_id: device_tracker.colmoneplus5_localdomain
from: 'home'
to: 'not_home'
condition: []
action: []
Though you may have the same issue, if the device keeps dropping in and out, and its state changes to away, the 3 hour timer resets and it wont then trigger for another 3 hours.
create a helper that changes like this. This works for me. The helper changes state of the input_select to “not Home”, “just arrived”, “home” and “away” and perform action on that state
###### index status of Dave present detection #################
- alias: Mark Dave as just arrived
initial_state: true
trigger:
- platform: state
entity_id: device_tracker.life360_dave
from: 'not_home'
to: 'home'
action:
- service: input_select.select_option
data:
entity_id: input_select.dave_status_dropdown
option: Just Arrived
- alias: Mark Dave as home
initial_state: true
trigger:
- platform: state
entity_id: input_select.dave_status_dropdown
to: 'Just Arrived'
for:
minutes: 5
- platform: state
entity_id: input_select.dave_status_dropdown
from: 'Just Left'
to: 'Just Arrived'
condition:
action:
- service: input_select.select_option
data:
entity_id: input_select.dave_status_dropdown
option: Home
- alias: Mark Dave as just left
initial_state: true
trigger:
- platform: state
entity_id: device_tracker.life360_dave
from: 'home'
to: 'not_home'
action:
- service: input_select.select_option
data:
entity_id: input_select.dave_status_dropdown
option: Just Left
- alias: Mark Dave as away
initial_state: true
trigger:
- platform: state
entity_id: input_select.dave_status_dropdown
to: 'Just Left'
for:
minutes: 2
action:
- service: input_select.select_option
data:
entity_id: input_select.dave_status_dropdown
option: Away
one automation and this works
- alias: Dave or Linda Home turn dining light on
initial_state: true
trigger:
platform: state
entity_id: binary_sensor.ecolink_door_window_sensor_sensor
condition:
- condition: template
value_template: >
{{ is_state('binary_sensor.ecolink_door_window_sensor_sensor','on') }}
- condition: template
value_template: >
{{ is_state('sun.sun','below_horizon') }}
- condition: template
value_template: >
{{ is_state('input_select.dave_status_dropdown','Just Arrived') or
is_state('input_select.linda_status_dropdown','Just Arrived') }}
action:
- service: light.turn_on
entity_id: light.leviton_dz6hd_1bz_decora_600w_smart_dimmer_level
data:
brightness_pct: 100
- service: switch.turn_on
entity_id: switch.wenzhou_mtlc_electric_appliances_enerwave_zwn_rsm1_plus_smart_single_relay_switch_module_switch
this is what is in my configuration.yaml (the helper) for the input_setect
> input_select:
>
> dave_status_dropdown:
> name: Dave
> options:
> - Home
> - Just Arrived
> - Just Left
> - Away
> initial: Home