I’ve just built a solenoid controlled cat door with two solenoids connected to an Electrodragon WiFi relay. The board is running Tasmota and I’ve configure a RGB LED on additional GPIO’s and set these up as additional relays in Tasmota. The LED’s will report the state of the door.
One solenoid locks the door so the cats can only come in, not out. The 2nd solenoid locks the cat door permanently so they can’t go in or out. A simple schedule will unlock both solenoids in the morning.
I want to voice control the cat door by asking Google to lock the door when the first cat comes in but only have it latch the 1st solenoid. When we ask to lock the door again, it checks if the first solenoid is on and if so, latches the 2nd solenoid. Additionally, it’d be nice to know the status of the lock when asked; reporting single or double lock mode.
I could just call them two different locks but I’m trying to up the WAF by making it easier to use. Once complete, I’ll upload a video to my YouTube channel.
Here is where I’ve got to but a bit stuck in regards to how to turn this into a final script.
{%- if states.switch.cat_door_half_lock.state == 'off' and states.switch.cat_door_full_lock.state == 'off' %}
script.half_lock
{%- elif states.switch.cat_door_half_lock.state == 'on' and states.switch.cat_door_full_lock.state == 'off' %}
script.full_lock
{% endif %}
What I’d like to do is call a single script (via Google) called Lock Cat Door and it then use the service template defined above (if correct) to do the following;
If both switches are off, activate switch one.
If switch one is on and switch two is off, activate switch two
If switch one and two are on, end the script (do nothing).
your template looks correct but i’d use is_state('switch.cat_door_half_lock','on'), and you’ll need a condition before this service template that makes sure that full lock is off.
Thank you for your input, much appreciated. Here is what I have.
script:
lock_cat_door:
alias: Lock Cat Door
sequence:
service: script.turn_on
data_template:
entity_id: >
{% if is_state('lock.cat_door_half_lock','unlocked') and is_state('lock.cat_door_full_lock','unlocked') %}
script.half_lock
{%- elif is_state('lock.cat_door_half_lock','locked') and is_state('lock.cat_door_full_lock','unlocked') %}
script.full_lock
{% endif %}
Can you advise if it’s possible to fire multiple services where I have the two scripts? I have a tri-colour LED that shows the door state controlled by three relays, one for green, red and blue.
So when both locks are unlocked, LED is green. Half lock; green LED off, blue LED on. Full lock; green LED off, Blue LED off, Red LED on. Can I execute more that one script when the statement is true?