This seems like it should be easy, but I'm struggling to find the documentation to support how to do it.
I added a couple of virtual switches, and then rule machine sends HTTP post commands to my AVR receiver to turn it on/off.
I've build a custom app to query the AVR receiver to determine the current power status, and I'd like to do a simple "set device ID on/off" so I can sync Hubitat to the AVR status. Is there a command that does this that I cannot find? In a convoluted way, I could set a Boolean and then grab that in RM with an another rule, but that is just messy. I'd just like to control the device directly.
Am I missing something, or is this not possible?
Assuming your App declares capability "Switch", you can simply do a
sendEvent(name: "switch", value: "on")
Maybe take look at this Roku TV App for example code of how an App can set the device state.
I see what you are saying. The proper solution for this problem is to build up a dedicated device driver, and then it would just work without the gymnastics (will do that tonight).
Going back to my original issue, the "Switch" capability can only be in a device driver not an app driver. Is there something similar that I could have one app trigger devices? Say if I wanted to build an app that blinked the kids lights until they went insane, is that possible from the app code area?
In short, provide a way to select a device in your app. This would be done with
input, as I'm guessing you have done already for something else in your app. You can just call
on() on any such device (including a collection of devices) to manipulate its switch state if it supports this command. The fact that it's virtual doesn't matter; you just can only manipulate devices that the user (you in this case) has selected via the UI.
However, it might be helpful to see the bigger picture. What do you have a set up so far, exactly? Is it sure that changing this switch state won't trigger some other automation?
Ok, I see what you are saying. Turns out just doing a proper driver that just fixes the problem takes 1/2 hour, scraping the internet and GitHub for suggestions eats many hours, and didn't get me an answer.
Thanks for the insight though, works perfectly now.