Fix shell running
This commit is contained in:
+4
-3
@@ -11,7 +11,8 @@ ws.on('message', msg => {
|
|||||||
if (data.state) {
|
if (data.state) {
|
||||||
let device = config.wsDevices.find(device => device.uniqueId === data.uniqueid)
|
let device = config.wsDevices.find(device => device.uniqueId === data.uniqueid)
|
||||||
if (device) {
|
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}`)
|
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}`,
|
axios.post(`${config.servers.influx.url}/api/v2/write?orgID=${config.servers.influx.orgId}&bucket=${config.servers.influx.bucket}`,
|
||||||
influxPayload,
|
influxPayload,
|
||||||
@@ -29,7 +30,7 @@ ws.on('message', msg => {
|
|||||||
if (device.openScript && data.state[device.valueKey]){
|
if (device.openScript && data.state[device.valueKey]){
|
||||||
console.log("Running open script")
|
console.log("Running open script")
|
||||||
try {
|
try {
|
||||||
console.log(exec.execSync(device.openScript).toString())
|
exec.exec(device.openScript)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error)
|
console.error(error)
|
||||||
}
|
}
|
||||||
@@ -39,4 +40,4 @@ ws.on('message', msg => {
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error)
|
console.error(error)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user