No doubt, what follows is a noob question...
I'm attempting to write a small driver/app combo for a REST API. For the life of me, I cannot discern how/when the relationship between the driver and the app is established.
How does the driver know which app is the parent app?
Thanks
Initially it doesn't. Apps allow the selection of devices and then subscribe to Events. The Driver communicates with the device and applies the information as Events.
An App has an Input, which is often a list of devices that have a certain capability. After being selected, the App subscribes to Attributes of the device. SO, for example, a Zwave Switch... the driver sends config specifics to the device over Z-Wave and will get a response, either directly from a command, or unsolicited. The Driver parses that and the result is an Event is posted. An App, subscribing to the switch attribute of a device will 'spring to life' as a result of the specifics of an Event.
1 Like
There is also the concept of a parent app (I believe) being the app that created a device, such as a virtual switch, for example.
If you are creating an App/Driver integration though, the app itself would create the devices. Then there is a parent/child relationship between them as @sburke781 mentioned.
I assume you want to use the app for setting things up and then have the app create multiple child devices based on what is discovered via the API?
Some good examples would be CoCoHue or the old community Kasa Integration. If you need to see how they are doing it within the app and driver code.
1 Like
I might also suggest:
To re-iterate the above, no device has a parent app or device unless it was created that way -- that way being the addChildDevice()
method in whatever you want the parent to be.
1 Like
Thank you all for your time and consideration in responding.
I'm having trouble fitting my scenario into the (typical?) driver/app paradigm as I understand it. Basically, I need this API device (which is my car via SmartcarAPI) to simply provide information when I ask it; and to perform some actions when I tell it. Pretty linear.
Having given it a little more thought, I'm going to pursue a solution with Rule Machine and HTTP calls and see where that gets me.
Thanks again.
That sounds like the perfect role for a driver, with or without a parent app (possibly with if you have something a driver can't do, want a better UI to set things up, or have other reasons for preferring this setup.) So, without more information, it's hard to say where you're getting stuck or why.
That being said, if you're able to just bang against the API with a Rule yourself and not have to write a driver (or app), that certainly works too!
1 Like