NorthernMan54 / homebridge-dht

Homebridge plugin for DHT22 Temperature / Humidity Sensors
73 stars 14 forks source link

cputemp is not working #43

Closed neo3 closed 4 years ago

neo3 commented 4 years ago

config.json

{ "accessory": "Dht", "name": "cputemp", "service": "Temperature" }

Log

[2019-12-18 3:03:44 PM] [Sensor] DHT Status: 0, Temperature: 27.2°C, Humidity: 51.6% [2019-12-18 3:03:44 PM] [cputemp] Got Temperature of NaN

Test in the Terminal

pi@afccasa:~ $ /usr/local/bin/cputemp CPU temperature: 58.534 °C

NorthernMan54 commented 4 years ago

The output from cputemp isn't correct, it should look like this

cputemp
42 C
neo3 commented 4 years ago

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.

NorthernMan54 commented 4 years ago

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
neo3 commented 4 years ago

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)

NorthernMan54 commented 4 years ago

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.

neo3 commented 4 years ago

Yes, thanks!