diff --git a/converters/toZigbee.js b/converters/toZigbee.js index be952f584e87b..68a577533055d 100644 --- a/converters/toZigbee.js +++ b/converters/toZigbee.js @@ -91,6 +91,73 @@ const converters = { } }, }, + hue_power_on_behavior: { + key: ['hue_power_on_behavior'], + convert: (key, value, message, type) => { + const lookup = { + 'default': 0x01, + 'on': 0x01, + 'off': 0x00, + 'recover': 0xff, + }; + + if (type === 'set') { + return { + cid: 'genOnOff', + cmd: 'write', + cmdType: 'foundation', + zclData: [{ + attrId: 0x4003, + dataType: 0x30, + attrData: lookup[value], + }], + cfg: cfg.default, + }; + } + }, + }, + hue_power_on_brightness: { + key: ['hue_power_on_brightness'], + convert: (key, value, message, type) => { + if (type === 'set') { + if (value === 'default') { + value = 255; + } + return { + cid: 'genLevelCtrl', + cmd: 'write', + cmdType: 'foundation', + zclData: [{ + attrId: 0x4000, + dataType: 0x20, + attrData: value, + }], + cfg: cfg.default, + }; + } + }, + }, + hue_power_on_color_temperature: { + key: ['hue_power_on_color_temperature'], + convert: (key, value, message, type) => { + if (type === 'set') { + if (value === 'default') { + value = 366; + } + return { + cid: 'lightingColorCtrl', + cmd: 'write', + cmdType: 'foundation', + zclData: [{ + attrId: 0x4010, + dataType: 0x21, + attrData: value, + }], + cfg: cfg.default, + }; + } + }, + }, light_brightness: { key: ['brightness', 'brightness_percent'], convert: (key, value, message, type) => { diff --git a/devices.js b/devices.js index d4d18bc21c62a..f76ac31ce3dfe 100644 --- a/devices.js +++ b/devices.js @@ -34,6 +34,30 @@ const generic = { }, }; +const tzHuePowerOnBehavior = [tz.hue_power_on_behavior, tz.hue_power_on_brightness, tz.hue_power_on_color_temperature]; +const hue = { + light_onoff_brightness: { + supports: generic.light_onoff_brightness.supports + ', power-on behavior', + fromZigbee: generic.light_onoff_brightness.fromZigbee, + toZigbee: generic.light_onoff_brightness.toZigbee.concat(tzHuePowerOnBehavior), + }, + light_onoff_brightness_colortemp: { + supports: generic.light_onoff_brightness_colortemp.supports + ', power-on behavior', + fromZigbee: generic.light_onoff_brightness_colortemp.fromZigbee, + toZigbee: generic.light_onoff_brightness_colortemp.toZigbee.concat(tzHuePowerOnBehavior), + }, + light_onoff_brightness_colorxy: { + supports: generic.light_onoff_brightness_colorxy.supports + ', power-on behavior', + fromZigbee: generic.light_onoff_brightness_colorxy.fromZigbee, + toZigbee: generic.light_onoff_brightness_colorxy.toZigbee.concat(tzHuePowerOnBehavior), + }, + light_onoff_brightness_colortemp_colorxy: { + supports: generic.light_onoff_brightness_colortemp_colorxy.supports + ', power-on behavior', + fromZigbee: generic.light_onoff_brightness_colortemp_colorxy.fromZigbee, + toZigbee: generic.light_onoff_brightness_colortemp_colorxy.toZigbee.concat(tzHuePowerOnBehavior), + }, +}; + const foundationCfg = {manufSpec: 0, disDefaultRsp: 0}; const execute = (device, actions, callback, delay) => { @@ -545,140 +569,140 @@ const devices = [ model: '7299760PH', vendor: 'Philips', description: 'Hue Bloom', - extend: generic.light_onoff_brightness_colorxy, + extend: hue.light_onoff_brightness_colorxy, }, { zigbeeModel: ['LLC020'], model: '7146060PH', vendor: 'Philips', description: 'Hue Go', - extend: generic.light_onoff_brightness_colortemp_colorxy, + extend: hue.light_onoff_brightness_colortemp_colorxy, }, { zigbeeModel: ['LWB004'], model: '433714', vendor: 'Philips', description: 'Hue Lux A19 bulb E27', - extend: generic.light_onoff_brightness, + extend: hue.light_onoff_brightness, }, { zigbeeModel: ['LWB006', 'LWB014'], model: '9290011370', vendor: 'Philips', description: 'Hue white A60 bulb E27', - extend: generic.light_onoff_brightness, + extend: hue.light_onoff_brightness, }, { zigbeeModel: ['LWB010'], model: '8718696449691', vendor: 'Philips', description: 'Hue White Single bulb B22', - extend: generic.light_onoff_brightness, + extend: hue.light_onoff_brightness, }, { zigbeeModel: ['LST001'], model: '7299355PH', vendor: 'Philips', description: 'Hue white and color ambiance LightStrip', - extend: generic.light_onoff_brightness_colorxy, + extend: hue.light_onoff_brightness_colorxy, }, { zigbeeModel: ['LST002'], model: '915005106701', vendor: 'Philips', description: 'Hue white and color ambiance LightStrip plus', - extend: generic.light_onoff_brightness_colortemp_colorxy, + extend: hue.light_onoff_brightness_colortemp_colorxy, }, { zigbeeModel: ['LCT001', 'LCT007', 'LCT010', 'LCT012', 'LCT014', 'LCT015', 'LCT016'], model: '9290012573A', vendor: 'Philips', description: 'Hue white and color ambiance E26/E27/E14', - extend: generic.light_onoff_brightness_colortemp_colorxy, + extend: hue.light_onoff_brightness_colortemp_colorxy, }, { zigbeeModel: ['LCT002'], model: '9290002579A', vendor: 'Philips', description: 'Hue white and color ambiance BR30', - extend: generic.light_onoff_brightness_colortemp_colorxy, + extend: hue.light_onoff_brightness_colortemp_colorxy, }, { zigbeeModel: ['LCT003'], model: '8718696485880', vendor: 'Philips', description: 'Hue white and color ambiance GU10', - extend: generic.light_onoff_brightness_colortemp_colorxy, + extend: hue.light_onoff_brightness_colortemp_colorxy, }, { zigbeeModel: ['LCT024'], model: '915005733701', vendor: 'Philips', description: 'Hue White and color ambiance Play Lightbar', - extend: generic.light_onoff_brightness_colortemp_colorxy, + extend: hue.light_onoff_brightness_colortemp_colorxy, }, { zigbeeModel: ['LTW011'], model: '464800', vendor: 'Philips', description: 'Hue white ambiance BR30 flood light', - extend: generic.light_onoff_brightness_colortemp, + extend: hue.light_onoff_brightness_colortemp, }, { zigbeeModel: ['LTW012'], model: '8718696695203', vendor: 'Philips', description: 'Hue white ambiance E14', - extend: generic.light_onoff_brightness_colortemp, + extend: hue.light_onoff_brightness_colortemp, }, { zigbeeModel: ['LTW013'], model: '8718696598283', vendor: 'Philips', description: 'Hue white ambiance GU10', - extend: generic.light_onoff_brightness_colortemp, + extend: hue.light_onoff_brightness_colortemp, }, { zigbeeModel: ['LTW010', 'LTW001', 'LTW004'], model: '8718696548738', vendor: 'Philips', description: 'Hue white ambiance E26/E27', - extend: generic.light_onoff_brightness_colortemp, + extend: hue.light_onoff_brightness_colortemp, }, { zigbeeModel: ['LTC001'], model: '3261030P7', vendor: 'Philips', description: 'Hue Being', - extend: generic.light_onoff_brightness_colortemp, + extend: hue.light_onoff_brightness_colortemp, }, { zigbeeModel: ['LTC003'], model: '3261331P7', vendor: 'Philips', description: 'Hue white ambiance Still', - extend: generic.light_onoff_brightness_colortemp, + extend: hue.light_onoff_brightness_colortemp, }, { zigbeeModel: ['LTC015'], model: '3216331P5', vendor: 'Philips', description: 'Hue white ambiance Aurelle rectangle panel light', - extend: generic.light_onoff_brightness_colortemp, + extend: hue.light_onoff_brightness_colortemp, }, { zigbeeModel: ['LTC016'], model: '3216431P5', vendor: 'Philips', description: 'Hue white ambiance Aurelle round panel light', - extend: generic.light_onoff_brightness_colortemp, + extend: hue.light_onoff_brightness_colortemp, }, { zigbeeModel: ['LLC010'], model: '7199960PH', vendor: 'Philips', description: 'Hue Iris', - extend: generic.light_onoff_brightness_colorxy, + extend: hue.light_onoff_brightness_colorxy, }, { zigbeeModel: ['RWL020', 'RWL021'],