metbosch / homebridge-http-temperature

HomeBridge HomeKit Plugin for HTTP temperature endpoints
https://www.npmjs.com/package/homebridge-http-temperature
Apache License 2.0
33 stars 18 forks source link

homebridge-http-temperature

Supports http/https devices on HomeBridge Platform. This version only supports temperature sensors returning a JSON with the data or the raw data.

This plug-in acts as an interface between a web endpoint and homebridge only. You will still need some dedicated hardware to expose the web endpoints with the temperature information. In my case, I used an Arduino board with Wifi capabilities.

Installation

  1. Install homebridge using: npm install -g homebridge
  2. Install this plugin using: npm install -g homebridge-http-temperature
  3. Update your configuration file. See sample-config.json in this repository for a sample.

Configuration

The available fields in the config.json file are:

Examples

The following sections provide different configuration examples. For a ready-to-go example, see the sample-config.json file in the git repository.

Minimal HTTP

"accessories": [
  {
    "accessory": "HttpTemperature",
    "name": "Outside Temperature",
    "url": "http://IP/path/to/endpoint"
  }
]

HTTPS + Auth + JSON-field

"accessories": [
  {
    "accessory": "HttpTemperature",
    "name": "Outside Temperature",
    "url": "https://IP/path/to/endpoint",
    "field_name": "temperature",
    "auth": {
      "user": "test",
       "pass": "1234"
    }
  }
]

With this configuration, the endpoint should return a JSON with (at least) a temperature field. It should look like:

{
  "temperature": 25.8
}

Advanced JSON parsing

If the defined endpoint returns something more complicated like:

{
  "time": "YYYY-MM-DD HH:MM:SS",
  "device_info": {
    ...
  },
  "values": [
    {
      "temp1": 31.5,
      "temp2": 24.1
    },
    {
      "temp1": 27.8,
      "temp2": 29.3
    }
  ]
}

The configuration to get temp2 from 1st set of values would look like:

"accessories": [
  {
    "accessory": "HttpTemperature",
    "name": "Outside Temperature",
    "url": "https://IP/path/to/endpoint",
    "field_name": "values.[0].temp2",
  }
]