From c057e5dd01d1f0f4e278b8a2d9eb2a6027035812 Mon Sep 17 00:00:00 2001 From: "christian.taepper" Date: Tue, 26 Dec 2023 12:15:32 +0100 Subject: [PATCH 1/4] create toggle state for switch --- src/homekit/accessories/HttpWebHookSwitchAccessory.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/homekit/accessories/HttpWebHookSwitchAccessory.js b/src/homekit/accessories/HttpWebHookSwitchAccessory.js index cc18d61..46cecb3 100644 --- a/src/homekit/accessories/HttpWebHookSwitchAccessory.js +++ b/src/homekit/accessories/HttpWebHookSwitchAccessory.js @@ -44,8 +44,10 @@ 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); From 2eac724708a1c4cdee1315c21f2af1bb778128d5 Mon Sep 17 00:00:00 2001 From: "christian.taepper" Date: Tue, 26 Dec 2023 12:20:33 +0100 Subject: [PATCH 2/4] fix removed line --- src/homekit/accessories/HttpWebHookSwitchAccessory.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/homekit/accessories/HttpWebHookSwitchAccessory.js b/src/homekit/accessories/HttpWebHookSwitchAccessory.js index 46cecb3..38aa432 100644 --- a/src/homekit/accessories/HttpWebHookSwitchAccessory.js +++ b/src/homekit/accessories/HttpWebHookSwitchAccessory.js @@ -44,6 +44,7 @@ HttpWebHookSwitchAccessory.prototype.changeFromServer = function(urlParams) { }; } else { + var state = urlParams.state var stateBool = state === "true"; if (urlParams.state === "toggle") { stateBool = !cachedState From 89e4d749e2fc76f9a91120837d97a98796acc8a5 Mon Sep 17 00:00:00 2001 From: "christian.taepper" Date: Tue, 26 Dec 2023 12:20:58 +0100 Subject: [PATCH 3/4] fix removed line --- src/homekit/accessories/HttpWebHookSwitchAccessory.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/homekit/accessories/HttpWebHookSwitchAccessory.js b/src/homekit/accessories/HttpWebHookSwitchAccessory.js index 38aa432..f613881 100644 --- a/src/homekit/accessories/HttpWebHookSwitchAccessory.js +++ b/src/homekit/accessories/HttpWebHookSwitchAccessory.js @@ -44,7 +44,7 @@ HttpWebHookSwitchAccessory.prototype.changeFromServer = function(urlParams) { }; } else { - var state = urlParams.state + var state = urlParams.state; var stateBool = state === "true"; if (urlParams.state === "toggle") { stateBool = !cachedState From 1fa397f4c24ee179b688be9e6f5e134a0d09581e Mon Sep 17 00:00:00 2001 From: "christian.taepper" Date: Tue, 26 Dec 2023 12:26:29 +0100 Subject: [PATCH 4/4] add readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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.