Fix shell running

This commit is contained in:
Liz
2025-10-25 10:50:37 -04:00
parent 7e61941789
commit ac21d0dc46
+4 -3
View File
@@ -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)
}
})
})