From 399ab6105b68691a1ddb7007e14fbe840e9aabd2 Mon Sep 17 00:00:00 2001 From: Claudio Chimera Date: Thu, 14 Oct 2021 17:01:57 +0200 Subject: [PATCH] Fix Contact Sensor, updateStatusIcon --- alexa/alexa-adapter.js | 60 +++++++-- alexa/alexa-device.js | 109 ++++++++++++--- test/flows.json | 297 +++++++++++++++++++++++++++++++---------- 3 files changed, 370 insertions(+), 96 deletions(-) diff --git a/alexa/alexa-adapter.js b/alexa/alexa-adapter.js index 01dca7e..cd2af25 100644 --- a/alexa/alexa-adapter.js +++ b/alexa/alexa-adapter.js @@ -82,6 +82,11 @@ module.exports = function (RED) { const RULE_TRIGGER = 'RULE_TRIGGER'; const VOICE_INTERACTION = 'VOICE_INTERACTION'; + const PROPERTIES_MAPPING = { + motionDetectionState: ['Alexa.MotionSensor', 'detectionState'], + contactDetectionState: ['Alexa.ContactSensor', 'detectionState'] + }; + class AlexaAdapterNode { constructor(config) { RED.nodes.createNode(this, config); @@ -659,8 +664,8 @@ module.exports = function (RED) { if (node.config.verbose) node._debug(" CCHI directive " + namespace + " " + name + " " + JSON.stringify(req.body.directive.payload)); try { let cmd_res = {}; - const changed_propertie_names = node.devices[endpointId].execDirective(header, req.body.directive.payload, cmd_res); - if (changed_propertie_names !== undefined) { + const changed_property_names = node.devices[endpointId].execDirective(header, req.body.directive.payload, cmd_res); + if (changed_property_names !== undefined) { node.get_access_token('evn') .then(access_token => { const r_namespace = cmd_res['namespace']; @@ -676,7 +681,7 @@ module.exports = function (RED) { // if (node.config.verbose) node._debug("CCHI report_state async response NOT SENT YET " + JSON.stringify(report_state)); if (r_name != 'DeferredResponse' && r_name != 'ErrorResponse' && r_namespace != "Alexa.SceneController") { process.nextTick(() => { - node.send_change_report(endpointId, changed_propertie_names, VOICE_INTERACTION, cmd_res).then(() => { }); + node.send_change_report(endpointId, changed_property_names, VOICE_INTERACTION, cmd_res).then(() => { }); }); } }) @@ -1254,22 +1259,22 @@ module.exports = function (RED) { // // // - send_change_report(endpointId, changed_propertie_names, reason, cmd_res, namespace, name) { + send_change_report(endpointId, changed_property_names, reason, cmd_res, namespace, name) { // https://github.com/alexa/alexa-smarthome/blob/master/sample_async/python/sample_async.py // https://developer.amazon.com/en-US/docs/alexa/smarthome/state-reporting-for-a-smart-home-skill.html // https://developer.amazon.com/en-US/docs/alexa/smarthome/send-events-to-the-alexa-event-gateway.html var node = this; return new Promise((resolve, reject) => { if (node.config.verbose) node._debug('send_change_report ' + endpointId); - if (changed_propertie_names === undefined) { - changed_propertie_names = []; + if (changed_property_names === undefined) { + changed_property_names = []; } - else if (typeof changed_propertie_names === 'string') { - changed_propertie_names = [changed_propertie_names]; + else if (typeof changed_property_names === 'string') { + changed_property_names = [changed_property_names]; } node.get_access_token('evn') .then(access_token => { - let state = node.get_change_report(endpointId, namespace, name, undefined, changed_propertie_names, reason); + let state = node.get_change_report(endpointId, namespace, name, undefined, changed_property_names, reason); node.objectMerge(state, cmd_res); if (node.config.verbose) node._debug('send_change_report state ' + JSON.stringify(state)); if (node.config.verbose) node._debug('send_change_report to event_endpoint ' + node.config.event_endpoint); @@ -1508,17 +1513,46 @@ module.exports = function (RED) { // // // - get_change_report(endpointId, namespace, name, messageId, changed_propertie_names, reason) { + get_mapped_property(namespace, name) { + Object.keys(PROPERTIES_MAPPING).forEach(i_name => { + if (PROPERTIES_MAPPING[i_name][1] === name && PROPERTIES_MAPPING[i_name][0] === namespace) { + name = i_name; + } + }); + return name; + } + + // + // + // + // + is_changed_property(name, namespace, changed_property_names) { + if (changed_property_names.includes(name)) { + return true; + } + let res = false; + Object.keys(PROPERTIES_MAPPING).forEach(key => { + if (PROPERTIES_MAPPING[key][1] === name && PROPERTIES_MAPPING[key][0] === namespace && changed_property_names.includes(key)) { + res = true; + } + }); + return res; + } + // + // + // + // + get_change_report(endpointId, namespace, name, messageId, changed_property_names, reason) { var node = this; let changed_properties = []; let unchanged_properties = []; let payload = {}; const oauth2_bearer_token = node.tokens.evn.access_token; const properties = node.devices[endpointId].getProperties(); - if (node.config.verbose) node._debug('endpointId ' + endpointId + ' properties ' + JSON.stringify(properties)); - if (changed_propertie_names && changed_propertie_names.length > 0) { + if (node.config.verbose) node._debug('get_change_report endpointId ' + endpointId + ' properties ' + JSON.stringify(properties)); + if (changed_property_names.length > 0) { properties.forEach(property => { - if (changed_propertie_names && changed_propertie_names.includes(property.name)) { + if (node.is_changed_property(property.name, property.namespace, changed_property_names)) { changed_properties.push(property); } else { unchanged_properties.push(property); diff --git a/alexa/alexa-device.js b/alexa/alexa-device.js index 3ebcd82..8aabdef 100644 --- a/alexa/alexa-device.js +++ b/alexa/alexa-device.js @@ -74,6 +74,7 @@ module.exports = function (RED) { if (node.isVerbose()) node._debug("(on-close) " + node.config.name); node.onClose(removed, done); }); + node.updateStatusIcon(); } // @@ -277,9 +278,9 @@ module.exports = function (RED) { if (node.isVerbose()) node._debug("Alexa.ColorController"); node.addCapability("Alexa.ColorController", { color: { - "hue": 350.5, - "saturation": 0.7138, - "brightness": 0.6524 + hue: 350.5, + saturation: 0.7138, + brightness: 0.6524 } }); } @@ -299,8 +300,6 @@ module.exports = function (RED) { if (node.isVerbose()) node._debug("Alexa.ContactSensor"); node.addCapability("Alexa.ContactSensor", { detectionState: 'NOT_DETECTED' - }, undefined, { - detectionState: 'contactDetectionState' }); } @@ -491,8 +490,6 @@ module.exports = function (RED) { if (node.isVerbose()) node._debug("Alexa.MotionSensor"); node.addCapability("Alexa.MotionSensor", { detectionState: 'NOT_DETECTED' // DETECTED - }, undefined, { - detectionState: 'motionDetectionState' }); } // PercentageController @@ -692,7 +689,7 @@ module.exports = function (RED) { // // // - getCapability(iface, properties_val, properties_map) { + getCapability(iface, properties_val) { var node = this; let capability = { type: "AlexaInterface", @@ -700,12 +697,11 @@ module.exports = function (RED) { version: "3", }; if (properties_val) { - if (typeof properties_map === 'undefined') { - properties_map = {}; - } let supported = []; Object.keys(properties_val).forEach(key => { - node.state[properties_map[key] || key] = properties_val[key]; + const mapped_key = node.alexa.get_mapped_property(iface, key); + console.log("CCHI TOOOOOOOOOOOOOOOOOOOOOOOOOOOOO TODO mapped_key " + iface + ' ' + key + " . " + mapped_key) + node.state[mapped_key] = properties_val[key]; supported.push({ name: key }); @@ -723,9 +719,9 @@ module.exports = function (RED) { // // // - addCapability(iface, properties_val, attributes, properties_map) { + addCapability(iface, properties_val, attributes) { var node = this; - let capability = node.getCapability(iface, properties_val, properties_map); + let capability = node.getCapability(iface, properties_val); if (attributes !== undefined) { Object.assign(capability, attributes); } @@ -744,6 +740,7 @@ module.exports = function (RED) { const name = header['name'] if (node.isVerbose()) node._debug("execDirective state before " + name + "/" + namespace + " " + JSON.stringify(node.state)); let modified = undefined; + let send_state_in_out = true; let event_payload = {}; let res_payload = {}; cmd_res['event'] = { @@ -922,6 +919,7 @@ module.exports = function (RED) { cmd_res["name"] = "DeferredResponse"; event_payload['estimatedDeferralInSeconds'] = 15; modified = []; + send_state_in_out = false; process.nextTick(() => { if (node.isVerbose()) node._debug("execDirective send_change_report"); // TODO manage response @@ -931,6 +929,7 @@ module.exports = function (RED) { modified = node.setValues({ powerState: 'ON' }, node.state); + node.sendState(modified, payload, namespace, name); node.alexa.send_change_report(node.id, [], "VOICE_INTERACTION", { event: { header: { @@ -1122,7 +1121,7 @@ module.exports = function (RED) { } - if (modified !== undefined) { + if (send_state_in_out && modified !== undefined) { node.sendState(modified, payload, namespace, name); } @@ -1349,6 +1348,85 @@ module.exports = function (RED) { return properties; } + // + // + // + // + updateStatusIcon() { + const node = this; + let text = ''; + let fill = 'blue'; + let shape = 'dot'; + if (node.state.powerState !== undefined) { + if (node.state.powerState === 'ON') { + text = 'ON'; + fill = 'green'; + } else { + text = 'OFF'; + fill = 'red'; + } + } + if (node.state.powerLevel !== undefined) { + text += " P: " + node.state.powerLevel; + } + if (node.state.brightness !== undefined) { + text += " bri: " + node.state.brightness; + } + if (node.state.colorTemperatureInKelvin !== undefined) { + text += ' temp: ' + node.state.colorTemperatureInKelvin; + } + if (node.state.color !== undefined) { + text += ' H: ' + node.state.color.hue + + ' S: ' + node.state.color.saturation + + ' B: ' + node.state.color.brightness; + } + if (node.state.lockState !== undefined) { + text += ' ' + node.state.lockState; + } + if (node.state.armState !== undefined) { + text += ' ' + node.state.armState; + } + if (node.state.percentage !== undefined) { + text += ' ' + node.state.percentage + "% "; + } + if (node.state.volume !== undefined) { + text += ' vol: ' + node.state.volume; + } + if (node.state.muted !== undefined && node.state.muted) { + text += ' M'; + } + if (node.state.temperature !== undefined) { + text += ' T: ' + node.state.temperature.value; + } + if (node.state.targetSetpoint !== undefined) { + text += ' TS: ' + node.state.targetSetpoint.value; + } + + if (node.state.lowerSetpoint !== undefined && node.state.upperSetpoint !== undefined) { + text += ' TS: [' + node.state.lowerSetpoint.value + ',' + node.state.upperSetpoint.value + ']'; + } + + if (node.state.motionDetectionState !== undefined) { + text += node.state.motionDetectionState === 'DETECTED' ? ' MOTION' : ' NO MOTION'; + } + + if (node.state.contactDetectionState !== undefined) { + text += node.state.contactDetectionState === 'DETECTED' ? ' CONTACT' : ' NO CONTACT'; + } + if (node.state.connectivity !== undefined) { + if (node.state.connectivity === 'UNREACHABLE') { + fill = 'red'; + } else if (fill !== 'red') { + fill = 'green'; + } + } + + if (!text) { + text = 'Unknown'; + } + node.status({ fill: fill, shape: shape, text: text }); + } + // // // @@ -1422,6 +1500,7 @@ module.exports = function (RED) { } } }); + node.updateStatusIcon(); return differs; } diff --git a/test/flows.json b/test/flows.json index 5e05599..20690ef 100644 --- a/test/flows.json +++ b/test/flows.json @@ -103,7 +103,7 @@ ], "i_automation_management": true, "i_brightness_controller": false, - "i_camera_stream_controller": true, + "i_camera_stream_controller": false, "i_channel_controller": false, "i_color_controller": false, "i_color_temperature_controller": false, @@ -131,7 +131,7 @@ "MORE" ], "i_lock_controller": false, - "i_media_metadata": true, + "i_media_metadata": false, "i_meter": true, "i_mode_controller": true, "i_motion_sensor": false, @@ -147,12 +147,12 @@ "Rewind", "FastForward" ], - "i_power_controller": false, - "i_power_level_controller": false, + "i_power_controller": true, + "i_power_level_controller": true, "i_range_controller": true, "i_rtc_session_controller": false, - "i_scene_controller": false, - "i_security_panel_controller": true, + "i_scene_controller": true, + "i_security_panel_controller": false, "i_speaker": false, "i_step_speaker": false, "i_temperature_sensor": false, @@ -219,10 +219,10 @@ "standby_wattage": "1", "maximum_wattage": "10", "arm_state": [ - "ARMED_AWAY", + "DISARMED", "ARMED_STAY", "ARMED_NIGHT", - "DISARMED" + "ARMED_AWAY" ], "alarms": [ "burglaryAlarm", @@ -232,8 +232,12 @@ ], "pin_code": "1234", "exit_delay": "10", - "x": 430, - "y": 700, + "mac_addresses": [ + "1.2.3.4", + "5.6.7.8" + ], + "x": 410, + "y": 960, "wires": [ [ "21a10626.9a490a" @@ -316,7 +320,7 @@ "id": "21a10626.9a490a", "type": "debug", "z": "5cc6ca02.0e2a64", - "name": "", + "name": "Output", "active": true, "tosidebar": true, "console": false, @@ -325,8 +329,8 @@ "targetType": "full", "statusVal": "", "statusType": "auto", - "x": 590, - "y": 700, + "x": 770, + "y": 960, "wires": [] }, { @@ -2383,8 +2387,8 @@ "topic": "reportState", "payload": "reportState", "payloadType": "str", - "x": 200, - "y": 700, + "x": 180, + "y": 960, "wires": [ [ "58c096a.8fa0d68" @@ -2412,8 +2416,8 @@ "topic": "SetMedia", "payload": "{\"id\":\"1\",\"cause\":\"cause of media creation\",\"recording\":{\"name\":\"Optional video name\",\"startTime\":\"2018-06-29T19:20:41Z\",\"endTime\":\"2018-06-29T19:21:41Z\",\"videoCodec\":\"H264\",\"audioCodec\":\"AAC\",\"uri\":{\"value\":\"https://somedomain/somevideo.mp4\",\"expireTime\":\"2018-06-29T19:31:41Z\"},\"thumbnailUri\":{\"value\":\"https://somedomain/someimage.png\",\"expireTime\":\"2018-06-29T19:31:41Z\"}}}", "payloadType": "json", - "x": 230, - "y": 620, + "x": 210, + "y": 880, "wires": [ [ "58c096a.8fa0d68" @@ -2441,8 +2445,8 @@ "topic": "SetMedia", "payload": "{\"id\":\"2\",\"cause\":\"cause of media creation\",\"recording\":{\"name\":\"Optional video name\",\"startTime\":\"2018-06-29T19:20:41Z\",\"endTime\":\"2018-06-29T19:21:41Z\",\"videoCodec\":\"H264\",\"audioCodec\":\"AAC\",\"uri\":{\"value\":\"https://somedomain/somevideo.mp4\",\"expireTime\":\"2018-06-29T19:31:41Z\"},\"thumbnailUri\":{\"value\":\"https://somedomain/someimage.png\",\"expireTime\":\"2018-06-29T19:31:41Z\"}}}", "payloadType": "json", - "x": 230, - "y": 660, + "x": 210, + "y": 920, "wires": [ [ "58c096a.8fa0d68" @@ -2470,8 +2474,8 @@ "topic": "AddOrUpdateMedia", "payload": "{\"id\":\"1\",\"cause\":\"cause of media creation\",\"recording\":{\"name\":\"Optional video name\",\"startTime\":\"2018-06-29T19:20:41Z\",\"endTime\":\"2018-06-29T19:21:41Z\",\"videoCodec\":\"H264\",\"audioCodec\":\"AAC\",\"uri\":{\"value\":\"https://somedomain/somevideo.mp4\",\"expireTime\":\"2018-06-29T19:31:41Z\"},\"thumbnailUri\":{\"value\":\"https://somedomain/someimage.png\",\"expireTime\":\"2018-06-29T19:31:41Z\"}}}", "payloadType": "json", - "x": 200, - "y": 740, + "x": 180, + "y": 1000, "wires": [ [ "58c096a.8fa0d68" @@ -2499,8 +2503,8 @@ "topic": "AddOrUpdateMedia", "payload": "{\"id\":\"2\",\"cause\":\"cause of media creation\",\"recording\":{\"name\":\"Optional video name\",\"startTime\":\"2018-06-29T19:20:41Z\",\"endTime\":\"2018-06-29T19:21:41Z\",\"videoCodec\":\"H264\",\"audioCodec\":\"AAC\",\"uri\":{\"value\":\"https://somedomain/somevideo.mp4\",\"expireTime\":\"2018-06-29T19:31:41Z\"},\"thumbnailUri\":{\"value\":\"https://somedomain/someimage.png\",\"expireTime\":\"2018-06-29T19:31:41Z\"}}}", "payloadType": "json", - "x": 200, - "y": 780, + "x": 180, + "y": 1040, "wires": [ [ "58c096a.8fa0d68" @@ -2528,8 +2532,8 @@ "topic": "SetMedia", "payload": "[]", "payloadType": "json", - "x": 240, - "y": 580, + "x": 220, + "y": 840, "wires": [ [ "58c096a.8fa0d68" @@ -2557,8 +2561,8 @@ "topic": "RemoveMedia", "payload": "1", "payloadType": "str", - "x": 220, - "y": 820, + "x": 200, + "y": 1080, "wires": [ [ "58c096a.8fa0d68" @@ -2586,8 +2590,8 @@ "topic": "RemoveMedia", "payload": "2", "payloadType": "str", - "x": 220, - "y": 860, + "x": 200, + "y": 1120, "wires": [ [ "58c096a.8fa0d68" @@ -2615,8 +2619,8 @@ "topic": "RemoveMedia", "payload": "3", "payloadType": "str", - "x": 220, - "y": 900, + "x": 200, + "y": 1160, "wires": [ [ "58c096a.8fa0d68" @@ -2641,7 +2645,7 @@ "payload": "{\"directive\":{\"header\":{\"namespace\":\"Alexa.CameraStreamController\",\"name\":\"InitializeCameraStreams\",\"payloadVersion\":\"3\",\"messageId\":\"d1aabb49-a0e8-4327-b4de-0b35136dc8a0\",\"correlationToken\":\"mio_correlation_token\"},\"endpoint\":{\"scope\":{\"type\":\"BearerToken\",\"token\":\"Atza|access_token-own\"},\"endpointId\":\"58c096a.8fa0d68\",\"cookie\":{}},\"payload\":{\"cameraStreams\":[{\"authorizationType\":\"NONE\",\"protocol\":\"RTSP\",\"videoCodec\":\"JPG\",\"audioCodec\":\"G711\",\"resolution\":{\"width\":1920,\"height\":1080}}]}}}", "payloadType": "json", "x": 170, - "y": 460, + "y": 540, "wires": [ [ "691dc41b.b1bb1c" @@ -2669,8 +2673,8 @@ "topic": "cameraStreams", "payload": "{\"cameraStreams\":[{\"uri\":\"https://pizza.dynu.net/hls/bbb.m3u8\",\"expirationTime\":\"2022-02-03T16:20:50.52Z\",\"idleTimeoutSeconds\":30,\"protocol\":\"HLS\",\"resolution\":{\"width\":1920,\"height\":1080},\"authorizationType\":\"NONE\",\"videoCodec\":\"H264\",\"audioCodec\":\"AAC\"}],\"imageUri\":\"https://upload.wikimedia.org/wikipedia/commons/f/fb/Veduta_di_Paestum_2010.jpg\"}", "payloadType": "json", - "x": 220, - "y": 540, + "x": 200, + "y": 800, "wires": [ [ "58c096a.8fa0d68" @@ -2695,7 +2699,7 @@ "payload": "{\"directive\":{\"header\":{\"namespace\":\"Alexa.CameraStreamController\",\"name\":\"InitializeCameraStreams\",\"payloadVersion\":\"3\",\"messageId\":\"d1aabb49-a0e8-4327-b4de-0b35136dc8a0\",\"correlationToken\":\"mio_correlation_token\"},\"endpoint\":{\"scope\":{\"type\":\"BearerToken\",\"token\":\"Atza|access_token-own\"},\"endpointId\":\"58c096a.8fa0d68\",\"cookie\":{}},\"payload\":{\"cameraStreams\":[{\"authorizationType\":\"NONE\",\"protocol\":\"HLS\",\"videoCodec\":\"H264\",\"audioCodec\":\"AAC\",\"resolution\":{\"width\":1920,\"height\":1080}}]}}}", "payloadType": "json", "x": 180, - "y": 420, + "y": 500, "wires": [ [ "691dc41b.b1bb1c" @@ -2780,7 +2784,7 @@ "payload": "{\"directive\":{\"header\":{\"namespace\":\"Alexa.CameraStreamController\",\"name\":\"InitializeCameraStreams\",\"payloadVersion\":\"3\",\"messageId\":\"d1aabb49-a0e8-4327-b4de-0b35136dc8a0\",\"correlationToken\":\"mio_correlation_token\"},\"endpoint\":{\"scope\":{\"type\":\"BearerToken\",\"token\":\"Atza|access_token-own\"},\"endpointId\":\"58c096a.8fa0d68\",\"cookie\":{}},\"payload\":{\"cameraStreams\":[{\"authorizationType\":\"NONE\",\"protocol\":\"HLS\",\"videoCodec\":\"H264\",\"audioCodec\":\"AAC\",\"resolution\":{\"width\":1920,\"height\":1080}}]}}}", "payloadType": "json", "x": 190, - "y": 340, + "y": 420, "wires": [ [ "691dc41b.b1bb1c" @@ -2800,7 +2804,7 @@ "persist": false, "proxy": "", "authType": "", - "x": 590, + "x": 610, "y": 280, "wires": [ [ @@ -2812,7 +2816,7 @@ "id": "1633b4b4.8bc82b", "type": "debug", "z": "5cc6ca02.0e2a64", - "name": "", + "name": "Response", "active": true, "tosidebar": true, "console": false, @@ -2821,7 +2825,7 @@ "targetType": "msg", "statusVal": "", "statusType": "auto", - "x": 890, + "x": 880, "y": 280, "wires": [] }, @@ -2859,7 +2863,7 @@ "payload": "{\"directive\":{\"header\":{\"namespace\":\"Alexa.MediaMetadata\",\"name\":\"GetMediaMetadata\",\"messageId\":\"123-456-789\",\"correlationToken\":\"token\",\"payloadVersion\":\"3\"},\"endpoint\":{\"scope\":{\"type\":\"BearerToken\",\"token\":\"Atza|access_token-own\"},\"endpointId\":\"58c096a.8fa0d68\",\"cookie\":{}},\"payload\":{\"filters\":{\"mediaIds\":[\"media Ids\",\"1\",\"2\",\"3\"]}}}}", "payloadType": "json", "x": 210, - "y": 380, + "y": 460, "wires": [ [ "691dc41b.b1bb1c" @@ -2870,7 +2874,7 @@ "id": "691dc41b.b1bb1c", "type": "change", "z": "5cc6ca02.0e2a64", - "name": "endpointId", + "name": "endpointId Multi", "rules": [ { "t": "set", @@ -2892,7 +2896,7 @@ "from": "", "to": "", "reg": false, - "x": 430, + "x": 440, "y": 280, "wires": [ [ @@ -2916,11 +2920,12 @@ "once": false, "onceDelay": 0.1, "topic": "getState", - "x": 240, - "y": 500, + "x": 220, + "y": 760, "wires": [ [ - "58c096a.8fa0d68" + "58c096a.8fa0d68", + "d8f22efa.dde0a" ] ] }, @@ -2941,8 +2946,8 @@ "topic": "", "payload": "{\"powerState\": \"ON\"}", "payloadType": "json", - "x": 210, - "y": 940, + "x": 190, + "y": 1200, "wires": [ [ "58c096a.8fa0d68" @@ -2966,8 +2971,8 @@ "topic": "", "payload": "{\"powerState\": \"OFF\"}", "payloadType": "json", - "x": 200, - "y": 980, + "x": 180, + "y": 1240, "wires": [ [ "58c096a.8fa0d68" @@ -3007,7 +3012,7 @@ "id": "2616a91b.32ee96", "type": "debug", "z": "5cc6ca02.0e2a64", - "name": "", + "name": "Event GW", "active": true, "tosidebar": true, "console": false, @@ -3173,8 +3178,8 @@ "topic": "SetSecurityDeviceNamesInError", "payload": "[\"Finestra Cucina\",\"Finestra Bagno\"]", "payloadType": "json", - "x": 170, - "y": 1020, + "x": 150, + "y": 1280, "wires": [ [ "58c096a.8fa0d68" @@ -3188,7 +3193,7 @@ "alexa": "a2728c12.4058f", "name": "Finestra Cucina", "display_categories": [ - "DOOR" + "CONTACT_SENSOR" ], "topic": "", "a_inputs": [ @@ -3212,7 +3217,7 @@ "i_channel_controller": "", "i_color_controller": "", "i_color_temperature_controller": "", - "i_contact_sensor": "", + "i_contact_sensor": true, "i_doorbell_event_source": "", "i_endpoint_health": "", "i_equalizer_controller": "", @@ -3227,7 +3232,7 @@ "i_media_metadata": "", "i_meter": "", "i_mode_controller": "", - "i_motion_sensor": "", + "i_motion_sensor": true, "i_percentage_controller": "", "i_playback_controller": "", "a_playback_modes": [], @@ -3263,7 +3268,9 @@ "x": 540, "y": 780, "wires": [ - [] + [ + "21a10626.9a490a" + ] ] }, { @@ -3273,7 +3280,7 @@ "alexa": "a2728c12.4058f", "name": "Finestra Bagno", "display_categories": [ - "DOOR" + "CONTACT_SENSOR" ], "topic": "", "a_inputs": [ @@ -3297,7 +3304,7 @@ "i_channel_controller": "", "i_color_controller": "", "i_color_temperature_controller": "", - "i_contact_sensor": "", + "i_contact_sensor": true, "i_doorbell_event_source": "", "i_endpoint_health": "", "i_equalizer_controller": "", @@ -3312,7 +3319,7 @@ "i_media_metadata": "", "i_meter": "", "i_mode_controller": "", - "i_motion_sensor": "", + "i_motion_sensor": true, "i_percentage_controller": "", "i_playback_controller": "", "a_playback_modes": [], @@ -3348,7 +3355,9 @@ "x": 540, "y": 840, "wires": [ - [] + [ + "21a10626.9a490a" + ] ] }, { @@ -3372,8 +3381,8 @@ "topic": "AddSecurityDeviceNamesInError", "payload": "[\"Finestra Cucina\",\"Finestra Salotto\",\"Finestra Bagno\"]", "payloadType": "json", - "x": 170, - "y": 1060, + "x": 150, + "y": 1320, "wires": [ [ "58c096a.8fa0d68" @@ -3401,8 +3410,8 @@ "topic": "DelSecurityDeviceNamesInError", "payload": "[\"Finestra Cucina\",\"Finestra Bagno\"]", "payloadType": "json", - "x": 170, - "y": 1100, + "x": 150, + "y": 1360, "wires": [ [ "58c096a.8fa0d68" @@ -3416,7 +3425,7 @@ "alexa": "a2728c12.4058f", "name": "Finestra Salotto", "display_categories": [ - "DOOR" + "CONTACT_SENSOR" ], "topic": "", "a_inputs": [ @@ -3440,7 +3449,7 @@ "i_channel_controller": "", "i_color_controller": "", "i_color_temperature_controller": "", - "i_contact_sensor": "", + "i_contact_sensor": true, "i_doorbell_event_source": "", "i_endpoint_health": "", "i_equalizer_controller": "", @@ -3455,7 +3464,7 @@ "i_media_metadata": "", "i_meter": "", "i_mode_controller": "", - "i_motion_sensor": "", + "i_motion_sensor": true, "i_percentage_controller": "", "i_playback_controller": "", "a_playback_modes": [], @@ -3491,7 +3500,159 @@ "x": 540, "y": 900, "wires": [ - [] + [ + "21a10626.9a490a" + ] + ] + }, + { + "id": "9ecf687b.d493d8", + "type": "inject", + "z": "5cc6ca02.0e2a64", + "name": "Activate", + "props": [ + { + "p": "payload" + } + ], + "repeat": "", + "crontab": "", + "once": false, + "onceDelay": 0.1, + "topic": "", + "payload": "{\"directive\":{\"header\":{\"namespace\":\"Alexa.SceneController\",\"name\":\"Activate\",\"messageId\":\"\",\"correlationToken\":\"\",\"payloadVersion\":\"3\"},\"endpoint\":{\"scope\":{\"type\":\"BearerToken\",\"token\":\"\"},\"endpointId\":\"\"},\"payload\":{}}}", + "payloadType": "json", + "x": 250, + "y": 320, + "wires": [ + [ + "691dc41b.b1bb1c" + ] + ] + }, + { + "id": "d4057e78.c21c7", + "type": "inject", + "z": "5cc6ca02.0e2a64", + "name": "Deactivate", + "props": [ + { + "p": "payload" + } + ], + "repeat": "", + "crontab": "", + "once": false, + "onceDelay": 0.1, + "topic": "", + "payload": "{\"directive\":{\"header\":{\"namespace\":\"Alexa.SceneController\",\"name\":\"Deactivate\",\"messageId\":\"\",\"correlationToken\":\"\",\"payloadVersion\":\"3\"},\"endpoint\":{\"scope\":{\"type\":\"BearerToken\",\"token\":\"\"},\"endpointId\":\"\"},\"payload\":{}}}", + "payloadType": "json", + "x": 240, + "y": 360, + "wires": [ + [ + "691dc41b.b1bb1c" + ] + ] + }, + { + "id": "44c4352a.655fac", + "type": "inject", + "z": "5cc6ca02.0e2a64", + "name": "TurnOn", + "props": [ + { + "p": "payload" + } + ], + "repeat": "", + "crontab": "", + "once": false, + "onceDelay": 0.1, + "topic": "", + "payload": "{\"directive\":{\"header\":{\"namespace\":\"Alexa.PowerController\",\"name\":\"TurnOn\",\"messageId\":\"\",\"correlationToken\":\"\",\"payloadVersion\":\"3\"},\"endpoint\":{\"scope\":{\"type\":\"BearerToken\",\"token\":\"\"},\"endpointId\":\"\",\"cookie\":{}},\"payload\":{}}}", + "payloadType": "json", + "x": 250, + "y": 580, + "wires": [ + [ + "691dc41b.b1bb1c" + ] + ] + }, + { + "id": "edde6ec9.e7153", + "type": "inject", + "z": "5cc6ca02.0e2a64", + "name": "TurnOff", + "props": [ + { + "p": "payload" + } + ], + "repeat": "", + "crontab": "", + "once": false, + "onceDelay": 0.1, + "topic": "", + "payload": "{\"directive\":{\"header\":{\"namespace\":\"Alexa.PowerController\",\"name\":\"TurnOff\",\"messageId\":\"\",\"correlationToken\":\"\",\"payloadVersion\":\"3\"},\"endpoint\":{\"scope\":{\"type\":\"BearerToken\",\"token\":\"\"},\"endpointId\":\"\",\"cookie\":{}},\"payload\":{}}}", + "payloadType": "json", + "x": 250, + "y": 620, + "wires": [ + [ + "691dc41b.b1bb1c" + ] + ] + }, + { + "id": "fd2d1fc9.a6156", + "type": "inject", + "z": "5cc6ca02.0e2a64", + "name": "contact DETECTED", + "props": [ + { + "p": "payload" + } + ], + "repeat": "", + "crontab": "", + "once": false, + "onceDelay": 0.1, + "topic": "", + "payload": "{\"contactDetectionState\":\"DETECTED\"}", + "payloadType": "json", + "x": 380, + "y": 720, + "wires": [ + [ + "d8f22efa.dde0a" + ] + ] + }, + { + "id": "480e2450.ff5bec", + "type": "inject", + "z": "5cc6ca02.0e2a64", + "name": "contact NOT_DETECTED", + "props": [ + { + "p": "payload" + } + ], + "repeat": "", + "crontab": "", + "once": false, + "onceDelay": 0.1, + "topic": "", + "payload": "{\"contactDetectionState\":\"NOT_DETECTED\"}", + "payloadType": "json", + "x": 390, + "y": 680, + "wires": [ + [ + "d8f22efa.dde0a" + ] ] } ] \ No newline at end of file