Closed neo3 closed 4 years ago
The output from cputemp isn't correct, it should look like this
cputemp
42 C
config.json
{ "accessory": "Dht", "name": "Raspberry", "service": "Temperature", "cputemp": "/usr/local/bin/temperatura.sh" }
Test in the Terminal
pi@afccasa:/usr/local/bin $ /usr/local/bin/temperatura.sh 60 C
The same error still happens.
Not sure what's happening on your machine....
test.js
var exec = require('child_process').execFile;
exec("cputemp", function(error, responseBody, stderr) {
if (error !== null) {
console.log('cputemp function failed: ' + error);
} else {
var binaryState = parseFloat(responseBody);
console.log("Got Temperature of %s", binaryState);
}
}.bind(this));
node test.js
Got Temperature of 45
In the index.js file cputemp was not quoted and after some testing I saw that the function was not getting my custom script. So I modified it for this:
exec("/home/pi/cputemp", function(error, responseBody, stderr)
With this workaround, is it working for you?
On Dec 19, 2019, at 10:22 AM, neo3 notifications@github.com wrote:
In the index.js file cputemp was not quoted and after some testing I saw that the function was not getting my custom script. So I modified it for this:
exec("/home/pi/cputemp", function(error, responseBody, stderr)
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/NorthernMan54/homebridge-dht/issues/43?email_source=notifications&email_token=AEXEFGCE6W3NYQC3EMOWCHDQZOGR7A5CNFSM4J4OFN22YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEHJ6AUI#issuecomment-567533649, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEXEFGHEEKQLP3NMGZ75KBDQZOGR7ANCNFSM4J4OFN2Q.
Yes, thanks!
config.json
Log
Test in the Terminal