Hi
I have a switch.garageporten that I toggle the garagedoor with. But it is “dumb” and only sends a pulse to toggle the garagedoor motor. In order to keep track of if the garagedoor is open I have a magnetic sensor (binary_sensor.garageporten).
I have made a template switch to have different icons depending on the state. But how can I also have the garegedoor status (Open/Closed) written out? Now the state is only “on” when I click the switch and then immediately goes “off”.
Been struggeling way too long with this so all help is appreciated
Those two together are confusing… does switch.garageporten send a pulse on both events, i.e. when it is turned “on” and “off”? Based on the History screenshot in the first post, it appears that switch.garageporten is turning “on” then “off” immediately.
Yes (if I understand your question). switch.garageporten turns “on” whenever the switch is triggered. The state turns on for a second and then back to off. So it is basically only on when there is a pulse sent.
What I would like to get out of it, as described in my first post, is that the state of the template switch is “Open” or “Closed” since that would add more meaning in Lovelace.
Then you want to use the binary_sensor as the main state. But the state will lag your button presses because the state only updates when the binary sensor updates. This is very apparent when it takes ~10 seconds to open/close your garage door. But if you’re patient, the state will update on the switch/cover.
But then the state is only “on” when I send the pulse to open/close. I think I will have to stick with one switch template for the icon and the toggle functionality, and then try to incoroprate the binary sensor in the code for the status of the garagedoor (open/closed).
Then it doesn’t make sense that it doesn’t work when you change the value_template.
Have you looked in your logs for errors? Can you share a video of you using the entity in the frontend with the value_template pointing at the binary sensor?
I don’t think you understood the question, but you have provided an answer…
This is a problem:
If the switch turns “on” then immediately “off”, then the action you have assigned for turn_off will never do anything. For the template switch to effectuate a change in the actual garage door both of those actions need to be switch.turn_on.
Part of the reason you are lost is that you are using entities outside their type… you’ve got a switch that should be a button that you’re using to create another switch that should be a cover.
Thank you for your patience
With your help the switch.garageporten_template is now reporting “on” and “off” but I think that is as close as I’ll get, I’ll do some replace actions in frontend to have it show open/closed.
Thanks, but I realized that the switch doesn’t support the device classes that I need so I think it is back to doing it right from the beginning and using cover instead of switch.
Thank you all for your feedback! I went with the template cover and it seems to be working and doing everything that I wanted. Sharing the code in case someone else needs something similar in the future. Icon template isn’t necessary but prefer the wider garage door icon over the standard one.