Greetings,
I am new to home assistant so hopefully I am doing this correctly. I have been scratching my head over this and have tried 20+ different things to get an automation to check an attribute with no luck, not sure why it is not working, I haven’t had this issue with other devices.
I have a lock that has the following attributes:
I am attempting to make an automation based on the “lockStatus: #” state / attribute and cannot get it to function. Here is what I tried (I also tried simpler attributes like ‘locked: true’):
condition: state
entity_id: lock.garage_door
attribute: lockStatus
state: 3
condition: template
value_template: "{{ is_state_attr('lock.garage_door', 'lockStatus', '3') }}"
I also tried different attributes like ‘locked: true’ with true and false values and could not get that to pass a test either. Are there certain states / attributes that cannot be used in automation or am I just doing this incorrectly?
petro
(Petro)
November 21, 2022, 9:21pm
2
that should have worked
that should be
condition: template
value_template: "{{ is_state_attr('lock.garage_door', 'lockStatus', 3) }}"
UNLESS… Can you copy/paste the attributes from developer tools → states page?
Thanks so much for the reply. I tried the template and get that the condition does not pass:
type: DEVICE_TYPE.LOCK_ADVANCED
category: LOCK
state:
name: Garage Door
model: T8520
serialNumber: #
hardwareVersion: P3
softwareVersion: 1.4.2.8
stationSerialNumber: #
battery: 76
locked: true
lockStatus: 3
p2pLiveStreamingStatus: false
rtspLiveStreamingStatus: false
global_motion_sensor: false
type: 51
autoLockTimer: 180
autoLockScheduleStartTime: '23:00'
autoLockScheduleEndTime: '06:00'
wrongTryAttempts: 5
wrongTryLockdownTime: 180
sound: 0
autoLockSchedule: false
notification: true
notificationUnlocked: true
oneTouchLocking: true
wrongTryProtection: true
autoLock: false
notificationLocked: true
scramblePasscode: false
properties_metadata:
name:
key: device_name
name: name
label: Name
readable: true
writeable: false
type: string
model:
key: device_model
name: model
label: Model
readable: true
writeable: false
type: string
serialNumber:
key: device_sn
name: serialNumber
label: Serial number
readable: true
writeable: false
type: string
type:
key: device_type
name: type
label: Type
readable: true
writeable: false
type: number
states:
'0': Station
'1': Camera
'2': Sensor
'3': Floodlight
'4': Camera E
'5': Doorbell
'7': Battery Doorbell
'8': Camera 2
'9': Camera 2c
'10': Motion Sensor
'11': Keypad
'14': Camera 2 Pro
'15': Camera 2c Pro
'16': Battery Doorbell 2
'30': Indoor Camera
'31': Indoor Camera PT
'32': Solo Camera
'33': Solo Camera Pro
'34': Indoor Camera 1080
'35': Indoor Camera PT 1080
'37': Floodlight 8422
'38': Floodlight 8423
'39': Floodlight 2
'44': Outdoor Camera 1080P No Light
'45': Outdoor Camera 2k
'46': Outdoor Camera 1080P
'50': Lock Basic
'51': Lock Advanced
'52': Lock Basic No Finger
'53': Lock Basic Advanced No Finger
'54': Lock 8503
'55': Lock 8530
'56': Lock 85A3
'57': Lock 8592
'58': Lock 8504
'60': Solo Camera Spotlight 1080p
'61': Solo Camera Spotlight 2k
'62': Solo Camera Spotlight Solar
'90': SmartDrop, Smart Delivery Box
'91': Video Doorbell Dual
'93': Video Doorbell Dual (Wired)
hardwareVersion:
key: main_hw_version
name: hardwareVersion
label: Hardware version
readable: true
writeable: false
type: string
softwareVersion:
key: main_sw_version
name: softwareVersion
label: Software version
readable: true
writeable: false
type: string
stationSerialNumber:
key: station_sn
name: stationSerialNumber
label: Station serial number
readable: true
writeable: false
type: string
battery:
key: 6001
name: battery
label: Battery percentage
readable: true
writeable: false
type: number
unit: '%'
min: 0
max: 100
locked:
key: custom_locked
name: locked
label: locked
readable: true
writeable: true
type: boolean
lockStatus:
key: 6000
name: lockStatus
label: Lock status
readable: true
writeable: false
type: number
states:
'1': '1'
'2': '2'
'3': Unlocked
'4': Locked
'5': Mechanical anomaly
'6': '6'
'7': '7'
autoLock:
key: 6500
name: autoLock
label: Auto Lock
readable: true
writeable: true
type: boolean
autoLockTimer:
key: 6600
name: autoLockTimer
label: Auto Lock Timer
readable: true
writeable: true
type: number
states:
'1': 1 sec.
'30': 30 sec.
'60': 1 min.
'90': 1,5 min.
'120': 2 min.
'150': 2,5 min.
'180': 3 min.
default: 60
unit: sec
autoLockSchedule:
key: 6501
name: autoLockSchedule
label: Auto Lock Schedule
readable: true
writeable: true
type: boolean
autoLockScheduleStartTime:
key: 6601
name: autoLockScheduleStartTime
label: Auto Lock Schedule Starttime (24-hour clock)
readable: true
writeable: true
type: string
default: '23:00'
format: {}
autoLockScheduleEndTime:
key: 6602
name: autoLockScheduleEndTime
label: Auto Lock Schedule Endtime (24-hour clock)
readable: true
writeable: true
type: string
default: '6:00'
format: {}
oneTouchLocking:
key: 6502
name: oneTouchLocking
label: One-Touch Locking
readable: true
writeable: true
type: boolean
wrongTryProtection:
key: 6503
name: wrongTryProtection
label: Wrong Try Protection
readable: true
writeable: true
type: boolean
wrongTryAttempts:
key: 6603
name: wrongTryAttempts
label: Wrong Try Attempts
readable: true
writeable: true
type: number
min: 3
max: 10
default: 6
wrongTryLockdownTime:
key: 6604
name: wrongTryLockdownTime
label: Wrong Try Lockdown Time
readable: true
writeable: true
type: number
states:
'60': 1 min.
'120': 2 min.
'180': 3 min.
'240': 4 min.
'300': 5 min.
default: 300
unit: sec
scramblePasscode:
key: 6504
name: scramblePasscode
label: Scramble Passcode
readable: true
writeable: true
type: boolean
sound:
key: 6505
name: sound
label: Sound
readable: true
writeable: true
type: number
states:
'0': 'Off'
'1': Low
'2': Medium
'3': High
default: 2
notification:
key: 6506
name: notification
label: Notification
readable: true
writeable: true
type: boolean
notificationUnlocked:
key: 6605
name: notificationUnlocked
label: Notification Unlocked
readable: true
writeable: true
type: boolean
notificationLocked:
key: 6606
name: notificationLocked
label: Notification Locked
readable: true
writeable: true
type: boolean
lowBatteryAlert:
key: custom_lowBatteryAlert
name: lowBatteryAlert
label: Low Battery Alert
readable: true
writeable: false
type: boolean
friendly_name: Garage Door
maybe this:
condition: template
value_template: "{{ state_attr('lock.garage_door', 'lockStatus') == 3 }}"
Actually, just checked they are the same, not used the is_state_attr
before, you learn something new every day
123
(Taras)
November 21, 2022, 10:41pm
6
Based on your screenshot, lock.garage_door
has an attribute named state
whose value is a dictionary. One of the dictionary’s keys is named lockStatus
.
condition: template
value_template: "{{ state_attr('lock.garage_door', 'state').lockStatus == 3 }}"
petro
(Petro)
November 21, 2022, 11:25pm
7
Sorry for the late response, as I expected, your attribute is not what you thought it was. 123 has the correct solution
That worked! Thank you so much! I had no it was considered a dictionary, I will need to read up on it.
1 Like