diff --git a/.eslintrc.json b/.eslintrc.json index 540026c9..4b21fd9f 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -4,9 +4,7 @@ }, "extends": ["eslint:recommended", "google"], "parserOptions": { - "ecmaFeatures": { - "experimentalObjectRestSpread": true - }, + "ecmaVersion": 6, "sourceType": "module" }, "rules": { diff --git a/lib/homeassistant.js b/lib/homeassistant.js index d5462a4e..8950dbb6 100644 --- a/lib/homeassistant.js +++ b/lib/homeassistant.js @@ -191,28 +191,21 @@ const configurations = { command_topic: true, }, }, - 'switch_left': { +}; + +const switchWithPostfix = (postfix) => { + return { type: 'switch', - object_id: 'switch_left', + object_id: `switch_${postfix}`, discovery_payload: { payload_off: 'OFF', payload_on: 'ON', - value_template: '{{ value_json.state_left }}', + value_template: `{{ value_json.state_${postfix} }}`, command_topic: true, - command_topic_prefix: 'left', + command_topic_prefix: postfix, + json_attributes: [`button_${postfix}`], }, - }, - 'switch_right': { - type: 'switch', - object_id: 'switch_right', - discovery_payload: { - payload_off: 'OFF', - payload_on: 'ON', - value_template: '{{ value_json.state_right }}', - command_topic: true, - command_topic_prefix: 'right', - }, - }, + }; }; // Map homeassitant configurations to devices. @@ -223,7 +216,7 @@ const mapping = { 'WXKG03LM': [configurations.sensor_click], 'WXKG02LM': [configurations.sensor_click], 'QBKG04LM': [configurations.switch], - 'QBKG03LM': [configurations.switch_left, configurations.switch_right], + 'QBKG03LM': [switchWithPostfix('left'), switchWithPostfix('right')], 'WSDCGQ01LM': [configurations.sensor_temperature, configurations.sensor_humidity], 'WSDCGQ11LM': [configurations.sensor_temperature, configurations.sensor_humidity, configurations.sensor_pressure], 'RTCGQ01LM': [configurations.binary_sensor_occupancy], @@ -281,7 +274,7 @@ const mapping = { 'SL 110 W': [configurations.light_brightness], 'AA68199': [configurations.light_brightness_colortemp], 'QBKG11LM': [configurations.switch, configurations.sensor_power], - 'QBKG12LM': [configurations.switch_left, configurations.switch_right, configurations.sensor_power], + 'QBKG12LM': [switchWithPostfix('left'), switchWithPostfix('right'), configurations.sensor_power], 'K2RGBW01': [configurations.light_brightness_colortemp_xy], '9290011370': [configurations.light_brightness], 'DNCKATSW001': [configurations.switch], @@ -300,6 +293,13 @@ const mapping = { 'AC03641': [configurations.light_brightness], 'FB56+ZSW05HG1.2': [configurations.switch], '72922-A': [configurations.switch], + 'AC03642': [configurations.light_brightness_colortemp], + 'DNCKATSW002': [switchWithPostfix('left'), switchWithPostfix('right')], + 'DNCKATSW003': [switchWithPostfix('left'), switchWithPostfix('right'), switchWithPostfix('center')], + 'DNCKATSW004': [ + switchWithPostfix('bottom_left'), switchWithPostfix('bottom_right'), + switchWithPostfix('top_left'), switchWithPostfix('top_right'), + ], }; // A map of all discoverd devices diff --git a/npm-shrinkwrap.json b/npm-shrinkwrap.json index 20320909..1f156655 100644 --- a/npm-shrinkwrap.json +++ b/npm-shrinkwrap.json @@ -293,9 +293,9 @@ "integrity": "sha1-BDP0TYCWgP3rYO0mDxsMJi6CpAs=" }, "commander": { - "version": "2.16.0", - "resolved": "https://registry.npmjs.org/commander/-/commander-2.16.0.tgz", - "integrity": "sha512-sVXqklSaotK9at437sFlFpyOcJonxe0yST/AG9DkQKUdIE6IqGIMv4SfAQSKaJbSdVEJYItASCrBiVQHq1HQew==" + "version": "2.17.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.17.0.tgz", + "integrity": "sha512-477o1hdVORiFlZxw8wgsXYCef3lh0zl/OV0FTftqiDxJSWw6dPQ2ipS4k20J2qBcsmsmLKSyr2iFrf9e3JGi4w==" }, "commist": { "version": "1.0.0", @@ -516,9 +516,9 @@ "dev": true }, "eslint": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-5.2.0.tgz", - "integrity": "sha512-zlggW1qp7/TBjwLfouRoY7eWXrXwJZFqCdIxxh0/LVB/QuuKuIMkzyUZEcDo6LBadsry5JcEMxIqd3H/66CXVg==", + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-5.3.0.tgz", + "integrity": "sha512-N/tCqlMKkyNvAvLu+zI9AqDasnSLt00K+Hu8kdsERliC9jYEc8ck12XtjvOXrBKu8fK6RrBcN9bat6Xk++9jAg==", "dev": true, "requires": { "ajv": "6.5.2", @@ -552,7 +552,7 @@ "path-is-inside": "1.0.2", "pluralize": "7.0.0", "progress": "2.0.0", - "regexpp": "1.1.0", + "regexpp": "2.0.0", "require-uncached": "1.0.3", "semver": "5.5.0", "string.prototype.matchall": "2.0.0", @@ -1470,9 +1470,9 @@ } }, "regexpp": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/regexpp/-/regexpp-1.1.0.tgz", - "integrity": "sha512-LOPw8FpgdQF9etWMaAfG/WRthIdXJGYp4mJ2Jgn/2lpkbod9jPn0t9UqN7AxBOKNfzRbYyVfgc7Vk4t/MpnXgw==", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/regexpp/-/regexpp-2.0.0.tgz", + "integrity": "sha512-g2FAVtR8Uh8GO1Nv5wpxW7VFVwHcCEr4wyA8/MHiRkO8uHoR5ntAA8Uq3P1vvMTX/BeQiRVSpDGLd+Wn5HNOTA==", "dev": true }, "reinterval": { @@ -1566,7 +1566,7 @@ "integrity": "sha1-QhxhiophK9QM+kYbSkYVTa8iKaU=", "requires": { "bindings": "1.2.1", - "commander": "2.16.0", + "commander": "2.17.0", "debug": "2.6.9", "lie": "3.3.0", "nan": "2.10.0", @@ -1884,7 +1884,7 @@ "bundled": true, "requires": { "chalk": "1.1.3", - "commander": "2.16.0", + "commander": "2.17.0", "is-my-json-valid": "2.15.0", "pinkie-promise": "2.0.1" }, @@ -2866,9 +2866,9 @@ } }, "zigbee-shepherd-converters": { - "version": "2.0.36", - "resolved": "https://registry.npmjs.org/zigbee-shepherd-converters/-/zigbee-shepherd-converters-2.0.36.tgz", - "integrity": "sha512-69Bc1W35NJjwvAIHP1n+lT6vVbQbihvZ6fX7DysV+GQAynIcRGYvsBMRZSuStCXOMOT7Q5NkFqTgcV420WakVg==", + "version": "2.0.37", + "resolved": "https://registry.npmjs.org/zigbee-shepherd-converters/-/zigbee-shepherd-converters-2.0.37.tgz", + "integrity": "sha512-XwWmU0687upUuvo54LZYEgMqmx/reGBQxF2a1kkeTsE39DbM8bElDqpk/1Bhi11jK6DTa1JwnZMF0SNY2C6ZQA==", "requires": { "debounce": "1.1.0" },