diff --git a/README.md b/README.md index a2bacff..afe063e 100755 --- a/README.md +++ b/README.md @@ -36,7 +36,7 @@ For occupancy sensors the value for `NEWSTATE` is either `true` for occupancy de For smoke sensors the value for `NEWSTATE` is either `true` for smoke detection or `false` for no smoke. ## Switch -For switches the value for `NEWSTATE` is either `true` for on or `false` for off. +For switches the value for `NEWSTATE` is either `true` for on or `false` for off. Alternatively use the value `toggle` to make the switch to into its other state. ## Push button For push buttons the value for `NEWSTATE` is `true`. The button will be released automatically. diff --git a/src/homekit/accessories/HttpWebHookSwitchAccessory.js b/src/homekit/accessories/HttpWebHookSwitchAccessory.js index cc18d61..f613881 100644 --- a/src/homekit/accessories/HttpWebHookSwitchAccessory.js +++ b/src/homekit/accessories/HttpWebHookSwitchAccessory.js @@ -46,6 +46,9 @@ HttpWebHookSwitchAccessory.prototype.changeFromServer = function(urlParams) { else { var state = urlParams.state; var stateBool = state === "true"; + if (urlParams.state === "toggle") { + stateBool = !cachedState + } this.storage.setItemSync("http-webhook-" + this.id, stateBool); // this.log("[INFO Http WebHook Server] State change of '%s' // to '%s'.",accessory.id,stateBool);