I’m trying to make sure my alarm does not get disarmed because I get WiFi signal on my way out of the house.
My current setup is that I turn on the alarm manually, but when my device tracker sees me as home it should disarm the alarm.
I have one device tracker that is ping type, and I use the Home assistant app geo tracking.
Those two are the triggers.
Then I have the condition, which is that the alarm has to be armed, and now I want to be sure a sudden wifi or geo track within “home” does not disarm the alarm.
So how can I add a condition in the automation to not disarm the alarm if the last state change is less than say 5 minutes ago?
The date time sensor is a string, and my input date time is a different formatted string or timestamp.
This is my current automation:
- id: '1234'
alias: Alarm off, arrive home
description: ''
trigger:
- entity_id: device_tracker.andreas
platform: state
to: home
- entity_id: device_tracker.nem_l21
platform: state
to: home
condition:
- condition: state
entity_id: alarm_control_panel.sector_alarm_01234
state: armed_away
action:
- data:
code: 1234
entity_id: alarm_control_panel.sector_alarm_01234
service: alarm_control_panel.alarm_disarm
I just adapted your example, however I see now that the logic in your example is wrong, you are checking whether now + 5 minutes is bigger than the last state change, this will always be true, the + 5 minutes needs to be on the other side of the comparison
as_timestamp() converts datetime object or string to UNIX timestamp. This function also be used as a filter.`
So it doesn’t say if it returns a string or int. Do you know?
I see now that there was a double single quote which looked like a double quote.
Let me try this again, just have to wait for my router to stop believing I’m home.
EDIT again.
Yes it worked. It was the double single quotes that tricked me.
Here’s another way to do the same thing. It takes advantage of the fact that the now() function has a timestamp property and an input_datetime has a timestamp attribute.