JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 56
  • Score
    100M100P100Q79073F
  • License Apache-2.0

Http JSON for Sensors and Url for Switches

Package Exports

  • homebridge-http-sensors-switches
  • homebridge-http-sensors-switches/dist/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (homebridge-http-sensors-switches) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Homebridge Platform Plugin

HTTP Sensors and Switches

Requirements:
 

[!IMPORTANT] Homebridge v2.0 Information

This template currently has a

  • package.json -> engines.homebridge value of "^1.8.0 || ^2.0.0-beta.0"
  • package.json -> devDependencies.homebridge value of "^2.0.0-beta.0"

This is to ensure that this plugin will build and run on both Homebridge v1 and v2.

[!IMPORTANT] Node v22 Information

This template currently has a

  • package.json -> engines.node value of "^18.20.4 || ^20.16.0 || ^22.5.1"

This plugin should be supporting Node v22 from October 2024.

⚙️ Config example

{
    "bridge": {
        "name": "Homebridge xxxx",
        "username": "xx:xx:xx:xx:xx:xx",
        "port": 51576,
        "pin": "xxx-xx-xxx",
        "advertiser": "bonjour-hap"
    },
    "platforms": [
        {
            "name": "Config",
            "port": 8581,
            "auth": "form",
            "theme": "auto",
            "tempUnits": "c",
            "lang": "auto",
            "noFork": true,
            "standalone": true,
            "platform": "config"
        },
        {
            "platform": "HttpSensorsAndSwitches",
            "name": "Stergo",
            "description": "Http all in one place",
            "devices": [
                {
                    "deviceType": "Sensor",
                    "deviceID": "896543287",
                    "deviceName": "Attic",
                    "deviceManufacturer": "NameTheManufacturer",
                    "deviceModel": "DHT",
                    "deviceSerialNumber": "203ab773-d5cd-42ww-b531-a98bba0e4444",
                    "deviceFirmwareVersion": "v1.4.0",
                    "sensorUrl": "http://192.168.1.74/mesures.json",
                    "temperatureName": "t",
                    "humidityName": "h",
                    "updateInterval": 60000
                },
                {
                    "deviceType": "Switch",
                    "deviceID": "1234578",
                    "deviceName": "Night Light",
                    "deviceManufacturer": "Stergo",
                    "deviceModel": "Switch",
                    "deviceSerialNumber": "203ab773-d5cd-42a2-b531-a98bba0e4444",
                    "deviceFirmwareVersion": "0.4.0",
                    "urlON": "http://192.168.1.77/POWER?state=ON",
                    "urlOFF": "http://192.168.1.77/POWER?state=OFF",
                    "urlStatus": "http://192.168.1.77/POWER",
                    "stateName": "POWER",
                    "onStatusValue": "ON",
                    "offStatusValue": "OFF"
                },
                {
                    "deviceType": "Sensor",
                    "deviceID": "65432258",
                    "deviceName": "Balcony",
                    "sensorUrl": "http://192.168.1.72/mesures.json",
                    "temperatureName": "t",
                    "updateInterval": 300000
                }
            ]
        }
    ]
}

⚙️ Config params

| Param | Description | Param needed | |--- |--- |:---: | | deviceType | Sensor or Switch | true | | deviceName | Name for Your Accessory | true | | deviceID | Uniqe ID for this Accessory | true | | deviceManufacturer | Name for Manufacturer of this Accessory | false | | deviceModel | Name of model for this Accessory | false | | deviceSerialNumber | Unique serial number | false | | deviceFirmwareVersion | Firmware running on device | false | | urlON | URL for Switch turn ON | true | | urlOFF | URL for Switch turn OFF | true | | urlStatus | URL for reading status of Switch (on/off) | true | | stateName | JSON status param | true | | onStatusValue | JSON return Value for status ON | true | | offStatusValue | JSON return Value for status OFF | true | | sensorUrl | JSON file containing sensor readings (temperature, humidity) | true | | temperatureName | JSON param name for Temperature reading | true | | humidityName | JSON param name for Humidity reading | true | | updateInterval | update interval for reading Sensors, default is 60000 | false |

Sensor JSON file example

{
    "t": "29.37",
    "h": "48.26",
    "p": "1001.33"
}

Compromise: Switch accessory, in order to work properly getStatus is bind in 5 sec interval. This is for passive devices not pushing their status. I have several devices built by my self like ESP8266 with relay and I'm just switching state. I have JSON file showing status:

{
    "POWER": "ON"
}