From ac21d0dc464054d0745c3b324e4197dd2fd3a97e Mon Sep 17 00:00:00 2001 From: Liz Date: Sat, 25 Oct 2025 10:50:37 -0400 Subject: [PATCH] Fix shell running --- watcher.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/watcher.js b/watcher.js index dc0a3a8..839f12c 100644 --- a/watcher.js +++ b/watcher.js @@ -11,7 +11,8 @@ ws.on('message', msg => { if (data.state) { let device = config.wsDevices.find(device => device.uniqueId === data.uniqueid) if (device) { - let influxPayload = `${device.name} ${device.influxKey}=${data.state[device.valueKey]?0:1}` + let payloadValue = (device.valueKey=='open')?(data.state['open']?0:1):data.state[device.valueKey] + let influxPayload = `${device.name} ${device.influxKey}=${payloadValue}` console.log(`${new Date().toString()} 👉🏻 Sending ${influxPayload}`) axios.post(`${config.servers.influx.url}/api/v2/write?orgID=${config.servers.influx.orgId}&bucket=${config.servers.influx.bucket}`, influxPayload, @@ -29,7 +30,7 @@ ws.on('message', msg => { if (device.openScript && data.state[device.valueKey]){ console.log("Running open script") try { - console.log(exec.execSync(device.openScript).toString()) + exec.exec(device.openScript) } catch (error) { console.error(error) } @@ -39,4 +40,4 @@ ws.on('message', msg => { } catch (error) { console.error(error) } -}) \ No newline at end of file +})