Code Monkey home page Code Monkey logo

homebridge-dht's Introduction

NPM Downloads

Supports integration of a DHT11/DHT21/DHT22/DHT33/DHT44 Temperature/Humidity Sensor into hombridge via the BCM2835 library on a Raspberry PI. I have tried numerous other interface methods for the DHT22, and found that this was least problematic. Also includes optional reporting of the RaspBerry PI CPU Temperature. This latest version splits the temperature and humidity into separate sensors, so they are readable from the home screen icon. Historical display of temperature data is available via HomeKit apps thats support graphing.

Homebridge Nodes

Also support use of multiple DHT22's, see config.json fragment.

1 - Detailed build instructions

For detailed installation instructions, please see the build instructions

2 - Install and configure required libraries

Prior to installation of this plugin, the BCM2835 library needs to be installed. Detailed installation instructions are part way down the page

If you run homebridge as non-root user - add it to GPIO group: (in case in logs: bcm2835_init: Unable to open /dev/gpiomem: Permission denied)

sudo adduser homebridge gpio

3 - Installing the plugin

sudo npm install -g homebridge-dht

4 - Configure the Plugin

A minimal config.json looks like this

{
  "bridge": {
    "name": "Penny",
    "username": "CC:22:3D:E3:CD:33",
    "port": 51826,
    "pin": "031-45-154"
    },

    "description": "HomeBridge DHT22",

  "platforms": [],

  "accessories": [
  	{ "accessory": "Dht",
      "name":      "Outside"
     }
	]
}

Required Configuration options

  • accessory: must be Dht
  • name: descriptive name for the temperature sensor

Optional Configuration Options

  • service: dht22, dht11 or Temperature. dht22/dht11 reads local dht sensor, Temperature reads cputemp. Defaults to dht22
  • cputemp - Full command including path to read cpu temp sensor. Not needed unless cputemp is installed in a location not on the path. Defaults to cputemp
"cputemp": "/usr/local/bin/cputemp"
  • gpio - Gpio pin to read for dht sensor. Defaults to 4
"gpio": "4"
  • refresh - Frequency of data refresh in seconds. Defaults to 60 seconds
  • storage - Storage of chart graphing data for history graphing, either fs or googleDrive, defaults to fs
  • spreadsheetId - Log data to a google sheet, this is part of the URL of your spreadsheet. ie the spreadsheet ID in the URL https://docs.google.com/spreadsheets/d/abc1234567/edit#gid=0 is "abc1234567".

config.json Samples

Configuration - with RPI cpu temperature sensor, requires cputemp program ( Optional )

{
    "bridge": {
        "name": "Penny",
        "username": "CC:22:3D:E3:CD:33",
        "port": 51826,
        "pin": "031-45-154"
    },

    "description": "HomeBridge DHT22",

 "platforms": [],

   "accessories": [
	{ "accessory":        "Dht",
	  "name":             "cputemp",
	  "service":          "Temperature" },
	{ "accessory":        "Dht",
          "name":             "dht22",
          "service":          "dht22" }
	]
}

Configuration - without cputemp

{
    "bridge": {
        "name": "Penny",
        "username": "CC:22:3D:E3:CD:33",
        "port": 51826,
        "pin": "031-45-154"
    },

    "description": "HomeBridge DHT22",

 "platforms": [],

   "accessories": [
	{ "accessory":        "Dht",
          "name":             "dht22",
          "service":          "dht22" }
	]
}

or with multiple DHT22's

{ "accessory":   "Dht",
  "name":        "dht22 - indoor",
  "gpio":        "4",       
  "service":     "dht22" },
{ "accessory":   "Dht",
  "name":        "dht22 - outdoor",
  "gpio":        "2",   
  "service":     "dht22" }

Optional cputemp script - install in /usr/local/bin

#!/bin/bash
cpuTemp0=$(cat /sys/class/thermal/thermal_zone0/temp)
cpuTemp1=$(($cpuTemp0/1000))
cpuTemp2=$(($cpuTemp0/100))
cpuTempM=$(($cpuTemp2 % $cpuTemp1))

echo $cpuTemp1" C"

Output from the cputemp command

cputemp
42 C

ToDo

Optional - Enable access to Google to log data and store history charting data

This presumes you already have a google account, and have access to google drive/sheets already

Step 1: Turn on the Drive API a. Use this wizard ( https://console.developers.google.com/start/api?id=sheets.googleapis.com ) to create or select a project in the Google Developers Console and automatically turn on the API. Click Continue, then Go to credentials.

b. On the Add credentials to your project page, click the Cancel button.

c. At the top of the page, select the OAuth consent screen tab. Select an Email address, enter a Product name if not already set, and click the Save button. I used 'Sheets Data Logger'

d. Select the Credentials tab, click the Create credentials button and select OAuth client ID.

e. Select the application type Other, enter the name "Drive API Quickstart", and click the Create button.

f. Click OK to dismiss the resulting dialog.

g. Click the file_download (Download JSON) button to the right of the client ID.

h. Move this file to your .homebridge and rename it logger_client_secret.json.

Step 2: Authorize your computer to access your Drive Account

a. Change to the directory where the plugin is installed i.e.

cd /usr/lib/node_modules/homebridge-mcuiot/node_modules/mcuiot-logger

b. Run the authorization module

node quickstart.js

c. Browse to the provided URL in your web browser.

If you are not already logged into your Google account, you will be prompted to log in. If you are logged into multiple Google accounts, you will be asked to select one account to use for the authorization.

d. Click the Accept button.

e. Copy the code you're given, paste it into the command-line prompt, and press Enter.

Credits

  • rxseger - separate humidity sensor
  • hector305 - Multiple sensor testing
  • merdok - Removed duplicate humidity sensor.
  • tooodooo - Added device polling
  • simont77 - History Service

homebridge-dht's People

Contributors

adambowles avatar ishift avatar merdok avatar northernman54 avatar tooodooo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

homebridge-dht's Issues

Not showing humidity and temperature as two sensors on home screen (DHT22)

Yesterday I set up a new raspberry 3, installed homebridge and the homebridge-dht plugin. Everything works well so far. But on the home screen only temperature shows up. I can see humidity if I click on edit and then on the sensor icon. How can I get both temperature AND humidity readable from the home screen icon?

Not able to log temp/hum records

Even if I try to set it to "fs" and look for it in /var/homebride/persist/ or choose another directory, I'm not able to generate any kind of JSON record. Would like to use it with EVE app.

Install Error (user "root" does not have permission)

I get the error that the user "root" does not have permission to access the dev dir "/root/.node-gyp/8.16.0".

I previously installed the bcm2835 library.

> [email protected] preinstall /usr/lib/node_modules/homebridge-dht/node_modules/node-dht-sensor
> ./check-lib.sh

Library bcm2835 found.

> [email protected] install /usr/lib/node_modules/homebridge-dht/node_modules/node-dht-sensor
> node-gyp configure

gyp WARN EACCES user "root" does not have permission to access the dev dir "/root/.node-gyp/8.16.0"
gyp WARN EACCES attempting to reinstall using temporary dev dir "/usr/lib/node_modules/homebridge-dht/node_modules/node-dht-sensor/.node-gyp"
gyp WARN install got an error, rolling back install
gyp WARN install got an error, rolling back install
gyp ERR! configure error
gyp ERR! stack Error: EACCES: permission denied, mkdir '/usr/lib/node_modules/homebridge-dht/node_modules/node-dht-sensor/.node-gyp'
gyp ERR! System Linux 4.14.98-v7+
gyp ERR! command "/usr/bin/node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "configure"
gyp ERR! cwd /usr/lib/node_modules/homebridge-dht/node_modules/node-dht-sensor
gyp ERR! node -v v8.16.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: `node-gyp configure`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2019-05-14T16_47_56_210Z-debug.log

Installation error on RPi3 with Buster

Hi,

thank you for your plugin - but i got an error during installation.
I‘ve followed your instruction, installed bcm lib before, but i got an erren when installing your plugin on my Pi with Raspian Buster.

Here are the errors:
.......................................................................................................................................................................................
make: *** [node_dht_sensor.target.mk:110: Release/obj.target/node_dht_sensor/node-dht-sensor.o] Fehler 1
make: Verzeichnis „/usr/local/lib/node_modules/homebridge-dht-rpi/node_modules/node-dht-sensor/build“ wird verlassen
gyp ERR! build error
gyp ERR! stack Error: make failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:194:23)
gyp ERR! stack at ChildProcess.emit (events.js:210:5)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:272:12)
gyp ERR! System Linux 4.19.75-v7+
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "build"
gyp ERR! cwd /usr/local/lib/node_modules/homebridge-dht-rpi/node_modules/node-dht-sensor
gyp ERR! node -v v12.13.0
gyp ERR! node-gyp -v v5.0.5
gyp ERR! not ok
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] postinstall: node-gyp build
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] postinstall script.
.......................................................................................................................................................................................

And here is the complete terminal output:
Homebridge-DHT-Install-Error.txt

Error on install

Hi - I have working Homebridge Pi Zero but when I install this package I get the following error (see screenshot). I have installed other plugin's and they worked fine. I'm sure it's my mistake but I can't work it out.

Thanks

Mike

Annotation 2020-08-18 170507

Warning: characteristic 'Current Temperature':

Hello, thank you for all the effort. I have an issue I cannot seem to sort. I am running on a Raspberry Pi Zero.

The sensor is functional via dht22 command, but the errors in homebridge are still more common than readings. Readings are sucessful every 20-100 trys.

Homebridge version v1.3.4

Any thoughts would be much appreciated.

here is a copy of the diagnoistic log:

[3/25/2021, 8:54:26 PM] Homebridge v1.3.4 (Homebridge 1B9B) is running on port 51843.
[3/25/2021, 8:54:26 PM] [Room] read data from Room : {"firstEntry":0,"lastEntry":268,"usedMemory":268,"refTime":638313503,"initialTime":1616620703,"history":["noValue",{"time":1616620703,"setRefTime":1},{"temp":23.7,"humidity":43.1,"time":1616620703}

[3/25/2021, 8:54:26 PM] [Room] History Loaded from Persistant Storage
[3/25/2021, 8:54:27 PM] [Room] Error: [Error: failed to read sensor]
[3/25/2021, 8:54:29 PM] [homebridge-dht] This plugin generated a warning from the characteristic 'Current Temperature': characteristic value expected valid finite number and received "undefined" (undefined). See https://git.io/JtMGR for more info.
[3/25/2021, 8:54:29 PM] [homebridge-dht] Error:
at CurrentTemperature.Characteristic.characteristicWarning (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/src/lib/Characteristic.ts:2038:105)
at CurrentTemperature.Characteristic.validateUserInput (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/src/lib/Characteristic.ts:1931:16)
at CurrentTemperature.Characteristic.setValue (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/src/lib/Characteristic.ts:1298:20)
at TemperatureSensor.Service.setCharacteristic (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/src/lib/Service.ts:459:35)
at DhtAccessory. (/usr/local/lib/node_modules/homebridge-dht/index.js:193:14)
at DhtAccessory. (/usr/local/lib/node_modules/homebridge-dht/index.js:103:9)
[3/25/2021, 8:54:57 PM] [Room] Error: [Error: failed to read sensor]
[3/25/2021, 8:55:27 PM] [Room] Error: [Error: failed to read sensor]
[3/25/2021, 8:55:57 PM] [Room] Error: [Error: failed to read sensor]
[3/25/2021, 8:56:27 PM] [Room] Error: [Error: failed to read sensor]
[3/25/2021, 8:56:57 PM] [Room] Error: [Error: failed to read sensor]
[3/25/2021, 8:57:27 PM] [Room] Error: [Error: failed to read sensor]
[3/25/2021, 8:57:57 PM] [Room] Error: [Error: failed to read sensor]
[3/25/2021, 8:58:27 PM] [Room] Error: [Error: failed to read sensor]
[3/25/2021, 8:58:57 PM] [Room] Error: [Error: failed to read sensor]
[3/25/2021, 8:59:27 PM] [Room] Error: [Error: failed to read sensor]
[3/25/2021, 8:59:57 PM] [Room] Error: [Error: failed to read sensor]
[3/25/2021, 9:00:27 PM] [Room] Error: [Error: failed to read sensor]
[3/25/2021, 9:00:57 PM] [Room] Error: [Error: failed to read sensor]
[3/25/2021, 9:01:27 PM] [Room] Error: [Error: failed to read sensor]
[3/25/2021, 9:01:57 PM] [Room] Error: [Error: failed to read sensor]
[3/25/2021, 9:02:27 PM] [Room] Error: [Error: failed to read sensor]
[3/25/2021, 9:02:57 PM] [Room] Error: [Error: failed to read sensor]
[3/25/2021, 9:03:27 PM] [Room] Error: [Error: failed to read sensor]
[3/25/2021, 9:03:56 PM] [Room] DHT Status: 0, Temperature: 24.4°C, Humidity: 33.5%
[3/25/2021, 9:03:56 PM] [Room] **Fakegato-timer: addData Room { time: 1616702636, temp: 24.4, humidity: 33.5 } immediate: false
[3/25/2021, 9:03:56 PM] [Room] Start Global Fakegato-Timer - 5min
[3/25/2021, 9:04:27 PM] [Room] Error: [Error: failed to read sensor]
[3/25/2021, 9:04:57 PM] [Room] Error: [Error: failed to read sensor]
[3/25/2021, 9:05:27 PM] [Room] Error: [Error: failed to read sensor]

Request

Thank you for the plugin.
I have request.
Because iOS 13 is combining se sensor together can you make humidity and temperature as separate devices?

How to separate humidity from temperature

Since the penultimate update, humidity is showing up along with the temperature and I can't separate it.

My iPhone is on iOS 13.2.3 and does not have the option to separate, my homebridge config is:

    {
        "accessory": "Dht",
        "name": "Sensor",
        "name_temperature": "Temperatura",
        "name_humidity": "Umidade",
        "gpio": "23",
        "service": "dht22"
    }

Homebridge Dht
homebridge-dht v0.1.32

Update plugin to support 'Current Temperature' read handler?

Current Situation

Hello,
I use this plugin to run a script to retrieve some temps (not via a DHT sensor), and though it works fine, it does throw the following errors :

[12/6/2023, 6:05:28 PM] [homebridge-dht] This plugin generated a warning from the
characteristic 'Current Temperature': characteristic value expected valid finite number
and received "NaN" (number). See https://homebridge.io/w/JtMGR for more info.
[12/6/2023, 6:05:16 PM] [homebridge-dht] This plugin slows down Homebridge. The
read handler for the characteristic 'Current Temperature' didn't respond at all!.
Please check that you properly call the callback! See https://homebridge.io/w/JtMGR for more info.
[12/6/2023, 6:05:38 PM] [Cupboard Ambient] Got Temperature of 32
[12/6/2023, 6:05:38 PM] [Cupboard Ambient] Got Temperature of 32
[12/6/2023, 6:05:41 PM] [Cupboard Ambient] Got Temperature of 32

My config is :

    "accessories": [
        {
            "accessory": "Dht",
            "cputemp": "/homebridge/sensors_homebridge",
            "name": "Cupboard Ambient",
            "refresh": 300,
            "service": "Temperature"
        }

Proposed Change

Apply the suggestions from https://github.com/homebridge/homebridge/wiki/Characteristic-Warnings ?

Additional Context

No response

Not getting any reading

hello, homekit is picking up the sensor however theres no reading, i ran sudo status homebridge and i get these errors
screenshot 2016-10-31 02 45 22

The Humidity value does not work

[7/12/2017, 7:11:24 PM] [CPU's Temp] Got Temperature of 50
[7/12/2017, 7:11:24 PM] [Room Temperature] Got status of 0
[7/12/2017, 7:11:24 PM] [Room Temperature] Got Temperature of 29
[7/12/2017, 7:11:24 PM] [Room Temperature] Got humidity of 72

But Humidity of HomeKit still 0%. The Temperature value is good.
I am using DHT11

Temperature as float

Is there any way to make the temperature more precise and show it with a decimal?
Thank you!

Reduce verbosity in log

Hi, thanks for the great plugin.

Would be useful to introduce a parameter to reduce verbosity of logging in syslog.

E.g. conditionally execute:
this.log("DHT Status: %s, Temperature: %s, Humidity: %s", result[0], temperature, humidity); at line 97
and
this.log("Got Temperature of %s", binaryState); at line 136.
(ref. code at tag v0.1.20)

Combining HomeKit sensors

Hello! After installing the module in HomeBridge, the sensors are displayed as a single unit. Can you tell me how they can be divided? A screenshot of the display and the current config is attached.
Снимок экрана 2021-02-02 в 02 42 15
Снимок экрана 2021-02-02 в 02 41 13
Снимок экрана 2021-02-02 в 02 43 11

Support for dht11

Hello and nice work!!
One question, does it support dht11? I have tried to replay at the service dht11 instead of dht22 but had no luck.

Thank you

Can't find the accessory

Hi, I follow your instruction to set up everything, and when i run the homebridge, all goes well, no error
but the homekit can't pair this accessory, I also use another plugin called homebridge-camera-rpi, which can be searched by home app.
so how to figure this out?

Homebridge crashes when trying to initialize Dht

May 14 19:05:59 raspberrypi2 homebridge[717]: [2019-5-14 19:05:59] [dht22] Initializing Dht accessory...
May 14 19:05:59 raspberrypi2 homebridge[717]: [2019-5-14 19:05:59] [dht22] Adding Accessory
May 14 19:06:00 raspberrypi2 homebridge[717]: [2019-5-14 19:06:00] [dht22] INIT: dht22
May 14 19:06:00 raspberrypi2 systemd[1]: homebridge.service: Main process exited, code=killed, status=11/SEGV
May 14 19:06:00 raspberrypi2 systemd[1]: homebridge.service: Unit entered failed state.
May 14 19:06:00 raspberrypi2 systemd[1]: homebridge.service: Failed with result 'signal'.

Config:

{
	"accessory": "Dht",
	"name": "dht22",
	"name_temperature": "Temperature",
	"name_humidity": "Humdity",
	"service": "dht22"
}

Everything works if I take out the plugin from the config.

[dht22] Error: [Error: failed to read sensor]

Hi, hope you are still around :) thx for the plugin.

I can't get it to work :(.

I installed the homebridge plugin via homebridge-config-ui-x. My config is:

       {  
            "accessory": "Dht",  
            "name": "dht22",  
            "name_temperature": "Temperature",  
            "name_humidity": "Humidity",  
            "service": "dht22"   
        },

I installed the BCM2835 library etc and i can run dht22 in my terminal as normal pi user and also as homebridge user. It returns something like

pi@raspberrypi:~ $ dht22    
0 21.5 C 49.9 %

When i boot my homebridge, the init stuff is

[1/16/2021, 5:19:05 PM] [dht22] Initializing Dht accessory...
[1/16/2021, 5:19:05 PM] [dht22] Adding Accessory
[1/16/2021, 5:19:05 PM] [dht22] INIT: dht22

But later when it actually runs it there is the error

[1/16/2021, 5:20:35 PM] [dht22] Error: [Error: failed to read sensor]

Any idea what this could be?

Homebridge is failing to read sensor

Hi,

I connected the dht to GPIO 25 and adjusted my config.json accordingly.

journalctl tells me: [dht22] Error: [Error: failed to read sensor]

Unfortunately theres no Error No. which is why I cant start any debugging. (Google search) ;)
The wiring is correct and I do have the current BCM2358 lib. Also the user "homebridge" is member of "gpio".

I look forward to hearing from you. (:

FeatureRequest: add MQTT publish

Hi, great work. I'm using homebridge-dht and publish the values for temp and humi to a MQTT broker via exec() function. What do you think to build in the feature into your code?

Enclosed my modification to your code:

pi@schuppen:/usr/local/lib/node_modules/homebridge-dht $ diff index.js index.js_original
46,47c41
< var execFile = require('child_process').execFile;
< var exec = require('child_process').exec;
---
> var exec = require('child_process').execFile;
79,82d72
<  // ADD MQTT
<   this.mqttbroker = config.mqtt_broker || "localhost";
<   this.mqtttopic = config.mqtt_topic || "sensor/dht";
<
96,117d85
<
<
<         // publish sensor value via MQTT
<         var PublishTemperature = 'mosquitto_pub -h ' + this.mqttbroker + ' -q 2 -t ' + this.mqtttopic + 'temperature -m ' + roundInt(temperature);
<         exec(PublishTemperature, function (error, stdout, stderr) {
<           if (error !== null) {
<             this.log('MQTT publish failed: ' + error);
<           } else {
<             this.log('MQTT publish: ' + PublishTemperature);
<           }
<         }.bind(this));
<
<         var PublishHumidity = 'mosquitto_pub -h ' + this.mqttbroker + ' -q 2 -t ' + this.mqtttopic + 'humidity -m ' + roundInt(humidity);
<         exec(PublishHumidity, function (error, stdout, stderr) {
<           if (error !== null) {
<             this.log('MQTT publish failed: ' + error);
<           } else {
<             this.log('MQTT publish: ' + PublishHumidity);
<           }
<         }.bind(this));
<
<
143c111
<     execFile(cputemp, function(error, responseBody, stderr) {
---
>     exec(cputemp, function(error, responseBody, stderr) {

[dht22] 32-bit executable, won't run on aarch64

I recently moved to the arm64 beta of Raspberry Pi OS, and when I tried to setup my Homebridge again I found that the dht22 executable is 32 bit, dynamically linked, and won't run on the 64-bit OS...

/usr/local/bin/dht22: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux-armhf.so.3, for GNU/Linux 2.6.32, BuildID[sha1]=7368cc48b57ad45ff60eb7cef27bd0e9719a5ae3, not stripped

It looks like you're just providing the binary (no source). Is there any chance you could recompile for arm64 or provide source so that I might build it myself?

Thanks!

about DHT11 get data failed

Hi,

I must modify the read method of getDHTTemperature

sensor.read(11, this.gpio, function(err, temperature, humidity) {
...

instead of

sensor.read(22, this.gpio, function(err, temperature, humidity) {
...

Error: dht22 read failed with status 2

Can you help me figure out what is happening?

I have errors in homebridge
[2019-3-3 21:30:01] [dht22] DHT Status: 2, Temperature: 0, Humidity: 0
[2019-3-3 21:30:01] [dht22] Error: dht22 read failed with status 2

Sometimes temperature is read correctly. I'm sure that DHT11 is working fine as from AdaFruit DHT is read correctly if I will check this sensor using this script. From your script I have correct reply only on 5% of request.

Next:

[2019-3-3 21:31:01] [dht22] Error: dht22 read failed with status 2 <-- this reply is more often, due that temperature is not displayed correctly in Home app.
[2019-3-3 21:32:01] [dht22] DHT Status: 0, Temperature: 26, Humidity: 38

ERROR LOADING PLUGIN homebridge-dht

Hi There!

I have a problem with running or loading dht plugin in Homebridge. Before it worked, but it broguht time to work.
But now, I get this error message and my DHT22 plugin doesn't work with Homebridge and iOS Home Kit.
The DHT22 sensor is good, because in Raspi terminal i can read out the values of temperature and humidity.

Here is the full error message from the terminal:

ERROR LOADING PLUGIN homebridge-dht:
[2019-10-6 22:11:04] Error: Cannot find module '/home/pi/homebridge-dht/node_modules/node-dht-sensor/build/Release/node_dht_sensor'. Please verify that the package.json has a valid "main" entry
at tryPackage (internal/modules/cjs/loader.js:288:19)
at Function.Module._findPath (internal/modules/cjs/loader.js:515:18)
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:759:27)
at Function.Module._load (internal/modules/cjs/loader.js:677:27)
at Module.require (internal/modules/cjs/loader.js:830:19)
at require (internal/modules/cjs/helpers.js:68:18)
at Object. (/home/pi/homebridge-dht/index.js:40:14)
at Module._compile (internal/modules/cjs/loader.js:936:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:947:10)
at Module.load (internal/modules/cjs/loader.js:790:32)
And here is a picture of it also.

Many-many thanks for your help!
dht_problem

No plug-in found for accessory “dht22” in config.json

Hi, not sure if the repos is still active but I’ve not long been into homebridge. Having a lot of issues. Managed to get this far from your instructable page.

keep getting these massages in the logs, any idea?

:
[28/04/2022, 21:33:07] Homebridge v1.4.0 (HAP v0.10.0) (Homebridge 855C) is running on port 51125.
[28/04/2022, 21:39:49] [Homebridge UI] Changes to config.json saved.
[28/04/2022, 21:40:06] [Homebridge UI] Homebridge restart request received
[28/04/2022, 21:40:06] [Homebridge UI] UI / Bridge settings have not changed; only restarting Homebridge process
[28/04/2022, 21:40:06] [Homebridge UI] Sending SIGTERM to Homebridge
[28/04/2022, 21:40:06] Got SIGTERM, shutting down Homebridge...
[28/04/2022, 21:40:11] [HB Supervisor] Homebridge Process Ended. Code: 143, Signal: null
[28/04/2022, 21:40:16] [HB Supervisor] Restarting Homebridge...
[28/04/2022, 21:40:16] [HB Supervisor] Starting Homebridge with extra flags: -I
[28/04/2022, 21:40:16] [HB Supervisor] Started Homebridge v1.4.0 with PID: 2130
[28/04/2022, 21:40:18] Loaded config.json with 2 accessories and 1 platforms.
[28/04/2022, 21:40:18] Loaded 0 cached accessories from cachedAccessories.
[28/04/2022, 21:40:18] ---
[28/04/2022, 21:40:20] Plugin /usr/local/lib/node_modules/homebridge-config-ui package.json does not contain the keyword 'homebridge-plugin'.
[28/04/2022, 21:40:21] Loaded plugin: [email protected]
[28/04/2022, 21:40:21] Registering platform 'homebridge-config-ui-x.config'
[28/04/2022, 21:40:21] ---
[28/04/2022, 21:40:21] Loading 1 platforms...
[28/04/2022, 21:40:21] [Config] Initializing config platform...
[28/04/2022, 21:40:21] [Config] Running in Service Mode
[28/04/2022, 21:40:21] Loading 2 accessories...
[28/04/2022, 21:40:21] No plugin was found for the accessory "Dht" in your config.json. Please make sure the corresponding plugin is installed correctly.
[28/04/2022, 21:40:21] No plugin was found for the accessory "Dht" in your config.json. Please make sure the corresponding plugin is installed correctly.
Setup Payload:
X-HM://0024VDJCJGNWM
Enter this code with your HomeKit app on your iOS device to pair with Homebridge:

cputemp is not working

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

Negative temperatures not working

sensor
.getService(Service.TemperatureSensor)
.getCharacteristic(Characteristic.CurrentTemperature)
.setProps({
minValue: -100,
maxValue: 100
});

Segmentation fault

I'm using pin 16. I changed the pin in dht22 file in /user/local/bin/ and run "dht22" but give:
Segmentation fault

please need help

having error reading the sensor

    "accessories": [{
                    "accessory": "Dht",
                    "name": "dht22 - outdoor",
                    "name_temperature": "Outdoor Temperature",
                    "name_humidity": "Outdoor Humdity",
                    "gpio": "26",
                    "service": "dht22"
    }]

}

[5/18/2017, 11:38:52 AM] [dht22 - outdoor] Identify requested!
[5/18/2017, 11:39:13 AM] [dht22 - outdoor] dhtExec function failed: Error: spawn dht22 ENOENT
[5/18/2017, 11:39:13 AM] [dht22 - outdoor] Identify requested!
[5/18/2017, 11:39:16 AM] [dht22 - outdoor] dhtExec function failed: Error: spawn dht22 ENOENT
[5/18/2017, 11:39:17 AM] [dht22 - outdoor] dhtExec function failed: Error: spawn dht22 ENOENT
[5/18/2017, 11:39:23 AM] [dht22 - outdoor] dhtExec function failed: Error: spawn dht22 ENOENT

DH11 showing humidity value of NaN

I installed this plugin and the temperature of my DH11 sensor works fine but I have not yet been able to get the humidity to show through to homekit.

Homekit status:

Sep 23 04:16:33 mediapi homebridge[5619]: [Sat Sep 23 2017 04:16:33 GMT+0000 (UTC)] [dht22] Got status of 0
Sep 23 04:16:33 mediapi homebridge[5619]: [Sat Sep 23 2017 04:16:33 GMT+0000 (UTC)] [dht22] Got Temperature of 26
Sep 23 04:16:33 mediapi homebridge[5619]: [Sat Sep 23 2017 04:16:33 GMT+0000 (UTC)] [dht22] Got humidity of NaN

And if I run the dhtxx binary I get:

~ $ dht22
0 26.0 52.0

Which shows a humidity of 52%. Any idea why I'm not getting this data flowing through to the plugin?

DHT22 does not work, show as 0C and 0%.

I have install BCM2835 (downloaded at /home/pi) and homebridge-dht both from config-ui-x and using command line with --unsafe-perm and this is my config.json
{ "accessory": "Dht", "name": "Room", "service": "dht22" }
but everything shows as 0 celcius and 0% humidity.

I am connecting DHT22 at GPIO4 (pin7) and I think I have follow through every steps, any suggestion?

Thanks

homebridge throws error when trying to read temps

I'm getting the following error when running homebridge. This seems to only trigger when the sensor is being read by homekit.
I have tested my sensor using python so I know it's working correctly.

[1/12/2017, 8:14:54 PM] Homebridge is running on port 51826.
internal/child_process.js:313
    throw errnoException(err, 'spawn');
    ^

Error: spawn EACCES
    at exports._errnoException (util.js:1022:11)
    at ChildProcess.spawn (internal/child_process.js:313:11)
    at exports.spawn (child_process.js:380:9)
    at exports.execFile (child_process.js:143:15)
    at Object.getDHTTemperature (/usr/lib/node_modules/homebridge-dht/index.js:66:9)
    at emitThree (events.js:116:13)
    at emit (events.js:194:7)
    at Characteristic.getValue (/usr/lib/node_modules/homebridge/node_modules/hap-nodejs/lib/Characteristic.js:120:10)
    at Bridge.<anonymous> (/usr/lib/node_modules/homebridge/node_modules/hap-nodejs/lib/Accessory.js:634:20)
    at Array.forEach (native)
    at Bridge.Accessory._handleGetCharacteristics (/usr/lib/node_modules/homebridge/node_modules/hap-nodejs/lib/Accessory.js:598:8)
    at emitMany (events.js:127:13)
    at HAPServer.emit (events.js:201:7)
    at HAPServer._handleCharacteristics (/usr/lib/node_modules/homebridge/node_modules/hap-nodejs/lib/HAPServer.js:926:10)
    at HAPServer.<anonymous> (/usr/lib/node_modules/homebridge/node_modules/hap-nodejs/lib/HAPServer.js:209:39)
    at emitNone (events.js:86:13)
    at IncomingMessage.emit (events.js:185:7)
    at endReadableNT (_stream_readable.js:974:12)
    at _combinedTickCallback (internal/process/next_tick.js:74:11)
    at process._tickCallback (internal/process/next_tick.js:98:9)

Thanks, and great work!

bcm2835_init: Unable to open /dev/gpiomem: No such file or directory

Hey everyone,

Somewhat new to these parts of the wood. I am running homebridge on my Raspberry Pi 4b through docker. I am getting:
bcm2835_init: Unable to open /dev/gpiomem: No such file or directory
[dht22] Error: [Error: failed to initialize sensor]

Yes, I know that I need to:
sudo adduser homebridge gpio

When I try to use that line with my Pi I get:

pi@mypi:~ $ sudo adduser homebridge gpio 
adduser: The user `homebridge' does not exist.

Current Config:
{ "bridge": { "name": "Home Bridge", "username": "CC:22:3D:E3:CD:33", "port": 51826, "pin": "031-45-154" }, "description": "HomeBridge", "platforms": [ { "name": "Config", "port": 8080, "platform": "config" }, { "name": "RPi", "hosts": [ { "host": "10.0.1.29:8888", "name": "mypi", "noPowerLed": true, "noSmokeSensor": true } ], "platform": "RPi" } ], "accessories": [ { "accessory": "DS18B20", "name": "DS18B20", "device": "28-00000912a17d" }, { "accessory": "Dht", "name": "dht22", "service": "dht22", "refresh": "15", "gpio": "18" } ] }

Any direction will be greatly appreciated.

Can't start plugin on boot

Hello, @NorthernMan54!

First of all, thank you very much for this plugin. It's been really useful.

I tested homebridge-dht by running sudo pigpiod and then homebridge. That worked perfectly. My problems began when I tried to run homebridge on boot. I configured cron to run the two commands mentioned before, but this didn't work. I'm not really sure why, but maybe sudo pigpiod wasn't being called before homebridge. Afterwards, I tried with sudo systemctl enable pigpiod and a script that called homebridge after waiting 15 seconds with cron. This method didn't work, too.

Homebridge starts successfully with these methods, but the DHT plugin does not. If my problem is that sudo pigpiod is not called before homebridge, how can I make sure it is called first?

Thank you very much in advance!

ERROR LOADING PLUGIN homebridge-dht

pi@raspberrypi:~ $ homebridge
[2019-9-27 01:30:14] Loaded config.json with 2 accessories and 0 platforms.
[2019-9-27 01:30:14] ---
[2019-9-27 01:30:14] ====================
[2019-9-27 01:30:14] ERROR LOADING PLUGIN homebridge-dht:
[2019-9-27 01:30:14] Error: Cannot find module 'node-dht-sensor'
at Function.Module._resolveFilename (module.js:543:15)
at Function.Module._load (module.js:470:25)
at Module.require (module.js:593:17)
at require (internal/module.js:11:18)
at Object. (/usr/local/lib/node_modules/homebridge-dht/index.js:40:14)
at Module._compile (module.js:649:30)
at Object.Module._extensions..js (module.js:660:10)
at Module.load (module.js:561:32)
at tryModuleLoad (module.js:501:12)
at Function.Module._load (module.js:493:3)
[2019-9-27 01:30:14] ====================
[2019-9-27 01:30:14] No plugins found. See the README for information on installing plugins.
[2019-9-27 01:30:14] Loading 0 platforms...
[2019-9-27 01:30:14] Loading 2 accessories...
[2019-9-27 01:30:14] Error: The requested accessory 'Dht' was not registered by any plugin.
at API.accessory (/usr/local/lib/node_modules/homebridge/lib/api.js:64:13)
at Server._loadAccessories (/usr/local/lib/node_modules/homebridge/lib/server.js:297:42)
at Server.run (/usr/local/lib/node_modules/homebridge/lib/server.js:91:38)
at module.exports (/usr/local/lib/node_modules/homebridge/lib/cli.js:59:10)
at Object. (/usr/local/lib/node_modules/homebridge/bin/homebridge:17:22)
at Module._compile (module.js:649:30)
at Object.Module._extensions..js (module.js:660:10)
at Module.load (module.js:561:32)
at tryModuleLoad (module.js:501:12)
at Function.Module._load (module.js:493:3)
[2019-9-27 01:30:14] Got SIGTERM, shutting down Homebridge...

What can I do? Please! I need to do a work using it.

Serial Number

Need to add a unique serial number to support fakegato service. Also BME280

Only one sensor

Since version 1.31 its shown as one sensor of temp with info about humidity inside. In version 1.30 its shown as two different sensor. Maybe you correct this. (iOS 13.2.3)

got an error

Hi there. Great guide and a wonderful idea, but for some reason after getting through it I get the homebridge to run for a few seconds and it stops. After entering troubleshooting on my phone I see the following:
pi@raspberrypi:/root/homebridge $ sudo homebridge -U /
[2019-5-2 01:38:28] config.json (/config.json) not found.
[2019-5-2 01:38:28] ====================
[2019-5-2 01:38:28] ERROR LOADING PLUGIN homebridge-dht:
[2019-5-2 01:38:28] Error: Cannot find module 'node-dht-sensor'
at Function.Module._resolveFilename (module.js:543:15)
at Function.Module._load (module.js:470:25)
at Module.require (module.js:593:17)
at require (internal/module.js:11:18)
at Object. (/usr/local/lib/node_modules/homebridge-dht/index.js:40:14)
at Module._compile (module.js:649:30)
at Object.Module._extensions..js (module.js:660:10)
at Module.load (module.js:561:32)
at tryModuleLoad (module.js:501:12)
at Function.Module._load (module.js:493:3)
[2019-5-2 01:38:28] ====================

Data History

Hi

Since the last Update the history always Show 0 degree (the hum 0%) in history (EVEapp)
Is there Any way to get it to work?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.