I'm quite familiar with sending data between parent/child drivers, child drivers and parent apps, etc. What I want to do is send events from one driver to another.
sendEvent()
has a method at the app level that lets me call it like sendEvent(dni, [map event])
.
This lets me raise events on any device from an app that knows the DNI. That's well and good and all, but I would like to see this exact same thing available at the driver level.
Right now I have some drivers set up with a super convoluted system where the driver raises a location event, there's a 'helper app' that subscribes to location events, then uses sendEvent(dni, [map event])
to send events to NON-child devices.
Related, I would like to have subscribe()
available at the driver level as well.
Ideally I would be able to do something like this in one driver:
On the receiving side do something like subscribe(DeviceEvent event, String attributeName, handlerMethod, Map options = null)
and NOT have to use Location events. These spam the Location events tab in logs... raising a bunch of them causes a lot of clutter. Having something other than Location would be good.
Then on the sending side, I could just do something like sendDeviceEvent(DeviceEvent event, 'myEvent', [data: [myData: 'stuffHere']])
Basically I want a way to raise a hub-wide event in one driver and subscribe to it in another. Passing everything thought parent-child app-driver works fine for parent app with child drivers, but Hubitat would greatly benefit from being able to have drivers subscribe to "driver event streams" and not need parent apps just to act like intermediary. Requiring a parent app means you cant' add driver-to-driver communication to pre-existing drivers. They would need to be deleted and re-created as children under the app since there's also no form of 'adopt' available to a parent app.
Why do I want this feature? First, my Sonos Advanced app gets a bunch of state on the "primary/coordinator" speaker device that needs sent to the "follower" devices. Right now I'm using a pretty silly system of @Field
objects to get DeviceWrapper handles in one driver so I can access commands on the other. Being able to just raise an event that would cause the followers to perform action would simplify this a good bit.
Secondly I'm working on the Hubitat drivers for Shelly devices. They have Bluetooth Gateway functionality on their devices, and they have some BLE devices that can send events, via any device with BLE Gateway functionality, to hubitat. Right now I'm using/abusing Location events to get the events coming in via the BLE Gateway on one device over to the other, and it requires a 'helper app' that exists solely to subscribe to Location events and send out events via sendEvent(dni, [map event])
. Being able to do this device to device would GREATLY simplify this setup and allow MUCH better integration of the line of BLE devices from Shelly.