From bc92b24d2d14bb55aac47ab743d7f4646290172e Mon Sep 17 00:00:00 2001 From: Simon Beckett Date: Sun, 26 Nov 2023 16:04:05 +1100 Subject: [PATCH 01/11] added getstate to api commands --- CHANGELOG.md | 3 +-- octoprint_octohue/__init__.py | 5 ++++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4b57f78..501c1d6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,7 @@ # OctoPrint-OctoHue Change Log ## Added in 0.5.0 -* Added "Light On" on Octoprint startup +* Added option to "Light On" on Octoprint startup by selecting an already configured light event ## Fixed in 0.4.4 * It is recommended that you remove your existing octohue settings, or at the very least remove statusDict from config.yaml @@ -11,7 +11,6 @@ * Moved from using the term "status" to "events" in line with octoprint terminology * Added new Event Add modal with "Event" dropdown populated from native octoprint events. - ## Fixed in 0.4.3 * Renamed rgb() to build_state() as it better describes its function * Fixed brightness not being passed properly to build_state meaning it always defaulted to 255 diff --git a/octoprint_octohue/__init__.py b/octoprint_octohue/__init__.py index e8d2242..bc3efbb 100644 --- a/octoprint_octohue/__init__.py +++ b/octoprint_octohue/__init__.py @@ -107,12 +107,15 @@ def on_shutdown(self): def get_api_commands(self): return dict( - togglehue=[] + togglehue=[], + getstate=[] ) def on_api_command(self, command, data): if command == 'togglehue': self.toggle_state() + elif command == 'getstate': + self.get_state() # Trigger state on Status match def on_event(self, event, payload): From 94d1d0c0830a2bae73a854d8aae1efad54d57873 Mon Sep 17 00:00:00 2001 From: Simon Beckett Date: Sun, 26 Nov 2023 16:46:43 +1100 Subject: [PATCH 02/11] doing some api things --- octoprint_octohue/__init__.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/octoprint_octohue/__init__.py b/octoprint_octohue/__init__.py index bc3efbb..0e94b18 100644 --- a/octoprint_octohue/__init__.py +++ b/octoprint_octohue/__init__.py @@ -114,8 +114,12 @@ def get_api_commands(self): def on_api_command(self, command, data): if command == 'togglehue': self.toggle_state() - elif command == 'getstate': - self.get_state() + + def on_api_get(self, request): + if request.args.get("getstate") + self._logger.debug("Recieved API Get: %s" % request) + return self.get_state() + # Trigger state on Status match def on_event(self, event, payload): From c6f8c3a791713fe95a1a066d905ec74ff1912ab6 Mon Sep 17 00:00:00 2001 From: Simon Beckett Date: Sun, 26 Nov 2023 16:50:17 +1100 Subject: [PATCH 03/11] fixed a typo --- octoprint_octohue/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/octoprint_octohue/__init__.py b/octoprint_octohue/__init__.py index 0e94b18..b6d814c 100644 --- a/octoprint_octohue/__init__.py +++ b/octoprint_octohue/__init__.py @@ -116,7 +116,7 @@ def on_api_command(self, command, data): self.toggle_state() def on_api_get(self, request): - if request.args.get("getstate") + if request.args.get("getstate"): self._logger.debug("Recieved API Get: %s" % request) return self.get_state() From 07968494737f892c3a6de93f6fa3d59f643e15f3 Mon Sep 17 00:00:00 2001 From: Simon Beckett Date: Sun, 26 Nov 2023 16:58:11 +1100 Subject: [PATCH 04/11] still working out this api thing --- octoprint_octohue/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/octoprint_octohue/__init__.py b/octoprint_octohue/__init__.py index b6d814c..55b8954 100644 --- a/octoprint_octohue/__init__.py +++ b/octoprint_octohue/__init__.py @@ -112,13 +112,14 @@ def get_api_commands(self): ) def on_api_command(self, command, data): + import flask if command == 'togglehue': self.toggle_state() def on_api_get(self, request): if request.args.get("getstate"): self._logger.debug("Recieved API Get: %s" % request) - return self.get_state() + return flask.jsonify(foo="bar") # Trigger state on Status match From dce3c8ff6f1f0100f7470cdd861bba39f67b89bf Mon Sep 17 00:00:00 2001 From: Simon Beckett Date: Sun, 26 Nov 2023 17:11:07 +1100 Subject: [PATCH 05/11] still working out this api thing --- octoprint_octohue/__init__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/octoprint_octohue/__init__.py b/octoprint_octohue/__init__.py index 55b8954..361b259 100644 --- a/octoprint_octohue/__init__.py +++ b/octoprint_octohue/__init__.py @@ -113,6 +113,7 @@ def get_api_commands(self): def on_api_command(self, command, data): import flask + self._logger.debug("Recieved API Command: %s" % command) if command == 'togglehue': self.toggle_state() From f39ce3dbcc5f7e4ec58884beebd9c940348bf333 Mon Sep 17 00:00:00 2001 From: Simon Beckett Date: Sun, 26 Nov 2023 17:21:46 +1100 Subject: [PATCH 06/11] still working out this api thing --- octoprint_octohue/__init__.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/octoprint_octohue/__init__.py b/octoprint_octohue/__init__.py index 361b259..b9b496d 100644 --- a/octoprint_octohue/__init__.py +++ b/octoprint_octohue/__init__.py @@ -116,6 +116,8 @@ def on_api_command(self, command, data): self._logger.debug("Recieved API Command: %s" % command) if command == 'togglehue': self.toggle_state() + elif command == 'getstate': + return self.get_state() def on_api_get(self, request): if request.args.get("getstate"): From e14be945a702b604523f8356765d9f3d377b5b56 Mon Sep 17 00:00:00 2001 From: Simon Beckett Date: Sun, 26 Nov 2023 17:28:18 +1100 Subject: [PATCH 07/11] still working out this api thing --- octoprint_octohue/__init__.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/octoprint_octohue/__init__.py b/octoprint_octohue/__init__.py index b9b496d..b19a1ca 100644 --- a/octoprint_octohue/__init__.py +++ b/octoprint_octohue/__init__.py @@ -117,7 +117,10 @@ def on_api_command(self, command, data): if command == 'togglehue': self.toggle_state() elif command == 'getstate': - return self.get_state() + if self.get_state(): + return flask.jsonify(on="true") + else: + return flask.jsonify(on="false") def on_api_get(self, request): if request.args.get("getstate"): From 732102e0aea3811462181695786b74277874ad60 Mon Sep 17 00:00:00 2001 From: Simon Beckett Date: Sun, 26 Nov 2023 17:31:54 +1100 Subject: [PATCH 08/11] getstate api command added. code cleanup --- octoprint_octohue/__init__.py | 6 ------ 1 file changed, 6 deletions(-) diff --git a/octoprint_octohue/__init__.py b/octoprint_octohue/__init__.py index b19a1ca..e9dadf7 100644 --- a/octoprint_octohue/__init__.py +++ b/octoprint_octohue/__init__.py @@ -121,12 +121,6 @@ def on_api_command(self, command, data): return flask.jsonify(on="true") else: return flask.jsonify(on="false") - - def on_api_get(self, request): - if request.args.get("getstate"): - self._logger.debug("Recieved API Get: %s" % request) - return flask.jsonify(foo="bar") - # Trigger state on Status match def on_event(self, event, payload): From ef9eda04f04d200ac343f3602d68d63e341f0ff3 Mon Sep 17 00:00:00 2001 From: Simon Beckett Date: Sun, 26 Nov 2023 17:46:47 +1100 Subject: [PATCH 09/11] added turn on|off --- octoprint_octohue/__init__.py | 11 ++++++++++- setup.py | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/octoprint_octohue/__init__.py b/octoprint_octohue/__init__.py index e9dadf7..ea55cd4 100644 --- a/octoprint_octohue/__init__.py +++ b/octoprint_octohue/__init__.py @@ -108,7 +108,9 @@ def on_shutdown(self): def get_api_commands(self): return dict( togglehue=[], - getstate=[] + getstate=[], + turnon=[], + turnoff=[] ) def on_api_command(self, command, data): @@ -121,6 +123,13 @@ def on_api_command(self, command, data): return flask.jsonify(on="true") else: return flask.jsonify(on="false") + elif command == 'turnon': + if "colour" in data: + self.build_state(illuminate=True, colour=data['colour'], bri=int(self._settings.get(['defaultbri']))) + else: + self.build_state(illuminate=True, bri=int(self._settings.get(['defaultbri']))) + elif command == 'turnoff': + self.build_state(illuminate=False) # Trigger state on Status match def on_event(self, event, payload): diff --git a/setup.py b/setup.py index 12f6f26..81d7544 100644 --- a/setup.py +++ b/setup.py @@ -14,7 +14,7 @@ plugin_name = "OctoHue" # The plugin's version. Can be overwritten within OctoPrint's internal data via __plugin_version__ in the plugin module -plugin_version = "0.5.0" +plugin_version = "0.6.0" # The plugin's description. Can be overwritten within OctoPrint's internal data via __plugin_description__ in the plugin # module From 9b155cfaf3817552ba0eed7d79514fcd8f2a8034 Mon Sep 17 00:00:00 2001 From: Simon Beckett Date: Sun, 26 Nov 2023 17:58:33 +1100 Subject: [PATCH 10/11] Staging up for new release --- CHANGELOG.md | 6 ++++++ README.md | 18 ++++++------------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 501c1d6..763b04e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # OctoPrint-OctoHue Change Log +## Added in 0.6.0 +* Added several API commands to assist with 3rd party integrations +** getstate : Returns "On": True|False, representing if the light is on or off +** turnon : turns the light on to its last illuminated settings. Also accepts the hex colour code as the value for the optional "colour" parameter +** turnoff: Turns the light off + ## Added in 0.5.0 * Added option to "Light On" on Octoprint startup by selecting an already configured light event diff --git a/README.md b/README.md index b7532e0..89281cb 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,12 @@ Illuminate your print job and signal its status using a Philips Hue light. +## Added in 0.6.0 +* Added several API commands to assist with 3rd party integrations +** getstate : Returns "On": True|False, representing if the light is on or off +** turnon : turns the light on to its last illuminated settings. Also accepts the hex colour code as the value for the optional "colour" parameter +** turnoff: Turns the light off + ## Added in 0.5.0 * Added option to "Light On" on Octoprint startup by selecting an already configured light event @@ -14,18 +20,6 @@ Illuminate your print job and signal its status using a Philips Hue light. * Added new Event Add modal with "Event" dropdown populated from native octoprint events. -## Fixed in 0.4.3 -* Renamed rgb() to build_state() as it better describes its function -* Fixed brightness not being passed properly to build_state meaning it always defaulted to 255 -* Fixed bridge object not being reinitialised on settings save, requiring a restart to pickup bridge and user changes. -* Default brightness now works as planned and sets the brightness when it is not defined for a particular status. - -## Added in 0.4.2 -* Optional Navbar Icon allowing the user to toggle On/Off -* Reworked settings allows user configurable Statuses and colour/brightness/state configurations. -* Added turning lights off as an option for printer statuses. -* Added debug logging option to allow logging or raw status events to aid configuration - ## Features * Set Colour, Brightness, and On/Off state for any Octoprint state event e.g Connected, Printing, PrintCompleted. * Optional Navbar Icon allowing the user to toggle On/Off From d150edea5786d26d75034a7ab1800ba1f56ec49c Mon Sep 17 00:00:00 2001 From: Simon Beckett Date: Sun, 26 Nov 2023 18:02:10 +1100 Subject: [PATCH 11/11] markdown fixes --- CHANGELOG.md | 6 +++--- README.md | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 763b04e..5ac1577 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,9 +2,9 @@ ## Added in 0.6.0 * Added several API commands to assist with 3rd party integrations -** getstate : Returns "On": True|False, representing if the light is on or off -** turnon : turns the light on to its last illuminated settings. Also accepts the hex colour code as the value for the optional "colour" parameter -** turnoff: Turns the light off + * getstate : Returns "On": True|False, representing if the light is on or off + * turnon : turns the light on to its last illuminated settings. Also accepts the hex colour code as the value for the optional "colour" parameter + * turnoff: Turns the light off ## Added in 0.5.0 * Added option to "Light On" on Octoprint startup by selecting an already configured light event diff --git a/README.md b/README.md index 89281cb..00268e0 100644 --- a/README.md +++ b/README.md @@ -4,9 +4,9 @@ Illuminate your print job and signal its status using a Philips Hue light. ## Added in 0.6.0 * Added several API commands to assist with 3rd party integrations -** getstate : Returns "On": True|False, representing if the light is on or off -** turnon : turns the light on to its last illuminated settings. Also accepts the hex colour code as the value for the optional "colour" parameter -** turnoff: Turns the light off + * getstate : Returns "On": True|False, representing if the light is on or off + * turnon : turns the light on to its last illuminated settings. Also accepts the hex colour code as the value for the optional "colour" parameter + * turnoff: Turns the light off ## Added in 0.5.0 * Added option to "Light On" on Octoprint startup by selecting an already configured light event