I do not want to double post, but I am opening this thread due to I think my problem is vice versa from the one I replied on earlier.
The problem described there:
Hi, I am having problems to understand. It might be due to the fact I am half ways understanding…
I have a gate. I have a sensor on the gate. I want the gate to be presented as a lock.
Gate binary sensor:
binary_sensor.gate_sensor_956
I have in configuration.yaml:
lock:
- platform: template
name: Gate
value_template: "{{ is_state('binary_sensor.gate_sensor_956', 'off') }}"
lock:
service: switch.turn_off
data:
entity_id: switch.virtual_vswitch_6
unlock:
service: switch.turn_on
data:
entity_id: switch.virtual_vswitch_6
The virtual switch:
switch:
- platform: virtual
name: vSwitch_6
I created the virtual switch to give an on and off state.
on=closed
off=open
I use it in node red:
(2× flows right to the delay of 20s is to ensure the hate closes if the first one fails)
But a lot of time the lock/unlock does not work…
the gate is controlled via a momentary switch which I “call” in node-red on-off for 2 secs opens or closes it.
Where am I thinking wrongly?
Edit:
Sometimes it just “hangs” and lock/unlock just doesn’t work until I restart homeassistant.
When I use the “vswitch 6” I can correctly control the gate (open / close).
OTHER WORDS:
I want to achieve to just use a “normal” lock in home assistant via a template. Which works 3 out of 5 times correctly.
But I was not able to use the lock state in node red so I created a virtual switch (used by the lock). That virtual switch controls a node red flow to lock or unlock the gate by means of sending pulses (2sec on-off) and then check if the gate is locked or not.
Hope I am clear :-).
But sometimes it just doesn’t respond to lock or unlock…
I am absolutely a noob on templates but I think that is where the source of my problem lies…
If I try:
lock:
- platform: template
name: Tuin Voor Poort
#value_template: "{{ is_state('binary_sensor.tuin_v_poort_sensor_956', 'off') }}"
value_template: "{{ is_state('binary_sensor.tuin_v_poort_sensor_956') }}"
lock:
service: switch.turn_off
data:
entity_id: switch.virtual_vswitch_6
unlock:
service: switch.turn_on
data:
entity_id: switch.virtual_vswitch_6
I get:
a greyed out “lock” button.
and the lock entity is unavailable (as described in the template documentation).
Edit:
if is is non-responding and after restarting home assistant all works well until… something happens and it goes wrong (but i cannot find out what).