node-red-contrib-deconz
Advanced tools
Comparing version 2.3.4 to 2.3.5
@@ -10,2 +10,8 @@ # Changelog | ||
## [2.3.5] - 2022-09-12 ![Relative date](https://img.shields.io/date/1662979773?label=) | ||
### Fixed | ||
- Fix HomeKit attributes Lock Target State and Lock Current State for door lock. (#213) @Zehir | ||
## [2.3.4] - 2022-08-07 ![Relative date](https://img.shields.io/date/1659874532?label=) | ||
@@ -12,0 +18,0 @@ |
@@ -77,7 +77,7 @@ const NODE_PATH = '/node-red-contrib-deconz/'; | ||
try { | ||
if (forceRefresh) await controller.discoverDevices({forceRefresh: true}); | ||
if (forceRefresh) await controller.discoverDevices({ forceRefresh: true }); | ||
if (query === undefined) { | ||
res.json({items: controller.device_list.getAllDevices()}); | ||
res.json({ items: controller.device_list.getAllDevices() }); | ||
} else { | ||
res.json({items: controller.device_list.getDevicesByQuery(query)}); | ||
res.json({ items: controller.device_list.getDevicesByQuery(query) }); | ||
} | ||
@@ -147,3 +147,3 @@ } catch (e) { | ||
res.json({count: count, sample: sample}); | ||
res.json({ count: count, sample: sample }); | ||
} else { | ||
@@ -166,4 +166,4 @@ res.status(404).end(); | ||
let sample = {homekit: {}}; | ||
let count = {homekit: {}}; | ||
let sample = { homekit: {} }; | ||
let count = { homekit: {} }; | ||
@@ -190,3 +190,3 @@ const formatter = (new HomeKitFormatter.fromDeconz({})); | ||
res.json({count, sample}); | ||
res.json({ count, sample }); | ||
} else { | ||
@@ -229,3 +229,3 @@ res.status(404).end(); | ||
if (server === undefined) { | ||
res.json({errors: [`Could not find the server node.`]}); | ||
res.json({ errors: [`Could not find the server node.`] }); | ||
return; | ||
@@ -238,3 +238,3 @@ } | ||
} else { | ||
res.json({errors: [`The server node is not ready. Please check the server configuration.`]}); | ||
res.json({ errors: [`The server node is not ready. Please check the server configuration.`] }); | ||
} | ||
@@ -266,3 +266,3 @@ } catch (e) { | ||
if (controller && controller.constructor.name === "ServerNode") { | ||
let fakeNode = {server: controller}; | ||
let fakeNode = { server: controller }; | ||
let cp = new CommandParser(config.command, {}, fakeNode); | ||
@@ -273,3 +273,3 @@ let devices = []; | ||
if (device) { | ||
devices.push({data: device}); | ||
devices.push({ data: device }); | ||
} else { | ||
@@ -276,0 +276,0 @@ console.warn(`Error : Device not found : '${path}'`); |
@@ -12,5 +12,5 @@ const OutputMsgFormatter = require("../src/runtime/OutputMsgFormatter"); | ||
specific: { | ||
method: {type: 'GET'}, | ||
endpoint: {type: 'str', value: '/'}, | ||
payload: {type: 'json', value: '{}'} | ||
method: { type: 'GET' }, | ||
endpoint: { type: 'str', value: '/' }, | ||
payload: { type: 'json', value: '{}' } | ||
} | ||
@@ -93,3 +93,3 @@ }; | ||
// Do request | ||
const response = await node.server.api.doRequest(endpoint, {method, body: payload}); | ||
const response = await node.server.api.doRequest(endpoint, { method, body: payload }); | ||
@@ -96,0 +96,0 @@ // Add output properties |
@@ -140,3 +140,3 @@ const OutputMsgFormatter = require("../src/runtime/OutputMsgFormatter"); | ||
let formatter = new OutputMsgFormatter(rule, NodeType, this.config); | ||
let msgToSend = formatter.getMsgs({data: device, changed}, rawEvent, options); | ||
let msgToSend = formatter.getMsgs({ data: device, changed }, rawEvent, options); | ||
@@ -143,0 +143,0 @@ // Make sure that the result is an array |
@@ -92,3 +92,3 @@ const ConfigMigration = require("../src/migration/ConfigMigration"); | ||
for (let path of node.config.device_list) { | ||
devices.push({data: node.server.device_list.getDeviceByPath(path)}); | ||
devices.push({ data: node.server.device_list.getDeviceByPath(path) }); | ||
} | ||
@@ -105,3 +105,3 @@ break; | ||
for (let r of node.server.device_list.getDevicesByQuery(querySrc).matched) { | ||
devices.push({data: r}); | ||
devices.push({ data: r }); | ||
} | ||
@@ -108,0 +108,0 @@ } catch (e) { |
@@ -141,3 +141,3 @@ const OutputMsgFormatter = require("../src/runtime/OutputMsgFormatter"); | ||
let formatter = new OutputMsgFormatter(rule, NodeType, this.config); | ||
let msgToSend = formatter.getMsgs({data: device, changed}, rawEvent, options); | ||
let msgToSend = formatter.getMsgs({ data: device, changed }, rawEvent, options); | ||
@@ -144,0 +144,0 @@ // Make sure that the result is an array |
@@ -14,24 +14,24 @@ const CommandParser = require("../src/runtime/CommandParser"); | ||
arg: { | ||
on: {type: 'keep', value: ""}, | ||
alert: {type: 'str', value: ""}, | ||
effect: {type: 'str', value: ""}, | ||
colorloopspeed: {type: 'num', value: ""}, | ||
open: {type: 'keep', value: ""}, | ||
stop: {type: 'keep', value: ""}, | ||
lift: {type: 'num', value: ""}, | ||
tilt: {type: 'num', value: ""}, | ||
group: {type: 'num', value: ""}, | ||
scene: {type: 'num', value: ""}, | ||
target: {type: 'state', value: ""}, | ||
command: {type: 'str', value: "on"}, | ||
payload: {type: 'msg', value: "payload"}, | ||
delay: {type: 'num', value: "2000"}, | ||
transitiontime: {type: 'num', value: ""}, | ||
retryonerror: {type: 'num', value: "0"}, | ||
aftererror: {type: 'continue', value: ""}, | ||
bri: {direction: 'set', type: 'num', value: ""}, | ||
sat: {direction: 'set', type: 'num', value: ""}, | ||
hue: {direction: 'set', type: 'num', value: ""}, | ||
ct: {direction: 'set', type: 'num', value: ""}, | ||
xy: {direction: 'set', type: 'json', value: "[]"} | ||
on: { type: 'keep', value: "" }, | ||
alert: { type: 'str', value: "" }, | ||
effect: { type: 'str', value: "" }, | ||
colorloopspeed: { type: 'num', value: "" }, | ||
open: { type: 'keep', value: "" }, | ||
stop: { type: 'keep', value: "" }, | ||
lift: { type: 'num', value: "" }, | ||
tilt: { type: 'num', value: "" }, | ||
group: { type: 'num', value: "" }, | ||
scene: { type: 'num', value: "" }, | ||
target: { type: 'state', value: "" }, | ||
command: { type: 'str', value: "on" }, | ||
payload: { type: 'msg', value: "payload" }, | ||
delay: { type: 'num', value: "2000" }, | ||
transitiontime: { type: 'num', value: "" }, | ||
retryonerror: { type: 'num', value: "0" }, | ||
aftererror: { type: 'continue', value: "" }, | ||
bri: { direction: 'set', type: 'num', value: "" }, | ||
sat: { direction: 'set', type: 'num', value: "" }, | ||
hue: { direction: 'set', type: 'num', value: "" }, | ||
ct: { direction: 'set', type: 'num', value: "" }, | ||
xy: { direction: 'set', type: 'json', value: "[]" } | ||
} | ||
@@ -50,4 +50,4 @@ }; | ||
specific: { | ||
delay: {type: 'num', value: '50'}, | ||
result: {type: 'at_end', value: ''} | ||
delay: { type: 'num', value: '50' }, | ||
result: { type: 'at_end', value: '' } | ||
} | ||
@@ -126,3 +126,3 @@ }; | ||
if (device) { | ||
devices.push({data: device}); | ||
devices.push({ data: device }); | ||
} else { | ||
@@ -142,3 +142,3 @@ done(`Error : Device not found : '${path}'`); | ||
for (let r of node.server.device_list.getDevicesByQuery(querySrc).matched) { | ||
devices.push({data: r}); | ||
devices.push({ data: r }); | ||
} | ||
@@ -145,0 +145,0 @@ } catch (e) { |
@@ -10,3 +10,3 @@ const got = require('got'); | ||
const Utils = require("../src/runtime/Utils"); | ||
const {setIntervalAsync, clearIntervalAsync} = require('set-interval-async/fixed'); | ||
const { setIntervalAsync, clearIntervalAsync } = require('set-interval-async/fixed'); | ||
@@ -73,3 +73,3 @@ module.exports = function (RED) { | ||
let pooling = async () => { | ||
let result = await node.discoverDevices({forceRefresh: true}); | ||
let result = await node.discoverDevices({ forceRefresh: true }); | ||
if (result === true) { | ||
@@ -191,3 +191,3 @@ if (node.state.pooling.isValid === false) { | ||
try { | ||
let mainConfig = await got(node.api.url.main(), {retry: 1, timeout: 2000}).json(); | ||
let mainConfig = await got(node.api.url.main(), { retry: 1, timeout: 2000 }).json(); | ||
try { | ||
@@ -412,3 +412,3 @@ let group0 = await got(node.api.url.main() + node.api.url.groups.main(0), { | ||
news.device, | ||
{initialEvent: true} | ||
{ initialEvent: true } | ||
); | ||
@@ -807,3 +807,3 @@ break; | ||
credentials: { | ||
secured_apikey: {type: "text"} | ||
secured_apikey: { type: "text" } | ||
} | ||
@@ -810,0 +810,0 @@ }); |
{ | ||
"name": "node-red-contrib-deconz", | ||
"version": "2.3.4", | ||
"version": "2.3.5", | ||
"description": "deCONZ connectivity nodes for node-red", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -37,3 +37,3 @@ const dotProp = require('dot-prop'); | ||
if (this.handler === undefined || !this.handler.migrate) { | ||
return {errors: [`Configuration migration handler not found for node type '${this.type}'.`]}; | ||
return { errors: [`Configuration migration handler not found for node type '${this.type}'.`] }; | ||
} | ||
@@ -55,3 +55,3 @@ | ||
} else { | ||
return {notNeeded: true}; | ||
return { notNeeded: true }; | ||
} | ||
@@ -58,0 +58,0 @@ } |
@@ -34,3 +34,3 @@ const ConfigMigrationHandler = require('./ConfigMigrationHandler'); | ||
}, | ||
{type: 'homekit', onstart: true, onerror: true} | ||
{ type: 'homekit', onstart: true, onerror: true } | ||
]; | ||
@@ -37,0 +37,0 @@ this.result.delete.push('state'); |
@@ -347,3 +347,3 @@ const ConfigMigrationHandler = require('./ConfigMigrationHandler'); | ||
case 'num': | ||
command.arg.colorloopspeed = {type: 'num'}; | ||
command.arg.colorloopspeed = { type: 'num' }; | ||
if (isNaN(parseInt(this.config.payload))) { | ||
@@ -396,3 +396,3 @@ this.result.errors.push(`Invalid value '${this.config.payload}' for option 'colorloopspeed'`); | ||
if (this.config.payload === 'stop') { | ||
command.arg.lift = {type: 'stop'}; | ||
command.arg.lift = { type: 'stop' }; | ||
} else if (isNaN(parseInt(this.config.payload))) { | ||
@@ -445,5 +445,5 @@ this.result.errors.push(`Invalid value '${this.config.payload}' for option 'lift'`); | ||
) | ||
command.arg.on = {type: 'set', value: 'true'}; | ||
command.arg.on = { type: 'set', value: 'true' }; | ||
if (this.config.command === 'bri' && !isNaN(this.config.payload)) | ||
command.arg.on = {type: 'set', value: Number(this.config.payload) > 0 ? 'true' : 'false'}; | ||
command.arg.on = { type: 'set', value: Number(this.config.payload) > 0 ? 'true' : 'false' }; | ||
break; | ||
@@ -478,3 +478,3 @@ | ||
command.type = 'custom'; | ||
command.arg.target = {type: 'state'}; | ||
command.arg.target = { type: 'state' }; | ||
command.arg.command = { | ||
@@ -491,3 +491,3 @@ type: 'str', | ||
command.type = 'custom'; | ||
command.arg.target = {type: 'state'}; | ||
command.arg.target = { type: 'state' }; | ||
command.arg.command = { | ||
@@ -504,4 +504,4 @@ type: 'msg', | ||
command.type = 'custom'; | ||
command.arg.target = {type: 'state'}; | ||
command.arg.command = {type: 'object'}; | ||
command.arg.target = { type: 'state' }; | ||
command.arg.command = { type: 'object' }; | ||
command.arg.payload = { | ||
@@ -528,3 +528,3 @@ type: this.config.payloadType, | ||
case 'num': | ||
command.arg.transition = {type: 'num'}; | ||
command.arg.transition = { type: 'num' }; | ||
if (this.config.transitionTime === '') { | ||
@@ -540,3 +540,3 @@ command.arg.transition.value = ''; | ||
if (typeof this.config.transitionTimeType === 'undefined') { | ||
command.arg.transition = {type: 'num'}; | ||
command.arg.transition = { type: 'num' }; | ||
} else { | ||
@@ -555,7 +555,7 @@ this.result.errors.push(`Invalid value type '${this.config.transitionTimeType}' for option 'transition'`); | ||
command.arg.aftererror = {type: 'continue'}; | ||
command.arg.aftererror = { type: 'continue' }; | ||
this.result.new.commands = [command]; | ||
this.result.new.specific = { | ||
delay: {type: 'num', value: 50}, | ||
result: {type: 'at_end'}, | ||
delay: { type: 'num', value: 50 }, | ||
result: { type: 'at_end' }, | ||
}; | ||
@@ -572,3 +572,3 @@ this.config_version = 1; | ||
if (command.type === 'deconz_state' && command.domain === 'scene_call') { | ||
command.arg.scene_mode = {type: 'single', value: ''}; | ||
command.arg.scene_mode = { type: 'single', value: '' }; | ||
} | ||
@@ -575,0 +575,0 @@ newCommands[i] = command; |
@@ -296,3 +296,3 @@ /** | ||
} | ||
return {H, S, V}; | ||
return { H, S, V }; | ||
}; | ||
@@ -360,3 +360,3 @@ | ||
} | ||
return {R, G, B}; | ||
return { R, G, B }; | ||
}; | ||
@@ -405,3 +405,3 @@ | ||
return {H, S, L}; | ||
return { H, S, L }; | ||
}; | ||
@@ -469,3 +469,3 @@ | ||
} | ||
return {R, G, B}; | ||
return { R, G, B }; | ||
}; | ||
@@ -501,3 +501,3 @@ | ||
} | ||
return {H, S, I}; | ||
return { H, S, I }; | ||
}; | ||
@@ -539,3 +539,3 @@ | ||
} | ||
return {R, G, B}; | ||
return { R, G, B }; | ||
}; | ||
@@ -638,3 +638,3 @@ | ||
return {R, G, B}; | ||
return { R, G, B }; | ||
}; | ||
@@ -662,3 +662,3 @@ | ||
B = 200 * (Y - Z); | ||
return {L, A, B}; | ||
return { L, A, B }; | ||
}; | ||
@@ -711,3 +711,3 @@ | ||
V = 13 * (L) * (v1 - Colorspace.WHITEPOINT_V); | ||
return {L, U, V}; | ||
return { L, U, V }; | ||
}; | ||
@@ -738,3 +738,3 @@ | ||
Z = (Y) * ((3 - 0.75 * U) / V - 5); | ||
return {X, Y, Z}; | ||
return { X, Y, Z }; | ||
}; | ||
@@ -760,3 +760,3 @@ | ||
if (H < 0) H += 360; | ||
return {L, C, H}; | ||
return { L, C, H }; | ||
}; | ||
@@ -763,0 +763,0 @@ |
@@ -114,3 +114,3 @@ const Utils = require("./Utils"); | ||
break; | ||
default : | ||
default: | ||
this.result.state[k] = Number(value); | ||
@@ -117,0 +117,0 @@ break; |
@@ -123,3 +123,3 @@ const got = require('got'); | ||
let response = {log: []}; | ||
let response = { log: [] }; | ||
@@ -148,8 +148,8 @@ response.log.push(`Fetching data from '${this.url.discover()}'.`); | ||
for (const result of discoverResult) { | ||
guesses.push({secured: false, ip: result.internalipaddress, ports: [result.internalport]}); | ||
guesses.push({ secured: false, ip: result.internalipaddress, ports: [result.internalport] }); | ||
} | ||
} | ||
if (this.ip !== 'localhost') { | ||
guesses.push({secured: false, ip: 'localhost', ports: [80, 443, 8080]}); | ||
guesses.push({secured: true, ip: 'localhost', ports: [80, 443, 8080]}); | ||
guesses.push({ secured: false, ip: 'localhost', ports: [80, 443, 8080] }); | ||
guesses.push({ secured: true, ip: 'localhost', ports: [80, 443, 8080] }); | ||
} | ||
@@ -160,3 +160,3 @@ for (const ip of ['core-deconz.local.hass.io', 'homeassistant.local']) { | ||
if (!ports.includes(this.port)) ports.unshift(this.port); | ||
guesses.push({secured: false, ip, ports}); | ||
guesses.push({ secured: false, ip, ports }); | ||
} | ||
@@ -353,3 +353,3 @@ } | ||
retry: 1, | ||
json: {devicetype: devicetype}, | ||
json: { devicetype: devicetype }, | ||
responseType: 'json', | ||
@@ -376,3 +376,3 @@ timeout: 2000 | ||
try { | ||
const discover = await this.doRequest(this.url.config.main(), {timeout}); | ||
const discover = await this.doRequest(this.url.config.main(), { timeout }); | ||
return keyName === undefined ? discover.body : discover.body[keyName]; | ||
@@ -379,0 +379,0 @@ } catch (e) { |
@@ -6,12 +6,12 @@ const EventEmitter = require('events'); | ||
constructor({ | ||
hostname, | ||
port = 443, | ||
token, | ||
secure = false, | ||
pingInterval = 10000, | ||
pingTimeout = 3000, | ||
reconnectInterval = 10000, | ||
reconnectMaxRetries = Infinity, | ||
autoConnect = true | ||
} = {}) { | ||
hostname, | ||
port = 443, | ||
token, | ||
secure = false, | ||
pingInterval = 10000, | ||
pingTimeout = 3000, | ||
reconnectInterval = 10000, | ||
reconnectMaxRetries = Infinity, | ||
autoConnect = true | ||
} = {}) { | ||
super(); | ||
@@ -18,0 +18,0 @@ |
@@ -83,3 +83,3 @@ const Query = require('./Query'); | ||
createQuery(device) { | ||
return {device_path: this.getPathByDevice(device)}; | ||
return { device_path: this.getPathByDevice(device) }; | ||
} | ||
@@ -86,0 +86,0 @@ |
@@ -139,10 +139,10 @@ const dotProp = require("dot-prop"); | ||
switch (dotProp.get(rawEvent, 'state.buttonevent') % 1000) { | ||
case 1 : // Hold Down | ||
case 1: // Hold Down | ||
return 2; // Long Press | ||
case 2: // Short press | ||
return 0; // Single Press | ||
case 4 : // Double press | ||
case 5 : // Triple press | ||
case 6 : // Quadtruple press | ||
case 10 : // Many press | ||
case 4: // Double press | ||
case 5: // Triple press | ||
case 6: // Quadtruple press | ||
case 10: // Many press | ||
/* | ||
@@ -201,3 +201,3 @@ * Merge all many press event to 1 because homekit only support double press events. | ||
.services(['Heater Cooler', 'Thermostat']) | ||
.needDeviceMeta({type: 'ZHAThermostat'}) | ||
.needDeviceMeta({ type: 'ZHAThermostat' }) | ||
.needEventMeta('config.heatsetpoint') | ||
@@ -212,3 +212,3 @@ .to((rawEvent, deviceMeta) => | ||
.services(['Heater Cooler', 'Thermostat']) | ||
.needDeviceMeta({type: 'ZHAThermostat'}) | ||
.needDeviceMeta({ type: 'ZHAThermostat' }) | ||
.needEventMeta('config.coolsetpoint') | ||
@@ -223,3 +223,3 @@ .to((rawEvent, deviceMeta) => | ||
.services('Thermostat') | ||
.needDeviceMeta({type: 'ZHAThermostat'}) | ||
.needDeviceMeta({ type: 'ZHAThermostat' }) | ||
.needEventMeta((rawEvent, deviceMeta) => | ||
@@ -263,3 +263,3 @@ dotProp.has(rawEvent, 'config.heatsetpoint') || | ||
.services('Heater Cooler') | ||
.needDeviceMeta({type: 'ZHAThermostat'}) | ||
.needDeviceMeta({ type: 'ZHAThermostat' }) | ||
.needEventMeta('state.on') | ||
@@ -274,3 +274,3 @@ .to((rawEvent, deviceMeta) => { | ||
.services('Thermostat') | ||
.needDeviceMeta({type: 'ZHAThermostat'}) | ||
.needDeviceMeta({ type: 'ZHAThermostat' }) | ||
.needEventMeta('state.on') | ||
@@ -299,3 +299,3 @@ .to((rawEvent, deviceMeta) => { | ||
.services('Thermostat') | ||
.needDeviceMeta({type: 'ZHAThermostat'}) | ||
.needDeviceMeta({ type: 'ZHAThermostat' }) | ||
.needEventMeta('config.mode') | ||
@@ -321,3 +321,3 @@ .to((rawEvent, deviceMeta) => { | ||
.services('Heater Cooler') | ||
.needDeviceMeta({type: 'ZHAThermostat'}) | ||
.needDeviceMeta({ type: 'ZHAThermostat' }) | ||
.needEventMeta('config.locked') | ||
@@ -333,3 +333,3 @@ .to((rawEvent, deviceMeta) => dotProp.get(rawEvent, 'config.locked') === true ? 1 : 0) | ||
.priority(10) | ||
.needDeviceMeta({type: 'ZHAThermostat'}) | ||
.needDeviceMeta({ type: 'ZHAThermostat' }) | ||
.to((rawEvent, deviceMeta) => 0); // Celsius | ||
@@ -340,3 +340,3 @@ HKF.TemperatureDisplayUnits_Fahrenheit = new Attribute() | ||
.priority(0) | ||
.needDeviceMeta({type: 'ZHAThermostat'}) | ||
.needDeviceMeta({ type: 'ZHAThermostat' }) | ||
.to((rawEvent, deviceMeta) => 1); // Fahrenheit | ||
@@ -348,3 +348,7 @@ //#endregion | ||
.needDeviceMeta((deviceMeta) => { | ||
return !['Window covering controller', 'Window covering device'].includes(deviceMeta.type); | ||
return ![ | ||
'Window covering controller', | ||
'Window covering device', | ||
'Door Lock' | ||
].includes(deviceMeta.type); | ||
}); | ||
@@ -368,3 +372,3 @@ HKF.Brightness = new Attribute() | ||
.needColorCapabilities(['hs', 'unknown']) | ||
.needDeviceMeta({'state.colormode': 'hs'}) | ||
.needDeviceMeta({ 'state.colormode': 'hs' }) | ||
.to((rawEvent, deviceMeta) => { | ||
@@ -383,3 +387,3 @@ if (dotProp.get(rawEvent, 'state.on') !== true) return; | ||
.needColorCapabilities(['hs', 'unknown']) | ||
.needDeviceMeta({'state.colormode': 'hs'}) | ||
.needDeviceMeta({ 'state.colormode': 'hs' }) | ||
.to((rawEvent, deviceMeta) => { | ||
@@ -397,3 +401,3 @@ if (dotProp.get(rawEvent, 'state.on') !== true) return; | ||
.needColorCapabilities(['ct', 'unknown']) | ||
.needDeviceMeta({'state.colormode': 'ct'}); | ||
.needDeviceMeta({ 'state.colormode': 'ct' }); | ||
//#endregion | ||
@@ -412,3 +416,3 @@ //#region Window cover | ||
.services('Window Covering') | ||
.needDeviceMeta({type: ['Window covering controller', 'Window covering device']}) | ||
.needDeviceMeta({ type: ['Window covering controller', 'Window covering device'] }) | ||
.needEventMeta('state.tilt') | ||
@@ -425,3 +429,3 @@ .to((rawEvent, deviceMeta) => | ||
.services('Window Covering') | ||
.needDeviceMeta({type: ['Window covering controller', 'Window covering device']}) | ||
.needDeviceMeta({ type: ['Window covering controller', 'Window covering device'] }) | ||
.to((rawEvent, deviceMeta) => 2); // Stopped | ||
@@ -439,28 +443,28 @@ //#endregion | ||
HKF.LockTargetState = new Attribute() | ||
.services('Lock Mechanism') | ||
.to((rawEvent, deviceMeta) => { | ||
const map = { | ||
false : 0, | ||
true : 1 | ||
}; | ||
return map[dotProp.get(deviceMeta, 'config.lock')]; | ||
}) | ||
.from((value, allValues, result) => { | ||
const map = { | ||
0 : false, | ||
1 : true | ||
}; | ||
dotProp.set(result, 'config.lock', map[value]); | ||
}); | ||
.services('Lock Mechanism') | ||
.needDeviceMeta({ type: 'Door Lock' }) | ||
.to((rawEvent, deviceMeta) => { | ||
const map = { | ||
false: 0, | ||
true: 1 | ||
}; | ||
return map[dotProp.get(deviceMeta, 'state.on')]; | ||
}) | ||
.from((value, allValues, result) => { | ||
const map = { | ||
0: false, | ||
1: true | ||
}; | ||
dotProp.set(result, 'state.on', map[value]); | ||
}); | ||
HKF.LockCurrentState = new Attribute() | ||
.services('Lock Mechanism') | ||
.needEventMeta('state.lockstate') | ||
.needDeviceMeta({ type: 'Door Lock' }) | ||
.needEventMeta('state.on') | ||
.to((rawEvent, deviceMeta) => { | ||
const map = { | ||
"locked" : 1, | ||
"unlocked" : 0, | ||
"undefined" : 3, | ||
"not fully locked" : 2 | ||
false : 0, | ||
true : 1 | ||
}; | ||
const result = map[dotProp.get(rawEvent, 'state.lockstate')]; | ||
const result = map[dotProp.get(rawEvent, 'state.on')]; | ||
return result !== undefined ? result : map.undefined; | ||
@@ -579,2 +583,2 @@ }); | ||
module.exports = {fromDeconz, toDeconz}; | ||
module.exports = { fromDeconz, toDeconz }; |
@@ -97,6 +97,6 @@ const dotProp = require('dot-prop'); | ||
break; | ||
case 'average' : | ||
case 'average': | ||
case 'sum': | ||
case 'min' : | ||
case 'max' : | ||
case 'min': | ||
case 'max': | ||
let mergeData; | ||
@@ -125,6 +125,6 @@ let mergeMethod; | ||
break; | ||
case 'min' : | ||
case 'min': | ||
mergeMethod = Math.min; | ||
break; | ||
case 'max' : | ||
case 'max': | ||
mergeMethod = Math.max; | ||
@@ -168,3 +168,3 @@ break; | ||
isSingleValue = true; | ||
mergeData('', msg.payload, msg.payload_count, {value: data.payload}, mergeMethod); | ||
mergeData('', msg.payload, msg.payload_count, { value: data.payload }, mergeMethod); | ||
} | ||
@@ -171,0 +171,0 @@ } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
557540
7839