Hue Binding – Hue routines as Thing

Use case : In the Philips Hue smartphone app (implemented by Signify) you can define Hue routines for “Wake up”, “Go to sleep” and “Other routines” for time control of lights. In the Philips Hue app you can “enable” and “disable” each routine separately with a switch, which means it will run or not run. With OH I just want to control this switch.

Basics : For each scheduled routine in Philips Hue app a schedule is created within the Hue Bridge, that can be found using the Philips Hue CLIP API Debugger. Setting the status of the schedule to “enabled” or “disabled” sets the associated Hue routine to the corresponding status.

JSON example of a schedule (with Flag Sensor):
GET https:///api/${username}/schedules/1

{
   "name": "Routine 1",
   "description": "MyRoutine",
   "command": {
      "address": "/api/${username/sensors/1/state",
      "body": {
        "flag": true
      },
      "method": "PUT"
   },
   "localtime": "W001/T21:00:00",
   "time": "W001/T20:00:00",
   "created": "2021-02-14T14:09:48",
   "status": "enabled",
   "recycle": true
}

The status “enabled” is the relevant parameter that assures the Hue routine will run.

My request: Please provide Hue routines as things with the status channel as explained above. Currently only CLIP Generic Status Sensors and CLIP Generic Flag Sensors are supported within the Hue Binding (see 2.5.x Hue Binding documentation). These two sensors just tell if a Hue routine is running at the moment (=true) or not (=false).

Depending on the type of the Hue routine “CLIPGenericStatus” or “CLIPGenericFlag” the Hue bridge differentiate between CLIP Generic Status Sensor and CLIP Generic Flag Sensor. The type of the Hue routine schedule can be derived from the command body (status or flag) which should also be reflected in the thing for the Hue routine.

JSON example of a schedule (with Status Sensor):
GET https:///api/ ${username}/schedules/2

{
   "name": "Routine 2",
   "description": "MyRoutine",
   "command": {
      "address": "/api/${username /sensors/2/state",
      "body": {
         "status": 1
      },
      "method": "PUT"
   },
   "localtime": "W001/T11:00:00",
   "time": "W001/T10:00:00",
   "created": "2021-01-23T16:56:15",
   "status": "disabled",
   "recycle": true
}

When searching for schedules on the Hue bridge maybe filter out schedules which were auto-generated by Philips Hue App. This schedules can be detected via “command”: {“address”: "/api/0/*” …} to not get many new things in the inbox.

In addition I suggest putting currently existing Sensor channels (Flag in case of Flag Sensor, Status in case of Status Sensor) and the Last_updated channel to the new Hue Routine thing.

References:
Hue Binding: Routines and CLIP Generic Flag Sensor
Hue Binding: What is a CLIP Generic Status Sensor?
For an introduction to Hue routines see e.g. How Does The Philips Hue Wake-Up Feature Work?

2 Likes