I am having a hard time wrapping my head around setting up a cover template for my simple set of garage doors. I have a single magnetic switch that indicates when the door is closed/open. I have a relay connected to a esp32. the relay needs to cycle for 2 seconds (about) to tell the door motor. What entries in this code do I change to my devices/switches/entities?
what do you mean ‘cycle for 2 seconds’? You mean it needs to be on for 2 seconds? Regardless of that, the posted solution should work accept you’d change the value_template to point to your magnetic sensor, not the switch.
Thanks petro
Yes the relay needs to go on for 2 seconds then back off. I get confused sometimes with the code. I will change the value_template to my magnetic sensor
Is it possible to have different platform for sensor and switch in a cover template ? i.e. my sensor is rest based, but switch is mqtt. Here is my sensor
Above sensor works and I can see correct status (though scan interval is 60 seconds, I manually refresh and see correct status when calling any actions.)
I confirmed that I can open and close garage door using above mqtt switch too.
However when I try to incorporate both in a cover then I can see status but opening/closing doesn’t work
I’m connecting Uni to my “dumb” gate right now (one button open/close/stop). I have magnetic sensors attached, so I know if the gate is opened or closed. I’m also building a circuit to read ADC input using a rotary potentiometer.
How do you read the value of ADC and how are you changing it to text?
In my case, I’ll have a value in the range of 2-20V.
Sadly the value “jumps” (see the image below), so I’m not sure if I’ll be able to calculate the position using it.
How do you solve the issue with actions? In my case, if I press the button to open the gate, stop it, and want to open it more, then I must press once (close), do a second press (stop) and the third press will open the gate. So the action is dependent on the previous state and I must wait at least a second between button presses.
Test with a multimeter to see if the issue is in the pot output or the ADC on the Uni. Replacing the pot with something else might be the solution.
You don’t - and can’t. You’d have to make your own controller for the gate - if all you can do is activate one button on the original controller, you’ll have to live with the limitations you’ve seen.
I finally started working on refining my garage door setup and move it from a Homekit stop gap to HA and found this thread. This is the first time I work with template switches or covers and I am also new to Jinja2 in general. I currently use a Zigbee wall light switch to control a relay and I have a Fibaro Homekit door sensor that is now directly connected to HA as a sensor.
The basics:
Challenge 1:
HA only knows my switch as a light switch as it comes in via the Hue integration. I need to turn it into a normal switch (or cover?). I like to handle this within the same (cover ?) template.
Challenge 2:
It needs to turn on for 2 secs for both open and close operations. If it stays on, it ca’t trigger the alternative action. I have no idea how to incorporate this 2 S wait followed by turning. off into the same operation.
Nice-to-haves:
Challenge 3:
As the sensor will only know the closed state when the door movement has completed, it would be great to have a state of ‘moving’ that begins with the switch pulse for closing and ends with the sensor reporting closed. When opening, the move state could be a fixed time after the open command.
Challenge 4:
Ideally, I like to have the option to also stop the door. This would be just another 2sec pulse when the door is ‘moving’.
I hope you can help me. All I managed so far is this and the switch is unavailable:
Update: I tried to ask ChatGPT for the code and even though it suggested a template switch at first that wasn’t as useful as a template cover, it provided me with 90% of what I needed to get 1., 2. and 4. done by using scripts to incorporate the delay.
I feel your pain @holger
I use raspberry pi for HA and garage door, so code will differ.
A mqtt garage door switch command topic uses set_on_ms instead of set. The payload_on can then be set to time in milliseconds.
Two position sensors (reed switch) let me me know open or closed.
I use the cover to get state from the template and perform an action.
The template defines the door position at any given moment.
I love watching people solve problems that have already been solved multiple times with minimal easy-to obtain and cheap hardware. It reaffirms my belief that sometimes, even in Home Automation, it’s about the journey, not the destination.
Of course they can. I just meant that there are multiple super cheap solutions, including ready-made, to solve the hardware issue, and YAML posted multiple times that’s well-proven to work.
Yet people are still trying to do something different to accomplish less. I really don’t get it - banging my head against the wall isn’t fun.