irzayev1
(Irzayev)
March 2, 2024, 7:06pm
1
Hi everyone,
My esphome script is:
binary_sensor:
platform: gpio
name: “Door Sensor”
icon: “mdi:door”
id: DOOR
device_class: door
pin:
number: D3
mode: INPUT_PULLUP
inverted: False
filters:
platform: gpio
name: “Lock Sensor”
icon: “mdi:lock”
id: Lock
device_class: safety
pin:
number: D4
mode: INPUT_PULLUP
inverted: False
filters:
It gives me states ON and OFF
How can I get states values Locked and Unlocked?
Thx!
Edwin_D
(Edwin D.)
March 2, 2024, 7:10pm
2
I’d use state class lock, not safety. But to get back to your question: the states stay the same, it is just the presentation in Lovelace that changes through translation.
1 Like
irzayev1
(Irzayev)
March 2, 2024, 11:27pm
4
yeap I know, HA shows correct in lovelace, but just for perfection i’d like to get right statuses =)
i think smth like that but its not correct syntax:
platform: gpio
name: “Lock Sensor”
icon: “mdi:lock”
id: Lock
device_class: safety
pin:
number: D4
mode: INPUT_PULLUP
inverted: False
filters:
delayed_off: 100 ms
lambda: |-
if (id(‘Lock’).state) {
return “Unlocked”;
} else {
return “Locked”;
}
tom_l
March 3, 2024, 1:18am
5
No one can tell. You have not formatted your post correctly for the forum as I advised earlier.
Spacing is important in yaml. We cant tell what your spacing is if you don’t format it correctly. So we can’t help you.
1 Like