Im trying to create an automation where I get a notification if the car is unlocked and parked, after 1 minute.
With the automation below I receive the noticed although the car is locked. Do I need to use the attribute ‘shift_state’ and if so how do I look for the ‘P’ state?
alias: '[NOTICE] - Bilen är olåst'
description: ''
trigger:
- entity_id: lock.el_rosso_door_lock
for: 00:01:00
platform: state
to: unlocked
condition:
- condition: state
entity_id: binary_sensor.el_rosso_parking_brake_sensor
state: 'on'
action:
- data:
message: El Rosso är olåst!
service: notify.telegram
The condition shouldn’t matter at all if the door was locked. The only way this triggers is if is in the unlocked state for at least 1 minute (THEN it will look at the condition).
The fact that you says you got it even though the car was locked is a little suspicious.
To answer your other question, I don’t have a tesla so I’m not sure about the attributes, but if you have an attribute you want to check for a trigger or condition, do this.
condition:
- condition: template
# Some condition that evaluates to 'true' or 'false'
value_template: "{{ is_state_attr('sensor.tesla', 'shift_state', 'P') }}"
This will return True if sensor.tesla has an attribute named ‘shift_state’, who’s value is exactly ‘P’.