/** * @description Disconnect telegram API * @example * disconnect(); */ async function disconnect() { logger.debug('Disconnecting Telegram API'); if (this.bot) { await this.bot.stopPolling(); } this.bot = null; }
/** * @description Heal Zwave network * @example * zwave.healNetwork(); */ function healNetwork() { if (!this.connected) { throw new ServiceNotConfiguredError('ZWAVE_DRIVER_NOT_RUNNING'); } logger.debug(`Zwave : Heal network.`); this.zwave.healNetwork(); }
action.conditions.forEach((condition) => { const conditionVerified = compare(condition.operator, scope[condition.variable], condition.value); if (conditionVerified) { oneConditionVerified = true; } else { logger.debug( `Condition not verified. Condition = ${scope[condition.variable]} ${condition.operator} ${condition.value}`, ); } });
/** * @description TurnOn a given deviceFeature. * @param {Object} device - The device to turnOn. * @param {Object} deviceFeature - The deviceFeature to turnOn. * @example * light.turnOn(device, deviceFeature); */ async function turnOn(device, deviceFeature) { logger.debug(`Turning on the light of deviceFeature "${deviceFeature.selector}"`); await this.deviceManager.setValue(device, deviceFeature, STATE.ON); this.eventManager.emit(EVENTS.LIGHT.TURNED_ON, { device, deviceFeature }); }
/** * @description When the scan is complete * @example * zwave.on('scan complete', this.scanComplete); */ function scanComplete() { logger.debug(`Zwave : Scan Complete!`); this.scanInProgress = false; this.eventManager.emit(EVENTS.WEBSOCKET.SEND_ALL, { type: WEBSOCKET_MESSAGE_TYPES.ZWAVE.SCAN_COMPLETE, payload: {}, }); }
/** * @description Add node * @example * zwave.removeNode(); */ function removeNode() { logger.debug(`Zwave : Entering exclusion mode`); this.zwave.removeNode(); setTimeout(this.cancelControllerCommand.bind(this), REMOVE_NODE_TIMEOUT); }
/** * @description Set value. * @param {Object} device - The device to control. * @param {Object} deviceFeature - The device feature to control. * @param {number} value - The value to set. * @example * zwave.setValue(); */ function setValue(device, deviceFeature, value) { logger.debug(`Zwave : Setting value`); const { nodeId, comclass, index, instance } = getNodeInfoByExternalId(deviceFeature.external_id); this.zwave.setValue({ node_id: nodeId, class_id: comclass, instance, index }, value); }
/** * @description When a node event is received. * @param {number} nodeId - The ID of the node. * @param {Object} data - The event. * @example * zwave.on('node event', this.nodeEvent); */ function nodeEvent(nodeId, data) { logger.debug(`Zwave : Node Event, nodeId = ${nodeId}, data = ${data}`); }
/** * @description Request all params of a node. * @param {number} nodeId - The NodeId. * @example * zwave.refreshNodeParams(1); */ function refreshNodeParams(nodeId) { if (!this.connected) { throw new ServiceNotConfiguredError('ZWAVE_DRIVER_NOT_RUNNING'); } logger.debug(`Zwave : Request all params of nodeId = ${nodeId}`); this.zwave.requestAllConfigParams(nodeId); }
/** * @description Disconnect telegram API * @example * disconnect(); */ async function disconnect() { logger.debug('Disconnecting Telegram API'); if (this.bot) { await this.bot.stopPolling(); } this.bot = null; }
/** * @description Heal Zwave network * @example * zwave.healNetwork(); */ function healNetwork() { if (!this.connected) { throw new ServiceNotConfiguredError('ZWAVE_DRIVER_NOT_RUNNING'); } logger.debug(`Zwave : Heal network.`); this.zwave.healNetwork(); }
/** * @description Add node * @example * zwave.removeNode(); */ function removeNode() { logger.debug(`Zwave : Entering exclusion mode`); this.zwave.removeNode(); setTimeout(this.cancelControllerCommand.bind(this), REMOVE_NODE_TIMEOUT); }
/** * @description Notification about a node * @param {number} nodeId - The ID of the node. * @param {Object} notif - Number of the type of notification. * @example * zwave.on('notification', this.notification); */ function notification(nodeId, notif) { logger.debug(`Zwave : Notification, nodeId = ${nodeId}, notif = ${NOTIFICATION_TYPES[notif]}`); }
/** * @description When a node event is received. * @param {number} nodeId - The ID of the node. * @param {Object} data - The event. * @example * zwave.on('node event', this.nodeEvent); */ function nodeEvent(nodeId, data) { logger.debug(`Zwave : Node Event, nodeId = ${nodeId}, data = ${data}`); }
/** * @description Notification about a node * @param {number} nodeId - The ID of the node. * @param {Object} notif - Number of the type of notification. * @example * zwave.on('notification', this.notification); */ function notification(nodeId, notif) { logger.debug(`Zwave : Notification, nodeId = ${nodeId}, notif = ${NOTIFICATION_TYPES[notif]}`); }