npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

homebridge-http-sensors-switches

v1.1.6

Published

Http JSON for Sensors and Url for Switches

Downloads

176

Readme

Homebridge Platform Plugin

HTTP Sensors and Switches

verified-by-homebridge       Donate

This plugin communicates with your devices over HTTP or MQTT. Currently it supports Switches and Temperature/Humidity sensor.
Simple Discord Webhooks available in Switches

💡 Switch

[!NOTE] HTTP - Read Status (On/Off), Turn ON (url), Turn OFF (url)
MQTT - Turn ON/OFF | Values: On = 1, Off = 0
Discord Webhook publishes switch status to your Discord channel

[!TIP] If you don't have Manual switch and you don't mind when Homebridge is rebooted, your device is going to be set as OFF then you don't have to use Parameter urlStatus.

How to setup Discord Webhooks: link

[!IMPORTANT] Use HTTP or MQTT not both for same accessory.

Parameters required in Config:

deviceType = 'Switch',
deviceName = 'Name your Accessory',
deviceID = 'Put something unique / chars and numbers',
urlON = 'URL that triggers your device to change state to ON',
urlOFF = 'URL that triggers your device to change state to OFF'

[!CAUTION] Parameter: urlStatus = 'url points to JSON with device status' when is set it will bind Accessory to 5 sec check status interval

{
    "POWER": "ON"
}

🌡️ Temperature and Humidity sensor

[!NOTE] Sensor - Read JSON Or MQTT for Temperature, Humidity

[!TIP] Parameters required in Config:

deviceType = 'Sensor',
deviceName = 'Name your Accessory',
deviceID = 'Put something unique / chars and numbers',

For JSON read use param sensorUrl:
sensorUrl = 'JSON file containing sensor readings (temperature, humidity)',

For MQTT use param mqttBroker:
mqttBroker = 'URL of MQTT Broker'

[!IMPORTANT] MQTT is just an basic implementation, no encription etc.

Sensor JSON file example

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

⚙️ 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
                },
                {
                    "deviceType": "Switch",
                    "deviceID": "21wqwweqwee65432258",
                    "deviceName": "Relay",
                    "mqttBroker": "192.168.1.200",
                    "mqttPort": "1883",
                    "mqttSwitch": "iot/things/StergoTestSwitch/switch1",
                    "mqttUsername": "testuser",
                    "mqttPassword": "testuser",
                    "discordWebhook": "https://discordapp.com/api/webhooks/XXXXX",
                    "discordUsername": "SmartHome",
                    "discordAvatar": "",
                    "discordMessage": " is "
                },
                {
                    "deviceType": "Sensor",
                    "deviceID": "65432258",
                    "deviceName": "Balcony",
                    "mqttBroker": "192.168.1.200",
                    "mqttPort": "1883",
                    "mqttTemperature": "qiot/things/Attic/Temperature",
                    "mqttHumidity": "qiot/things/Attic/Humidity",
                    "mqttUsername": "testuser",
                    "mqttPassword": "testuser"
                }
            ]
        }
    ]
}

⚙️ 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 to Turn ON the Switch | true | | urlOFF | URL to Turn OFF the Switch | true | | urlStatus | URL to retrieve the switch status (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 = 60 seconds = 1 minute | false | | mqttBroker | URL of MQTT Broker | true/fale | | mqttPort | MQTT port | false | | mqttTemperature | Temperature Topic | true | | mqttHumidity | Humidity Topic | true | | mqttUsername | MQTT Broker username | false | | mqttPassword | MQTT Broker password | false | | mqttSwitch | Switch Topic | true | | discordWebhook | URL to Discord WebHook | false | | discordUsername | Name for message publisher | false | | discordAvatar | URL to Online Avatar image | false | | discordMessage | Message | false |

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"
}

[!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.