eldad007
(Eldad El-Yashiv)
October 18, 2021, 5:03am
1
Hi
I have a GPIO switch that open the gate of my house. I want to set it as a lock.
Usually I use the homekit to control my home.
I saw the Lock Template in home assistant examples, but I didn’t succeed it.
This is my code:
switch:
- platform: rpi_gpio
ports:
18: relay1
23: relay2
24: relay3
25: relay4
lock:
- platform: template
name: Gate
value_template: "{{ is_state('switch.relay4', 'on')}}"
lock:
service: switch.turn_off
target:
entity_id: switch.relay4
unlock:
service: switch.turn_on
target:
entity_id: switch.relay4
I can’t see the Gate as a lock in home assistant and can’t see it in home kit.
HELP?
tom_l
October 18, 2021, 6:28am
2
eldad007
(Eldad El-Yashiv)
October 18, 2021, 6:42am
3
Can’t understand how to do this 3 dots
‘’’
Using iPhone
did it - using Mac
1 Like
tom_l
October 18, 2021, 8:49am
4
Great! That makes it a lot clearer that your lock indentation is slightly off. Should be:
lock:
- platform: template
name: Gate
value_template: "{{ is_state('switch.relay4', 'on')}}"
lock:
service: switch.turn_off
target:
entity_id: switch.relay4
unlock:
service: switch.turn_on
target:
entity_id: switch.relay4
Other that that I can’t see any issues with what you have.
eldad007
(Eldad El-Yashiv)
October 18, 2021, 9:09am
5
I can’t see the different between my code and yours
tom_l
October 18, 2021, 9:49am
6
Look at the indentation highlighted in red. Yours:
Mine:
Also I just noticed there are quite a few trailing spaces (dots at the end of the lines). They won’t hurt but are not good practice.
eldad007
(Eldad El-Yashiv)
October 18, 2021, 10:59am
7
Those dots are the copy paste issues.
I repaired the code as you described- it’s still ain’t working