Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including homebridge-sonoff-wifi-switch with all npm packages installed. Try it out:

var homebridgeSonoffWifiSwitch = require("homebridge-sonoff-wifi-switch")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

homebridge-sonoff-wifi-switch v1.3.3

Homebridge-sonoff-wifi-switch plugin initial release.

Config Example:

{
"platforms" : [
  {
   "platform" : "SonoffWiFiSwitchHTTPPlatform",
   "accessories" : [
     {
      "initState" : "off",
      "action" : "on",
      "hostname" : "XXX.XX.X.XX",
      "password" : "*******"
      "pulse" : "false",
      "lock" : "false",
      "duration" : "5",
      "name" : "accessorie 1",
      "status" : "relay1",
      "sensor" : "true",
      "sensorService" : "ContactSensor",
      "sensorCharacteristic" : "ContactSensorState"
     },
     {
      "accessory" : "SonoffWiFiSwitchHTTP",
      "hostname" : "XXX.XX.X.XX",
      "sensor" : "true",
      "sensorUpdateIntervalMs" : "1000",
      "sensorService" : "TemperatureSensor",
      "TemperatureSensorCorrection" : "-30.5",
      "TemperatureSensorCorrectionMax" : "100",
      "TemperatureSensorCorrectionMim" : "-100",
      "sensorCharacteristic" : "CurrentTemperature",
      "status" : "temperature1",
      "name" : "ServerRoom"
     }
    ],
   "name" : "SonoffWiFiPlatform1"
  }
 ]
}

Default accessorie type is "Switch"
hostname - accessorie address
pulse - (true/false) Flag to change the state to the original after (duration) seconds
duration - timer (seconds)
status - (string, default: "relay" + RelayNum) Name of the Json -field containing the device status in status response
action - (on/off) click
RelayNum - (int, default: 1) relay number for internal requests (examples, where "2" is RelayNum: "cmd?command=relay off 2", "cmd?command=pulse on relay2 2000") lock - (true/false) accessorie is "LockMechanism"


sensor - (true/false) accessorie is "ContactSensor"
  -sensorService/sensorCharacteristic (both fields must be filled) - (string - name of sensor sensor service/sensor characteristic) accessorie is sensor (sensor = true)
  -sensorUpdateIntervalMs
  If sensorService is TemperatureSensor:
   -TemperatureSensorCorrection
   -TemperatureSensorCorrectionMax
   -TemperatureSensorCorrectionMim

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free