Skip to content

Commit

Permalink
Merge pull request #50 from entrippy/develop
Browse files Browse the repository at this point in the history
OctoApp API endpoints
  • Loading branch information
entrippy committed Nov 26, 2023
2 parents bf46548 + 7a563bd commit 7bf9c32
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 16 deletions.
9 changes: 7 additions & 2 deletions CHANGELOG.md
@@ -1,7 +1,13 @@
# 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 "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
Expand All @@ -11,7 +17,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
Expand Down
18 changes: 6 additions & 12 deletions README.md
Expand Up @@ -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

Expand All @@ -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
Expand Down
19 changes: 18 additions & 1 deletion octoprint_octohue/__init__.py
Expand Up @@ -107,12 +107,29 @@ def on_shutdown(self):

def get_api_commands(self):
return dict(
togglehue=[]
togglehue=[],
getstate=[],
turnon=[],
turnoff=[]
)

def on_api_command(self, command, data):
import flask
self._logger.debug("Recieved API Command: %s" % command)
if command == 'togglehue':
self.toggle_state()
elif command == 'getstate':
if self.get_state():
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):
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -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
Expand Down

0 comments on commit 7bf9c32

Please sign in to comment.