diff --git a/streamdeck-plugin/README.md b/streamdeck-plugin/README.md index 1281eaa..134a97d 100644 --- a/streamdeck-plugin/README.md +++ b/streamdeck-plugin/README.md @@ -1,5 +1,28 @@ # Release notes +## Version 0.2.0.0 (2024-12-28) + +### Download + +[org.igox.busylight.v0.2.0.0.streamDeckPlugin](download/org.igox.busylight.v0.2.0.0.streamDeckPlugin) + +### Features + +- Add the capability to set the color diplayed by BusyLigh LEDs. + +### Fixes + +- None. + +### Bugs & known limitations + +- None known at publication time. + +### Screenshot + +![v0.2.0.0 screenshot](img/v0.2.0.0.png) + + ## Version 0.1.0.0 (2024-12-28) ### Download diff --git a/streamdeck-plugin/busylight/org.igox.busylight.sdPlugin/imgs/actions/color/color.png b/streamdeck-plugin/busylight/org.igox.busylight.sdPlugin/imgs/actions/color/color.png new file mode 100644 index 0000000..82d3f44 Binary files /dev/null and b/streamdeck-plugin/busylight/org.igox.busylight.sdPlugin/imgs/actions/color/color.png differ diff --git a/streamdeck-plugin/busylight/org.igox.busylight.sdPlugin/imgs/actions/color/color@2x.png b/streamdeck-plugin/busylight/org.igox.busylight.sdPlugin/imgs/actions/color/color@2x.png new file mode 100644 index 0000000..82d3f44 Binary files /dev/null and b/streamdeck-plugin/busylight/org.igox.busylight.sdPlugin/imgs/actions/color/color@2x.png differ diff --git a/streamdeck-plugin/busylight/org.igox.busylight.sdPlugin/manifest.json b/streamdeck-plugin/busylight/org.igox.busylight.sdPlugin/manifest.json index d44d7e0..854197d 100644 --- a/streamdeck-plugin/busylight/org.igox.busylight.sdPlugin/manifest.json +++ b/streamdeck-plugin/busylight/org.igox.busylight.sdPlugin/manifest.json @@ -1,113 +1,128 @@ -{ - "Name": "iGoX BusyLight", - "Version": "0.1.0.0", - "Author": "iGoX", - "$schema": "https://schemas.elgato.com/streamdeck/plugins/manifest.json", - "Actions": [ - { - "Name": "Set status as 'Available'", - "UUID": "org.igox.busylight.status.available", - "Icon": "imgs/actions/status/available/available", - "Tooltip": "Set status as 'Available'", - "PropertyInspectorPath": "ui/status-config.html", - "Controllers": [ - "Keypad" - ], - "States": [ - { - "Image": "imgs/actions/status/available/available", - "TitleAlignment": "bottom" - } - ] - }, - { - "Name": "Set status as 'Away'", - "UUID": "org.igox.busylight.status.away", - "Icon": "imgs/actions/status/away/away", - "Tooltip": "Set status as 'Away'", - "PropertyInspectorPath": "ui/status-config.html", - "Controllers": [ - "Keypad" - ], - "States": [ - { - "Image": "imgs/actions/status/away/away", - "TitleAlignment": "bottom" - } - ] - }, - { - "Name": "Set status as 'Busy'", - "UUID": "org.igox.busylight.status.busy", - "Icon": "imgs/actions/status/busy/busy", - "Tooltip": "Set status as 'Busy'", - "PropertyInspectorPath": "ui/status-config.html", - "Controllers": [ - "Keypad" - ], - "States": [ - { - "Image": "imgs/actions/status/busy/busy", - "TitleAlignment": "bottom" - } - ] - } - , - { - "Name": "Turn off the BusyLight", - "UUID": "org.igox.busylight.status.off", - "Icon": "imgs/actions/status/off/off", - "Tooltip": "Turn off the BusyLight", - "PropertyInspectorPath": "ui/status-config.html", - "Controllers": [ - "Keypad" - ], - "States": [ - { - "Image": "imgs/actions/status/off/off", - "TitleAlignment": "bottom" - } - ] - }, - { - "Name": "Set brightness", - "UUID": "org.igox.busylight.brigthness.set", - "Icon": "imgs/actions/brightness/brightness", - "Tooltip": "Set brightness", - "PropertyInspectorPath": "ui/brightness-config.html", - "Controllers": [ - "Keypad" - ], - "States": [ - { - "Image": "imgs/actions/brightness/brightness", - "TitleAlignment": "bottom" - } - ] - } - ], - "Category": "iGoX BusyLight", - "CategoryIcon": "imgs/plugin/marketplace", - "CodePath": "bin/plugin.js", - "Description": "Control your DIY BusyLight (https://github.com/igox/busylight) from your Stream Deck", - "Icon": "imgs/plugin/marketplace", - "SDKVersion": 2, - "Software": { - "MinimumVersion": "6.4" - }, - "OS": [ - { - "Platform": "mac", - "MinimumVersion": "10.15" - }, - { - "Platform": "windows", - "MinimumVersion": "10" - } - ], - "Nodejs": { - "Version": "20", - "Debug": "enabled" - }, - "UUID": "org.igox.busylight" +{ + "Name": "iGoX BusyLight", + "Version": "0.2.0.0", + "Author": "iGoX", + "$schema": "https://schemas.elgato.com/streamdeck/plugins/manifest.json", + "Actions": [ + { + "Name": "Set status as 'Available'", + "UUID": "org.igox.busylight.status.available", + "Icon": "imgs/actions/status/available/available", + "Tooltip": "Set status as 'Available'", + "PropertyInspectorPath": "ui/status-config.html", + "Controllers": [ + "Keypad" + ], + "States": [ + { + "Image": "imgs/actions/status/available/available", + "TitleAlignment": "bottom" + } + ] + }, + { + "Name": "Set status as 'Away'", + "UUID": "org.igox.busylight.status.away", + "Icon": "imgs/actions/status/away/away", + "Tooltip": "Set status as 'Away'", + "PropertyInspectorPath": "ui/status-config.html", + "Controllers": [ + "Keypad" + ], + "States": [ + { + "Image": "imgs/actions/status/away/away", + "TitleAlignment": "bottom" + } + ] + }, + { + "Name": "Set status as 'Busy'", + "UUID": "org.igox.busylight.status.busy", + "Icon": "imgs/actions/status/busy/busy", + "Tooltip": "Set status as 'Busy'", + "PropertyInspectorPath": "ui/status-config.html", + "Controllers": [ + "Keypad" + ], + "States": [ + { + "Image": "imgs/actions/status/busy/busy", + "TitleAlignment": "bottom" + } + ] + }, + { + "Name": "Turn off the BusyLight", + "UUID": "org.igox.busylight.status.off", + "Icon": "imgs/actions/status/off/off", + "Tooltip": "Turn off the BusyLight", + "PropertyInspectorPath": "ui/status-config.html", + "Controllers": [ + "Keypad" + ], + "States": [ + { + "Image": "imgs/actions/status/off/off", + "TitleAlignment": "bottom" + } + ] + }, + { + "Name": "Set brightness", + "UUID": "org.igox.busylight.brigthness.set", + "Icon": "imgs/actions/brightness/brightness", + "Tooltip": "Set LED brightness", + "PropertyInspectorPath": "ui/brightness-config.html", + "Controllers": [ + "Keypad" + ], + "States": [ + { + "Image": "imgs/actions/brightness/brightness", + "TitleAlignment": "bottom" + } + ] + }, + { + "Name": "Set color", + "UUID": "org.igox.busylight.color.set", + "Icon": "imgs/actions/color/color", + "Tooltip": "Set BusyLight displayed color", + "PropertyInspectorPath": "ui/color-config.html", + "Controllers": [ + "Keypad" + ], + "States": [ + { + "Image": "imgs/actions/color/color", + "TitleAlignment": "bottom" + } + ] + } + ], + "Category": "iGoX BusyLight", + "CategoryIcon": "imgs/plugin/marketplace", + "CodePath": "bin/plugin.js", + "Description": "Control your DIY BusyLight (https://github.com/igox/busylight) from your Stream Deck", + "Icon": "imgs/plugin/marketplace", + "SDKVersion": 2, + "Software": { + "MinimumVersion": "6.4" + }, + "OS": [ + { + "Platform": "mac", + "MinimumVersion": "10.15" + }, + { + "Platform": "windows", + "MinimumVersion": "10" + } + ], + "Nodejs": { + "Version": "20", + "Debug": "enabled" + }, + "UUID": "org.igox.busylight" } \ No newline at end of file diff --git a/streamdeck-plugin/busylight/org.igox.busylight.sdPlugin/ui/color-config.html b/streamdeck-plugin/busylight/org.igox.busylight.sdPlugin/ui/color-config.html new file mode 100644 index 0000000..26694b0 --- /dev/null +++ b/streamdeck-plugin/busylight/org.igox.busylight.sdPlugin/ui/color-config.html @@ -0,0 +1,33 @@ + + + + Configure your BusyLight + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/streamdeck-plugin/busylight/org.igox.busylight.sdPlugin/ui/status-config.html b/streamdeck-plugin/busylight/org.igox.busylight.sdPlugin/ui/status-config.html index 6421220..409695d 100644 --- a/streamdeck-plugin/busylight/org.igox.busylight.sdPlugin/ui/status-config.html +++ b/streamdeck-plugin/busylight/org.igox.busylight.sdPlugin/ui/status-config.html @@ -14,9 +14,6 @@ - diff --git a/streamdeck-plugin/busylight/src/actions/set-brightness.ts b/streamdeck-plugin/busylight/src/actions/set-brightness.ts index aeaca5d..115026c 100644 --- a/streamdeck-plugin/busylight/src/actions/set-brightness.ts +++ b/streamdeck-plugin/busylight/src/actions/set-brightness.ts @@ -5,7 +5,7 @@ export class SetBrightness extends SingletonAction { override async onKeyDown(ev: KeyDownEvent): Promise { - streamDeck.logger.trace(`>>> Received KeyDownEvent. Settings: ${JSON.stringify(ev.payload.settings)} <<<`); + streamDeck.logger.debug(`>>> Received KeyDownEvent. Settings: ${JSON.stringify(ev.payload.settings)} <<<`); const { settings } = ev.payload; settings.brightness ??= 40; @@ -14,14 +14,14 @@ export class SetBrightness extends SingletonAction { override onWillAppear(ev: WillAppearEvent): void | Promise { - streamDeck.logger.trace(`>>> Received WillAppearEvent. Settings: ${JSON.stringify(ev.payload.settings)} <<<`); + streamDeck.logger.debug(`>>> Received WillAppearEvent. Settings: ${JSON.stringify(ev.payload.settings)} <<<`); return ev.action.setTitle(`${ev.payload.settings.brightness ?? 40}%`); } override async onDidReceiveSettings(ev: DidReceiveSettingsEvent): Promise { - streamDeck.logger.trace(`>>> Received onDidReceiveSettings. Settings: ${JSON.stringify(ev.payload.settings)} <<<`); + streamDeck.logger.debug(`>>> Received onDidReceiveSettings. Settings: ${JSON.stringify(ev.payload.settings)} <<<`); const { settings } = ev.payload; await ev.action.setSettings(settings); @@ -33,7 +33,7 @@ async function setBrightness(brightness: number) { const settings = await streamDeck.settings.getGlobalSettings(); const url = settings.url; - streamDeck.logger.trace(`>>> Sending brightness: ${brightness} to ${url} <<<`); + streamDeck.logger.debug(`>>> Sending brightness: ${brightness} to ${url} <<<`); fetch(`${url}/api/brightness`, { @@ -44,7 +44,7 @@ async function setBrightness(brightness: number) { body: JSON.stringify({"brightness": brightness/100}) }) .then(response => response.json()) - .then(data => streamDeck.logger.trace(data)); + .then(data => streamDeck.logger.debug(data)); } type BrightnessSettings = { diff --git a/streamdeck-plugin/busylight/src/actions/set-color.ts b/streamdeck-plugin/busylight/src/actions/set-color.ts new file mode 100644 index 0000000..6e6d19f --- /dev/null +++ b/streamdeck-plugin/busylight/src/actions/set-color.ts @@ -0,0 +1,51 @@ +import streamDeck, { action, JsonObject, KeyDownEvent, DidReceiveSettingsEvent, SingletonAction } from "@elgato/streamdeck"; + +@action({ UUID: "org.igox.busylight.color.set" }) +export class SetColor extends SingletonAction { + override async onKeyDown(ev: KeyDownEvent): Promise { + + streamDeck.logger.debug(`>>> Received KeyDownEvent. Settings: ${JSON.stringify(ev.payload.settings)} <<<`); + + const { settings } = ev.payload; + settings.color ??= '#FFFFFF'; + setColor(hexToRgb(settings.color)); + } + + override async onDidReceiveSettings(ev: DidReceiveSettingsEvent): Promise { + + streamDeck.logger.debug(`>>> Received onDidReceiveSettings. Settings: ${JSON.stringify(ev.payload.settings)} <<<`); + + const { settings } = ev.payload; + await ev.action.setSettings(settings); + } +} + +function hexToRgb(hex: string): { r: number, g: number, b: number } { + const hexNumber = parseInt(hex.replace('#', ''), 16); + const r = (hexNumber >> 16) & 255; + const g = (hexNumber >> 8) & 255; + const b = hexNumber & 255; + return { r, g, b }; +} + +async function setColor(color: JsonObject) { + const settings = await streamDeck.settings.getGlobalSettings(); + const url = settings.url; + + streamDeck.logger.debug(`>>> Sending color: ${JSON.stringify({"r": color.r, "g": color.g, "b": color.b})} to ${url} <<<`); + + fetch(`${url}/api/color`, + { + method: "POST", + headers: { + "Content-Type": "application/json" + }, + body: JSON.stringify({"r": color.r, "g": color.g, "b": color.b}) + }) + .then(response => response.json()) + .then(data => streamDeck.logger.debug(data)); +} + +type ColorSettings = { + color?: string; +}; \ No newline at end of file diff --git a/streamdeck-plugin/busylight/src/actions/set-status.ts b/streamdeck-plugin/busylight/src/actions/set-status.ts index 27a1e50..bf90212 100644 --- a/streamdeck-plugin/busylight/src/actions/set-status.ts +++ b/streamdeck-plugin/busylight/src/actions/set-status.ts @@ -32,7 +32,7 @@ async function setStatus(status: string) { const settings = await streamDeck.settings.getGlobalSettings(); const url = settings.url; - streamDeck.logger.trace(`>>> Sending status: ${status} to ${url} <<<`); + streamDeck.logger.debug(`>>> Sending status: ${status} to ${url} <<<`); fetch(`${url}/api/status/${status}`, { @@ -42,5 +42,5 @@ async function setStatus(status: string) { } }) .then(response => response.json()) - .then(data => streamDeck.logger.trace(data)); + .then(data => streamDeck.logger.debug(data)); } \ No newline at end of file diff --git a/streamdeck-plugin/busylight/src/plugin.ts b/streamdeck-plugin/busylight/src/plugin.ts index 1a4783a..a59808e 100644 --- a/streamdeck-plugin/busylight/src/plugin.ts +++ b/streamdeck-plugin/busylight/src/plugin.ts @@ -3,6 +3,7 @@ import streamDeck, { LogLevel, SingletonAction, action, type DidReceiveSettingsE //import { IncrementCounter } from "./actions/increment-counter"; import { SetStatusAvailable, SetStatusBusy, SetStatusAway, SetStatusOff } from "./actions/set-status"; import { SetBrightness } from "./actions/set-brightness"; +import { SetColor } from "./actions/set-color"; // We can enable "trace" logging so that all messages between the Stream Deck, and the plugin are recorded. When storing sensitive information streamDeck.logger.setLevel(LogLevel.INFO); @@ -13,6 +14,7 @@ streamDeck.actions.registerAction(new SetStatusBusy()); streamDeck.actions.registerAction(new SetStatusAway()); streamDeck.actions.registerAction(new SetStatusOff()); streamDeck.actions.registerAction(new SetBrightness()); +streamDeck.actions.registerAction(new SetColor()); // Finally, connect to the Stream Deck. streamDeck.connect(); diff --git a/streamdeck-plugin/download/org.igox.busylight.v0.2.0.0.streamDeckPlugin b/streamdeck-plugin/download/org.igox.busylight.v0.2.0.0.streamDeckPlugin new file mode 100644 index 0000000..92a0700 Binary files /dev/null and b/streamdeck-plugin/download/org.igox.busylight.v0.2.0.0.streamDeckPlugin differ diff --git a/streamdeck-plugin/img/v0.2.0.0.png b/streamdeck-plugin/img/v0.2.0.0.png new file mode 100644 index 0000000..6cca3df Binary files /dev/null and b/streamdeck-plugin/img/v0.2.0.0.png differ