I tried to find the answer to this but had no success: My goal: when the user tries to open or close a shade, I first check if the window is open. If it is, I don't open/close the shade. Giving an alert instead.
**Devices involved: **
-Smart shade
-Virtual device (if thats the only way to solve the problem).
-Echo (the user will operate the shade by voice via Alexa)
Imagine I have a RM that triggers when my virtual switch is pressed.
-One of the rules of that RM is that, in certain conditions, I will revert the state of that device. So if the switch was turned on, I might want to send an alert and revert that back to off.
Question: will my last action inside the RM above triger a device event for the switch? Because if so I will be stuck in a loop.
What is my scenario:
-I have a smart shade that rolls down and I tell it to close. However, if the window is open when I do that command the shade will be jammed. So what I am doing is that I am creating a virtual device for the curtain and I control it through that. This way, when I try to close I can first check if the window is open (contact sensor) and if so, I trigger an warning in my Alexa and don't close it. However, in this scenario I need to revert back the state of the virtual shade so that it stays aligned with the real shade.
If you have a more elegant solution to this, please let me know.
It would be helpful to see what you currently are using for the rule. Is the smart shade being controlled by HE, Alexa or.... It sounds like you create a virtual device which is triggering an Alexa routine to control the shade?
Edit - Also how are you getting alerts to Alexa, a routine as well?
Quick rule idea;
Required Expression - Window is open
Trigger - Shade Vitual switch close (could also use only if window is open instead of Required expression)
Action (this is where understanding how the actual smart shade is being contolled and how you are getting the alert)
If it was all controled via HE you could use
Shade Virutal switch open
Notify - Window open
Wait for event window closed - close shade -delay xx seconds so it doesn't close on you while you lock the window
Tks for the quick replies. I updated my post with additional details.
I made a test and can already confirm that what I feared is true: the app I tried to implement gets stuck in a loop, because:
-The trigger is when my "virtual shade" device changes state (regardless of opening or closing)
-Then, if the window is open, I send a voice alert via Alexa and reset the Virtual shade state. The real shade hasn't changed.
-The problem here is that, as I update the state of my virtual shade, I trigger again the same Rule, thus creating the loop.
I believe the best way to handle this is instead of a virtual shade I create two virtual buttons, when for opening and closing, then making Alexa press the respective button when the user asks to open or close the shade. This way I will to fall into a loop because I don't need to reset the state of the buttons. But that's an ugly fix: I'll need a routine with Alexa to interpret the command and press the button and Alexa won't be able to know if the shade is open or not (because it will not see a virtual shade, just two stateless buttons).
I use an Hubitat app named Echo speaks for that. Then I have a device in Hubitat that represents my echo dot and I can instruct say something.
For the rest, pls read my previous comment above.
Is there a device for the shade that HE controls directly or is the shade being controlled by Alexa via the virtual switch in HE? Curious what brand is the shade
If you don't use change and do what I have above the virtual switch will change back to open which will also be the same as the shade. If you remove the wait to close than you will simply retrigger the virtual switch to close and the blind will also be closed.
It will only get trigged IF the window is open.
Have you thought about using a virtual shade device, and sharing that with Alexa? That would be the shade Alexa thinks is the real shade for voice commands. Remove the real shade device from Alexa.
Then made a rule triggered by the virtual shade changing, and in that rule check the contact sensor for the window. If the contact is open, don't command the real shade device to do what was triggered in the virtual device, but if the window is closed, pass that command along to the real shades.
Start by creating 2 individual rules. One for closing the blinds, and another for opening the blinds.
Create 2 virtual switches. Set them to automatically turn off 1 second after being operated. These are the switches that will be controlled with Alexa voice commands.
So when you say Alexa "close the blind", the "Blind Down" VS will turn on for 1 second, which will trigger the rule. The VS will automatically turn off in 1 second, making it ready to accept the next voice command.
That's the solution I end up going for. My initial plan was using buttons instead of switches but then Alexa doesn't recognise buttons. As I mentioned in my latest comment above, any implementation with one single Virtual device triggers a loop as I deny the opening / closing of the shade and revert the virtual device state (because that triggers the rule).
Thanks for the contributions!
It is a pity we can't set for a rule to not trigger events of the devices it operates... although I imagine this could open a pandora box of issues.