From c66f8e43dda9217ef0e3c9b38c54739d614cfcda Mon Sep 17 00:00:00 2001 From: Andy Fuchs Date: Thu, 5 Jan 2023 16:53:16 +0100 Subject: [PATCH] try to show current value of a new light in SD+ --- README.md | 4 ++++ .../plugin/js/action.js | 11 +++++++++++ .../com.elgato.philips-hue.sdPlugin/plugin/js/main.js | 7 +++++++ 3 files changed, 22 insertions(+) diff --git a/README.md b/README.md index 584269c..9e30b7e 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,10 @@ In the [Release](./Release) folder, you can find the file `com.elgato.philips-hu The [Sources](./Sources) folder contains the source code of the plugin. # Changes +## 1.6.4 +- fixed/improved support for temperature actions +- PI now lets you only select lights for a temperature action if they support color temperature + ## 1.6.3 - updated CSS to the latest versions of our SDK-libs - added an option to the PI to allow larger steps if you rotate dials (1,2,3,4,5,10). diff --git a/Sources/com.elgato.philips-hue.sdPlugin/plugin/js/action.js b/Sources/com.elgato.philips-hue.sdPlugin/plugin/js/action.js index 69f85c4..edcddb4 100644 --- a/Sources/com.elgato.philips-hue.sdPlugin/plugin/js/action.js +++ b/Sources/com.elgato.philips-hue.sdPlugin/plugin/js/action.js @@ -82,6 +82,15 @@ function Action(inContext, inSettings, jsn) { }; this.updateDisplay = (lightOrGroup, property) => { + if(!lightOrGroup) { + const curLightOrGroup = this.getCurrentLightOrGroup(); + if(curLightOrGroup) { + lightOrGroup = curLightOrGroup.objCache; + this.savedValue = -1; // force update + } + console.assert(lightOrGroup, 'no light or group', curLightOrGroup); + if(!lightOrGroup) return; + }; if(this.isInMultiAction || !this.isEncoder) return; const powerHue = property == 'power' ? !lightOrGroup?.power : lightOrGroup?.power; let actionValue = lightOrGroup?.[this.property]; @@ -98,6 +107,8 @@ function Action(inContext, inSettings, jsn) { let value; if(this.property == 'temperature') { const ct = lightOrGroup.originalValue?.capabilities?.control?.ct; + console.assert(ct, 'no ct in capabilities', lightOrGroup); + if(!ct) return; value = parseInt(Utils.percent(lightOrGroup.temperature, ct.min, ct.max)); } else { value = parseInt(actionValue / 2.54); diff --git a/Sources/com.elgato.philips-hue.sdPlugin/plugin/js/main.js b/Sources/com.elgato.philips-hue.sdPlugin/plugin/js/main.js index 9ddbf20..1a5ed04 100644 --- a/Sources/com.elgato.philips-hue.sdPlugin/plugin/js/main.js +++ b/Sources/com.elgato.philips-hue.sdPlugin/plugin/js/main.js @@ -223,6 +223,13 @@ function connectElgatoStreamDeckSocket(inPort, inPluginUUID, inRegisterEvent, in actions[context].onKeyUp(context); } } + } else if (piEvent === 'lightsChanged') { + // console.log("lightsChanged", action, context, jsonPayload); + if (context in actions) { + if(actions[context].updateDisplay) { + actions[context].updateDisplay(); + }; + } } } };