Skip to content

Commit

Permalink
Fix HUE Brightness and Transition Time. Transition time was broken wi…
Browse files Browse the repository at this point in the history
…th the new state system and Brightness wasn't properly changed with lightswitch off
  • Loading branch information
LordTocs committed Mar 19, 2022
1 parent c05ba4f commit 9b04b8f
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 24 deletions.
31 changes: 16 additions & 15 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"@julusian/jpeg-turbo": "^1.1.1",
"@mdi/font": "^6.5.95",
"@nut-tree/nut-js": "^2.0.0",
"@peter-murray/hue-bridge-model": "^2.0.4",
"@twurple/api": "^5.0.13",
"@twurple/auth": "^5.0.13",
"@twurple/chat": "^5.0.13",
Expand All @@ -43,7 +44,7 @@
"jsdom": "^16.7.0",
"lodash": "^4.17.21",
"nanoid": "^3.1.32",
"node-hue-api": "^5.0.0-beta.8",
"node-hue-api": "^5.0.0-beta.13",
"node-key-sender": "^1.0.11",
"obs-websocket-js": "^4.0.3",
"public-ip": "^4.0.4",
Expand Down
23 changes: 15 additions & 8 deletions src/core/plugins/hue.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,7 @@ class HUEStateTracker {
}
const lastState = this.lastState[group];

if (requestedState.on != undefined) {
if (lastState.on != requestedState.on) {
state.on(requestedState.on);
lastState.on = requestedState.on;
}
}

if (requestedState.bri != undefined) {
if (lastState.bri != requestedState.bri) {
state.bri(requestedState.bri);
Expand Down Expand Up @@ -45,8 +40,17 @@ class HUEStateTracker {
delete lastState.sat;
}
}
if (requestedState.on != undefined) {
if (lastState.on != requestedState.on) {
state.on(requestedState.on);
lastState.on = requestedState.on;
if (!requestedState.on) {
this.lastState[group] = {};
}
}
}
if (requestedState.transition != undefined) {
state.transitionInMillis(requestedState.transition * 1000);
state.transitionInMillis(requestedState.transition);
}
return state;
}
Expand Down Expand Up @@ -104,7 +108,8 @@ const fs = require("fs");
const path = require('path');
const { userFolder } = require('../utils/configuration');
const axios = require("axios");
const _cloneDeep = require("lodash/cloneDeep")
const _cloneDeep = require("lodash/cloneDeep");
const { request } = require('websocket');

module.exports = {
name: "hue",
Expand Down Expand Up @@ -242,6 +247,7 @@ module.exports = {
}
catch (err) {
console.error(err);
this.logger.error(err);
return []
}
},
Expand All @@ -250,6 +256,7 @@ module.exports = {
return (await this.hue.scenes.getAll()).map(s => s.name)
}
catch (err) {
this.logger.error(err);
console.error(err);
return []
}
Expand Down

0 comments on commit 9b04b8f

Please sign in to comment.