diff --git a/example.config.json b/example.config.json index 8769d2d..d999b9b 100644 --- a/example.config.json +++ b/example.config.json @@ -27,7 +27,8 @@ "name": "", "uniqueId": "", "valueKey": "open", - "influxKey": "state" + "influxKey": "state", + "openScript": "this is optional" } ] } diff --git a/watcher.js b/watcher.js index a9bfb5b..9bafddc 100644 --- a/watcher.js +++ b/watcher.js @@ -1,6 +1,7 @@ import axios from 'axios' import WebSocket from 'ws' import fs from 'fs' +import exec from 'child_process' let config = JSON.parse(fs.readFileSync('config.json', 'utf8')) let ws = new WebSocket(`ws://${config.servers.deconz.url}:${config.servers.deconz.websocketPort}`) @@ -25,6 +26,14 @@ ws.on('message', msg => { }).catch(error => { console.error(error) }) + if (device.openScript){ + console.log("Running open script") + try { + console.log(exec.execSync(device.openScript).toString()) + } catch (error) { + console.error(error) + } + } } } } catch (error) {