michielpost / Q42.HueApi

C# helper library to talk to the Philips Hue bridge
MIT License
412 stars 114 forks source link

Add sensor inputs #217

Closed ChristopherHaws closed 4 years ago

ChristopherHaws commented 4 years ago

This PR add support for retrieving the sensor input details. This allows you to get info such as button event ID's which is helpful when creating rules for those sensors. Here is an example of a device with inputs:

{
  "1": {
    "state": {
      "buttonevent": 1002,
      "lastupdated": "2020-03-15T16:18:10"
    },
    "swupdate": {
      "state": "noupdates",
      "lastinstall": "2019-10-15T09:42:32"
    },
    "config": {
      "on": true,
      "battery": 80,
      "reachable": true,
      "pending": []
    },
    "name": "Master Bedroom Dimmer Switch",
    "type": "ZLLSwitch",
    "modelid": "RWL020",
    "manufacturername": "Signify Netherlands B.V.",
    "productname": "Hue dimmer switch",
    "diversityid": "73bbabea-3420-499a-9856-46bf437e119b",
    "swversion": "6.1.1.28573",
    "uniqueid": "00:17:88:01:02:1a:a4:73-02-fc00",
    "capabilities": {
      "certified": true,
      "primary": true,
      "inputs": [
        {
          "repeatintervals": [
            800
          ],
          "events": [
            {
              "buttonevent": 1000,
              "eventtype": "initial_press"
            },
            {
              "buttonevent": 1001,
              "eventtype": "repeat"
            },
            {
              "buttonevent": 1002,
              "eventtype": "short_release"
            },
            {
              "buttonevent": 1003,
              "eventtype": "long_release"
            }
          ]
        },
        {
          "repeatintervals": [
            800
          ],
          "events": [
            {
              "buttonevent": 2000,
              "eventtype": "initial_press"
            },
            {
              "buttonevent": 2001,
              "eventtype": "repeat"
            },
            {
              "buttonevent": 2002,
              "eventtype": "short_release"
            },
            {
              "buttonevent": 2003,
              "eventtype": "long_release"
            }
          ]
        },
        {
          "repeatintervals": [
            800
          ],
          "events": [
            {
              "buttonevent": 3000,
              "eventtype": "initial_press"
            },
            {
              "buttonevent": 3001,
              "eventtype": "repeat"
            },
            {
              "buttonevent": 3002,
              "eventtype": "short_release"
            },
            {
              "buttonevent": 3003,
              "eventtype": "long_release"
            }
          ]
        },
        {
          "repeatintervals": [
            800
          ],
          "events": [
            {
              "buttonevent": 4000,
              "eventtype": "initial_press"
            },
            {
              "buttonevent": 4001,
              "eventtype": "repeat"
            },
            {
              "buttonevent": 4002,
              "eventtype": "short_release"
            },
            {
              "buttonevent": 4003,
              "eventtype": "long_release"
            }
          ]
        }
      ]
    }
  }
}
michielpost commented 4 years ago

Thanks a lot for the PR! I'm unable to test this because I don't have any sensors. But the properties are optional, so it probably won't break anything. Can you provide some info what this PR adds?

ChristopherHaws commented 4 years ago

@michielpost I updated the PR with details and an example JSON response from the sensor endpoint. Thanks!

michielpost commented 4 years ago

Thanks, it's included in version 3.15.2 that's now on NuGet