Send Push Notification from Driver to Mobile App Device

I am writing my first driver, and want to send push notifications to devices registered with the mobile app.

I can see my Mobile App Device in Devices, and can send notifications via this to the mobile phone without any issue.

Having read the thread below, I was under the impression I could just use an input in my driver preferences to provide a list of devices with the notification capability and then push a message to those selected.

how-to-send-notifications-to-the-new-mobile-app

input "notificationDevice", type: "capability.notification", title: "Notification Devices:", multiple: true, required: false 

if (notificationDevice) notificationDevice.deviceNotification("message")

Using the above, I see nothing listed for notification devices in my driver preferences, only an empty text box.

image

In contrast, the device appears in Rule Machine:

image

Perhaps I've got this all wrong. Any assistance gratefully received!

Cheers

Perhaps that is a difference between drivers and apps.

It seems this can't be done in a driver, only in an app, probably due to security:

https://community.hubitat.com/t/device-selector-input-preference-in-device-driver/19323

If anyone can suggest a workaround or best-practice, I'd be grateful,

It seems like an obvious requirement, so I'm sure I'm missing something.

I essentially just want to send a push notification to selected mobile devices when a custom attribute in the driver is true.

You need an app to subscribe to events in your driver

1 Like

As @mark.cockcroft stated, only an App can subscribe events from one device and then execute a command in another device. Rule Machine can handle this for you.

As @mark.cockcroft stated, only an App can subscribe events from one device and then execute a command in another device. Rule Machine can handle this for you.

Thanks.

Is this something that is core to the way Hubitat functions, or are you aware of any plans to perhaps at least allow notifications to be sent from drivers in the future?. Apologies if you can't answer this question - your Ambassador handle implies you might have some insider info.

Yes, this is a core design element of the Hubitat architecture. Drivers are specific to a device and implement standard Capabilities. Apps subscribe to events and execute commands of devices.

While I do not speak for Hubitat, I am about 99% confident that there are no future plans to allow one device to call another device's commands.

Unless of course they have a parent/child relationship. Not applicable to what is trying to be accomplished here but I felt like being contrary today :stuck_out_tongue_winking_eye:

2 Likes