correl.github.io/_drafts/2018-03-15-hue-sunrise.org
2018-03-14 23:42:58 -04:00

12 KiB

A new Hue Sunrise

Sunrise Start
buvKocMysgD4XgX
Sunrise End
iyEEA2mHdGqkxaE

Initial scene

  {
    "name": "Sunrise start",
    "lights": [
      "2",
      "3",
      "5"
    ],
    "recycle": false,
    "appdata": {
      "version": 1,
      "data": "my-sunrise"
    }
  }
  {
    "on": true,
    "bri": 1,
    "xy": [
      0.6042,
      0.3739
    ]
  }
  {
    "on": true,
    "bri": 1,
    "xy": [
      0.2376,
      0.1186
    ]
  }
  POST http://bridge/api/${username}/scenes
  Content-Type: application/json

  <<sunrise-start>>
[
  {
    "success": {
      "id": "P9VgGRGLBL83Fsm"
    }
  }
]
  PUT http://bridge/api/${username}/scenes/${scene-start}/lightstates/2
  Content-Type: application/json

  <<sun-start>>
[
  {
    "success": {
      "/scenes/P9VgGRGLBL83Fsm/lightstates/2/on": true
    }
  },
  {
    "success": {
      "/scenes/P9VgGRGLBL83Fsm/lightstates/2/bri": 1
    }
  },
  {
    "success": {
      "/scenes/P9VgGRGLBL83Fsm/lightstates/2/xy": [
        0.6042,
        0.3739
      ]
    }
  }
]
  PUT http://bridge/api/${username}/scenes/${scene-start}/lightstates/3
  Content-Type: application/json

  <<wall-start>>
[
  {
    "success": {
      "/scenes/P9VgGRGLBL83Fsm/lightstates/3/on": true
    }
  },
  {
    "success": {
      "/scenes/P9VgGRGLBL83Fsm/lightstates/3/bri": 1
    }
  },
  {
    "success": {
      "/scenes/P9VgGRGLBL83Fsm/lightstates/3/xy": [
        0.2376,
        0.1186
      ]
    }
  }
]
  PUT http://bridge/api/${username}/scenes/${scene-start}/lightstates/5
  Content-Type: application/json

  <<wall-start>>
[
  {
    "success": {
      "/scenes/P9VgGRGLBL83Fsm/lightstates/5/on": true
    }
  },
  {
    "success": {
      "/scenes/P9VgGRGLBL83Fsm/lightstates/5/bri": 1
    }
  },
  {
    "success": {
      "/scenes/P9VgGRGLBL83Fsm/lightstates/5/xy": [
        0.2376,
        0.1186
      ]
    }
  }
]

Final scene

  {
    "name": "Sunrise end",
    "lights": [
      "2",
      "3",
      "5"
    ],
    "recycle": false,
    "appdata": {
      "version": 1,
      "data": "my-sunrise"
    }
  }
  {
    "on": true,
    "transitiontime": 17400,
    "bri": 254,
    "xy": [
      0.3769,
      0.3639
    ]
  }
  {
    "on": true,
    "transitiontime": 17400,
    "bri": 203,
    "xy": [
      0.2698,
      0.295
    ]
  }
  POST http://bridge/api/${username}/scenes
  Content-Type: application/json

  <<sunrise-end>>
[
  {
    "success": {
      "id": "NHBj78VkoJAWjd-"
    }
  }
]
  PUT http://bridge/api/${username}/scenes/${scene-end}/lightstates/2
  Content-Type: application/json

  <<sun-end>>
[
  {
    "success": {
      "/scenes/NHBj78VkoJAWjd-/lightstates/2/on": true
    }
  },
  {
    "success": {
      "/scenes/NHBj78VkoJAWjd-/lightstates/2/bri": 254
    }
  },
  {
    "success": {
      "/scenes/NHBj78VkoJAWjd-/lightstates/2/xy": [
        0.3769,
        0.3639
      ]
    }
  },
  {
    "success": {
      "/scenes/NHBj78VkoJAWjd-/lightstates/2/transitiontime": 17400
    }
  }
]
  PUT http://bridge/api/${username}/scenes/${scene-end}/lightstates/3
  Content-Type: application/json

  <<wall-end>>
[
  {
    "success": {
      "/scenes/NHBj78VkoJAWjd-/lightstates/3/on": true
    }
  },
  {
    "success": {
      "/scenes/NHBj78VkoJAWjd-/lightstates/3/bri": 203
    }
  },
  {
    "success": {
      "/scenes/NHBj78VkoJAWjd-/lightstates/3/xy": [
        0.2698,
        0.295
      ]
    }
  },
  {
    "success": {
      "/scenes/NHBj78VkoJAWjd-/lightstates/3/transitiontime": 17400
    }
  }
]
  PUT http://bridge/api/${username}/scenes/${scene-end}/lightstates/5
  Content-Type: application/json

  <<wall-end>>
[
  {
    "success": {
      "/scenes/NHBj78VkoJAWjd-/lightstates/5/on": true
    }
  },
  {
    "success": {
      "/scenes/NHBj78VkoJAWjd-/lightstates/5/bri": 203
    }
  },
  {
    "success": {
      "/scenes/NHBj78VkoJAWjd-/lightstates/5/xy": [
        0.2698,
        0.295
      ]
    }
  },
  {
    "success": {
      "/scenes/NHBj78VkoJAWjd-/lightstates/5/transitiontime": 17400
    }
  }
]

Sensor

  {
    "name": "My Sunrise Sensor",
    "modelid": "my-sunrise",
    "swversion": "1.0",
    "type": "CLIPGenericFlag",
    "uniqueid": "my-sunrise-1",
    "manufacturername": "my-sunrise",
    "state": {
      "flag": false
    },
    "config": {
      "on": true,
      "reachable": true
    }
  }
  POST http://bridge/api/${username}/sensors
  Content-Type: application/json

  <<sensor>>
[
  {
    "success": {
      "id": "6"
    }
  }
]

Schedules

  {
    "name": "my-sunrise-transition",
    "description": "Trigger sunrise end scene",
    "command": {
      "address": "/api/uCpPPhYlWIJdOvGuyrsM2EtmaeiVvcTX0WEdAn0P/groups/0/action",
      "body": {
        "scene": "NHBj78VkoJAWjd-"
      },
      "method": "PUT"
    },
    "localtime": "PT00:01:00",
    "status": "disabled",
    "autodelete": false
  }
  POST http://bridge/api/${username}/schedules
  Content-Type: application/json

  <<schedule-transition>>
[
  {
    "success": {
      "id": "1"
    }
  }
]

Start

  {
    "name": "my-sunrise-start",
    "description": "Trigger sunrise end scene",
    "command": {
      "address": "/api/uCpPPhYlWIJdOvGuyrsM2EtmaeiVvcTX0WEdAn0P/sensors/6/state",
      "body": {
        "flag": true
      },
      "method": "PUT"
    },
    "localtime": "W124/T06:30:00",
    "status": "enabled"
  }
  POST http://bridge/api/${username}/schedules
  Content-Type: application/json

  <<schedule-start>>
[
  {
    "success": {
      "id": "2"
    }
  }
]

Rules

  {
    "name": "my-sunrise-start",
    "status": "enabled",
    "conditions": [
      {
        "address": "/sensors/6/state/flag",
        "operator": "eq",
        "value": "true"
      }
    ],
    "actions": [
      {
        "address": "/groups/0/action",
        "method": "PUT",
        "body": {
          "scene": "P9VgGRGLBL83Fsm"
        }
      },
      {
        "address": "/schedules/1",
        "method": "PUT",
        "body": {
          "status": "enabled"
        }
      }
    ]
  }
  POST http://bridge/api/${username}/rules
  Content-Type: application/javascript

  <<rule-start>>
[
  {
    "success": {
      "id": "1"
    }
  }
]
  {
    "name": "my-sunrise-turnoff",
    "status": "enabled",
    "conditions": [
      {
        "address": "/sensors/6/state/flag",
        "operator": "eq",
        "value": "true"
      },
      {
        "address": "/sensors/6/state/flag",
        "operator": "ddx",
        "value": "PT02:30:00"
      }
    ],
    "actions": [
      {
        "address": "/groups/2/action",
        "method": "PUT",
        "body": {
          "on": false
        }
      },
      {
        "address": "/sensors/6/state",
        "method": "PUT",
        "body": {
          "flag": false
        }
      }
    ]
  }
  POST http://bridge/api/${username}/rules
  Content-Type: application/javascript

  <<rule-turnoff>>
[
  {
    "success": {
      "id": "2"
    }
  }
]

Actions

  PUT http://bridge/api/${username}/groups/0/action
  Content-Type: application/json

  {"scene": "${scene-start}"}
  PUT http://bridge/api/${username}/groups/0/action
  Content-Type: application/json

  {"scene": "${scene-end}"}
  PUT http://bridge/api/${username}/sensors/6/state
  Content-Type: application/json

  {"flag": true}