Hi,
Firstly I’m pretty new to Home Assistant so please bear with me!
I’ve got a Velux skylight (Velux gateway HomeKit device) that seems to be based around the “cover” building block.
This obviously allows me to open and close the skylight but also, when in the open state to specify a position (100 = fully open). I believe the skylight supports the concept of a semi-locked “trickle vent” position where the state of the skylight is still open but its position is basically less than about 8 (it’s “open” but closed in appearance).
I want to have an on/off switch that can be used to toggle between fully open and the trickle vent position.
I’ve probably gone down a rabbit hole but I’ve managed to do this using a template switch, as per below:
This seems to work, but… (presumably because it takes some time for the window to move to the new position) … the button - correctly I guess - takes a while to reflect the new state… I can this that this is correct - but it’s not want I want. I want the button - once pressed - to reflect the outcome that will be achieved once the operation completes.
Have I massively over-engineered this (and made it problematic along the way)? Is there a simpler way of achieving what I’m after? My head has started to hurt!
Hi Tom
Thanks very much - I made some tweaks (including the 0 < position <=8 to become 8 < position <-100 and increasing the delay) but that pretty much did the trick.
To confirm my understanding, basically the delay is preventing the template switch from being refreshed? And then once the delay is over, giving home assistant a kick to make sure that it does then get refreshed?
This highlights some “interesting” behaviours on my dashboard though… I’ve an Entities Card showing the switch with “Show state colour” enabled. The switch changes state as I click on it but the colour doesn’t (until later). So I’m guessing the colour is derived from the value_template value (which hasn’t been refreshed due to the needed delay) rather than the position of the switch in the GUI? Which is a shame as I’d like them to be in synch…
Which makes me wonder whether I’m trying to solve this in the wrong way?.. I think I’m after a custom switch that is simply toggled by someone pressing it - so its state is being handled properly?.. But it is also dynamically updated - if someone hasn’t pressed it for say a minute - by the current position of the window? Does that make sense? …and if so, any idea how I might achieve this?
That is what my value template tests for. Yours tests for above 8, i.e. not in the “trickle” position. Your switch will be shown as on when the window is fully open.
Yes the delay gives the window a bit of time to move and then refreshes the state updating the value template.