Skip to content

Commit

Permalink
color fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
andreypopov committed Jun 26, 2022
1 parent 2d0ad32 commit 79329a5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion nodes/out.js
Original file line number Diff line number Diff line change
Expand Up @@ -272,13 +272,13 @@ module.exports = function(RED) {

if (payload.On !== undefined) {
if ("current_values" in device) {
// console.log(device.current_values);
// if ("brightness" in device.current_values) msg['brightness'] = device.current_values.brightness;
}
msg['state'] = payload.On?"on":"off";
}
if (payload.Brightness !== undefined) {
msg['brightness'] = Zigbee2mqttHelper.convertRange(payload.Brightness, [0,100], [0,255]);
device.current_values.brightness = msg['brightness'];
if ("current_values" in device) {
if ("current_values" in device) device.current_values.brightness = msg['brightness'];
}
Expand All @@ -287,6 +287,7 @@ module.exports = function(RED) {
}
if (payload.Hue !== undefined) {
msg['color'] = {"hue":payload.Hue};
device.current_values.color.hue = payload.Hue;
if ("current_values" in device) {
if ("brightness" in device.current_values) msg['brightness'] = device.current_values.brightness;
if ("color" in device.current_values && "saturation" in device.current_values.color) msg['color']['saturation'] = device.current_values.color.saturation;
Expand All @@ -296,6 +297,7 @@ module.exports = function(RED) {
}
if (payload.Saturation !== undefined) {
msg['color'] = {"saturation":payload.Saturation};
device.current_values.color.saturation = payload.Saturation;
if ("current_values" in device) {
if ("brightness" in device.current_values) msg['brightness'] = device.current_values.brightness;
if ("color" in device.current_values && "hue" in device.current_values.color) msg['color']['hue'] = device.current_values.color.hue;
Expand All @@ -305,6 +307,7 @@ module.exports = function(RED) {
}
if (payload.ColorTemperature !== undefined) {
msg['color_temp'] = Zigbee2mqttHelper.convertRange(payload.ColorTemperature, [150,500], [150,500]);
device.current_values.color_temp = msg['color_temp'];
if ("current_values" in device) {
if ("color_temp" in device.current_values) device.current_values.color_temp = msg['color_temp'];
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
},
"name": "node-red-contrib-zigbee2mqtt",
"description": "Zigbee2mqtt connectivity nodes for node-red",
"version": "2.3.0",
"version": "2.3.1",
"dependencies": {
"eventsource": "^2.0.2",
"mqtt": "^4.3.7",
Expand Down

0 comments on commit 79329a5

Please sign in to comment.