Are APIs available to Custom App Developers for leveraging Rooms and the Devices therein?

How do you select rooms in the app?

Here is a code snippet to selecting rooms.

/*
 * I have not found an `import com.hubitat.app.x for a RoomWrapper
 * or RoomWrapperList type. ArrayList<LinkedHashMap> works for now.
 */
ArrayList<LinkedHashMap> rooms = app.getRooms() 

// Process the results to generate a room picklist.
List<Map<Integer, String>> roomPicklist = rooms.sort{it.name}.collect{[(it.id): it.name]}

input(
  name: 'roomId',
  type: 'enum',
  title: 'Select one room',
  submitOnChange: true,
  required: true,
  multiple: false,
  options: roomPicklist
)

As @garyjmilne notes, the resulting room information is of limited immediate use today.

For "security reasons", Hubitat does not expose the Hub's devices to our custom apps in a convenient way. Our custom apps only gain access to devices via input(...) directives.

Clients - by selecting presented devices - are in affect "authorizing" our custom apps access to a subset of their (private) devices.

Currently, the input(...) facility lacks filtering. There is no way to pass in a closure that narrows the choices presented to a client.

  • A closure could facilitate robust filtering - e.g., narrow the devices presented to a client based on the enclosing room, a substring that occurs in the device's type, etc.

We can ask a client to select ALL of the devices our app might need (irrespective of room). Our application can process the resulting DeviceWrapperList parsing the DeviceWrapper instances using device methods - e.g., getRoomId(), getRoomName().

  • Currently, there is no way for a client to "select all" when using input(...) which is a significant inconvenience if they need to "authorize" a lot of devices.

As @tomw illustrates with his sample code (below), screen-scraping Hubitat's UI works assuming you hold the credentials on the target hub and the screens are stable across releases.

Added this Feature Request

4 Likes