1.4.0 • Published 5 months ago

homebridge-http-sensors-switches v1.4.0

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
5 months ago

Homebridge Platform Plugin

HTTP Sensors and Switches

verified-by-homebridge       Donate

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

🕺 Motion Sensor

!NOTE
HTTP - Read status (true or 1 /false or 0) from JSON - {"Motion": true}
MQTT - Read status (true or 1/false)

{
    "Motion": false
}

💡 Light Bulb

!NOTE
HTTP:

  • Read Status (On/Off), Turn ON (url), Turn OFF (url)
  • Control RGB or HSV on device
  • Brightness
  • Color Temperature: Mired (153-500) OR Kelvin (2000-6500)

MQTT:

  • Turn ON/OFF | Values: On = true || 1, Off = fale || 0
  • RGB in format #FFAA22 or without #

SET only Parameters you intent to use

{
    "Light": true, "Brightness": 100, "RGB": "FF00AA", "Hue": 120, "Saturation": 20, "ColorTemperature": 500
}

!TIP
Use RGB will Send and Receive values in RGB format
If use RGB is set, Saturation and Hue will not be sent or read.
Use Brightness 0-255 will Send and Receive converted Brightness value in range 0-255

Parameters for services you do not need, leave BLANK

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

  Switch & Outlet

!NOTE
HTTP:

  • Read Status (On/Off), Turn ON (url), Turn OFF (url)
  • Outlet read Status: Outlet In Use( true/false)

MQTT:

  • Turn ON/OFF ( Values: On = 1 || true, Off = 0 || false )
  • Outlet In Use ( Values: true/false or 1/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", "inUSE": false
}

🌡️ 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

ParamDescriptionParam needed
deviceTypeSensor or Switchtrue
deviceNameName for Your Accessorytrue
deviceIDUniqe ID for this Accessorytrue
deviceManufacturerName for Manufacturer of this Accessoryfalse
deviceModelName of model for this Accessoryfalse
deviceSerialNumberUnique serial numberfalse
deviceFirmwareVersionFirmware running on devicefalse
enableLoggingDafault is enabled (1)true
urlONURL to Turn ON the Switchtrue
urlOFFURL to Turn OFF the Switchtrue
urlStatusURL to retrieve JSON with all Datatrue
stateNameJSON Parameter Name for Reading ON/OFFtrue
onStatusValueJSON return Value for status ONtrue
offStatusValueJSON return Value for status OFFtrue
inUseStateNameJSON status param in Usefalse
inUseOnStatusValueJSON return Value for inUSE ONfalse
inUseOffStatusValueJSON return Value for inUSE OFFfalse
sensorUrlJSON file containing sensor readings (temperature, humidity)true
temperatureNameJSON param name for Temperature readingtrue
humidityNameJSON param name for Humidity readingtrue
useRGBUse RGB instead of HSV (true/false)true
useBrightness255Use Brightness 0 - 255 not 0 - 100 (true/false)true
useColorTKelvinColor Temperature in Mired (153-500), Kelvin (2000-6500)true
rgbParamNameJSON Parameter Name for RGB colorfalse
urlLightBulbControlHTTP address where to send Device control commands (POST)false
brightnessParamNameJSON Parameter Name for Brightnessfalse
saturationParamNameJSON Parameter Name for Saturationfalse
hueParamNameJSON Parameter Name for HUEfalse
colorTemperatureParamNameJSON Parameter Name for Color Temperaturefalse
updateIntervalupdate interval for reading Sensors, default is 60000 = 60 seconds = 1 minutefalse
mqttBrokerURL of MQTT Brokertrue/false
mqttReconnectIntervalreconnect interval when no connection to MQTT Broker, default is 60 secondstrue/false
mqttPortMQTT portfalse
mqttTemperatureTemperature Topictrue
mqttHumidityHumidity Topictrue
mqttUsernameMQTT Broker usernamefalse
mqttPasswordMQTT Broker passwordfalse
mqttSwitchSwitch Topictrue
mqttInUseOutlet in Use Topicfalse
mqttMotionSensorMotion Sensor Topictrue
mqttRGBMQTT Topic for RGBfalse
mqttBrightnessMQTT Topic for Brightnessfalse
mqttHueMQTT Topic for Huefalse
mqttSaturationMQTT Topic for Saturationfalse
mqttColorTemperatureMQTT Topic for Color Temperaturefalse
motionSensorNameJSON param name for Motion Sensor readingtrue
motionSensorUrlSON file containing Motion Sensor readingstrue
updateIntervalMotionSensorupdate interval for reading Motion Sensor, default is 60000 = 60 seconds = 1 minutetrue
discordWebhookURL to Discord WebHookfalse
discordUsernameName for message publisherfalse
discordAvatarURL to Online Avatar imagefalse
discordMessageMessagefalse

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

6 months ago

1.1.7

7 months ago

1.4.0

5 months ago

1.3.0

6 months ago

1.1.6

9 months ago

1.1.5

10 months ago

1.1.4

10 months ago

1.1.3

10 months ago

1.1.2

10 months ago

1.1.1

10 months ago

1.1.0

10 months ago

1.0.2

10 months ago

1.0.1

10 months ago

1.0.0

10 months ago

0.4.0

11 months ago

0.3.0

11 months ago

0.2.0

11 months ago

0.1.4

11 months ago

0.1.3

11 months ago

0.1.2

11 months ago

0.1.1

11 months ago

0.1.0

11 months ago

0.0.4-beta.0

11 months ago

0.0.3-beta.0

11 months ago