Fix shell running
This commit is contained in:
+4
-3
@@ -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)
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user