Driver and app code examples

Or a custom app. As mentioned above, the underlying issue is that a driver alone cannot do this (or at least I don't think so...I've never done it...EDIT: forgot that a driver can, but only on a specific port so probably not as useful unless you have control over the other end).

This is basically what HubConnect does if you use HTTP, but it's not exactly a minimal example app (and you can't reuse its code as licensed, but it may be a good reference).

A driver can listen for http requests. If device DNI needs to be set to the MAC address of the remote device and the calls are made to port http://hubip:39501, Hubitat will call parse() with the contents of the request.

The easiest approach is to create an oAuth-enabled app that will allow you to define endpoints that are mapped to functions within your app.

Have a look at the Remote Client code, it should provide some guidance on how Hubitat allows for http endpoint calls. There are probably simpler examples around here, I just can't think of any at the moment.

1 Like

Thanks, maker API worked, can send command to virtual switch - by calling URL, no coding needed!

Looking at some examples, I don't see any uninstalled() code, what happens to event subscriptions when the user decides to delete the app? Is that all handled for us? Can it be overridden?

1 Like

This may be a repeat, but take a look at bptworld/Hubitat: Apps for use with Hubitat Elevation (github.com)

yes, child apps, child devices, events, subscriptions, scheduled tasks and anything else associated with the app instance are removed.

4 Likes