Skip to content

Commit

Permalink
Initial upload
Browse files Browse the repository at this point in the history
  • Loading branch information
NorthernMan54 committed Jun 22, 2016
1 parent 57ff706 commit f682fc7
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 136 deletions.
106 changes: 70 additions & 36 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,50 +1,84 @@
# homebridge-dht

Supports X10 devices via dht on the HomeBridge Platform. Tested with a CM11A Module connected via a USB Serial adapter.
Supports integration of a DHT11/DHT21/DHT22/DHT33/DHT44 Temperature/Humidity
Sensor into hombridge via the pigpio library on a Raspberry PI. I have tried
numerous other interface methods for the DHT22, and found that this was least
problematic. Also includes reporting of the RaspBerry PI CPU Temperature.

# Installation

1. Install homebridge using: npm install -g homebridge
2. Install homebridge-dht using: npm install -g homebridge-dht
3. Update your configuration file. See sample-config.json in this repository for a sample.
4. Assumes dht is installed in /usr/local/bin/heyu, and already configured and running
5. Homebridge must run under the same id as heyu
2. Install the pigpiod library via these commands
sudo apt-get update
sudo apt-get install pigpio python-pigpio python3-pigpio
3. Download the DHT22 Sample program from here
http://abyz.co.uk/rpi/pigpio/code/DHTXXD.zip
4. Apply this patch to test_DHTXXD.

```diff test_DHTXXD.c orig/test_DHTXXD.c
128c128
< printf("%d %.1f C %.1f %%\n", r.status, r.temperature, r.humidity);
---
> printf("%d %.1f %.1f\n", r.status, r.temperature, r.humidity);
158,160d157
< } else {
< fprintf(stderr, "ERROR: pigpiod not running\n");
< return 1;

```
This adds units to the response, and adds an error when pigpiod is not running.
5. Compile with this command
```gcc -Wall -pthread -o DHTXXD test_DHTXXD.c DHTXXD.c -lpigpiod_if2
```
6. Copy DHTXXD to /usr/local/bin/dht22, and make executable.
7. Follow one of the numerous guides to wire up a DHT22 to a Raspberry PI.
Default GPIO pin to connect to is GPIO4
8. Install homebridge-dht using: npm install -g homebridge-dht
9. Create a file in /usr/local/bin/cputemp containing
```
#!/bin/bash
cpuTemp0=$(cat /sys/class/thermal/thermal_zone0/temp)
cpuTemp1=$(($cpuTemp0/1000))
cpuTemp2=$(($cpuTemp0/100))
cpuTempM=$(($cpuTemp2 % $cpuTemp1))
echo $cpuTemp1" C"
#echo GPU $(/opt/vc/bin/vcgencmd measure_temp)
```

10. Update your configuration file. See sample-config.json in this repository for a sample.


# Configuration

```
"accessories": [
{ "accessory": "Heyu",
"name": "All Devices", // Alias for the allon/alloff command
"device": "a", // House code A
"on_command": "allon", // heyu command
"off_command": "alloff", // heyu command
"statusHandling": "no", // Device does not supply status
"service": "Switch"
},
{ "accessory": "Heyu",
"name": "All Lights",
"device": "a",
"on_command": "lightson",
"off_command": "lightsoff",
"statusHandling": "no",
"service": "Switch"
},
{ "accessory": "Heyu",
"name": "Front Door Lights",
"device": "a1", // X10 device
"service": "Light", // Lights may be dimmed
"dimmable": "yes" // Device is dimmable
},
{ "accessory": "Heyu",
"name": "Walkway Lights",
"device": "a2",
"service": "Switch" // Switches are not dimmable
},
]
{
"bridge": {
"name": "Penny",
"username": "CC:22:3D:E3:CD:33",
"port": 51826,
"pin": "031-45-154"
},
"description": "HomeBridge Heyu Status Control",
"platforms": [],
"accessories": [
{ "accessory": "Dht",
"name": "cputemp",
"service": "Temperature" },
{ "accessory": "Dht",
"name": "Temp/Humidity Sensor",
"service": "dht22" }
]
}
```

# ToDo

Setup monitoring of events from X10 Remotes and 2 way devices
Stop using the external program call, and call the pigpio library directly using
npm module instead.
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ DhtAccessory.prototype = {
var informationService = new Service.AccessoryInformation();

informationService
.setCharacteristic(Characteristic.Manufacturer, "Dht Manufacturer")
.setCharacteristic(Characteristic.Manufacturer, "AOSONG")
.setCharacteristic(Characteristic.Model, this.service)
.setCharacteristic(Characteristic.SerialNumber, this.device);

Expand Down
111 changes: 12 additions & 99 deletions sample-config.json
Original file line number Diff line number Diff line change
@@ -1,111 +1,24 @@
{
"bridge": {
"name": "Heyu",
"username": "CC:22:3D:E3:CE:33",
"name": "Penny",
"username": "CC:22:3D:E3:CD:33",
"port": 51826,
"pin": "031-45-154"
},

"description": "HomeBridge Heyu Status Control",
"description": "HomeBridge DHT Temp/Humidity Sensor",

"accessories": [{
"accessory": "Heyu",
"name": "All Devices",
"device": "a",
"on_command": "allon",
"off_command": "alloff",
"statusHandling": "no",
"service": "Switch"
}, {
"accessory": "Heyu",
"name": "All Lights",
"device": "a",
"on_command": "lightson",
"off_command": "lightsoff",
"statusHandling": "no",
"service": "Switch"
}, {
"accessory": "Heyu",
"name": "Front Door Lights",
"device": "a1",
"service": "Light",
"dimmable": "yes"
}, {
"accessory": "Heyu",
"name": "Walkway Lights",
"device": "a2",
"service": "Switch"
}, {
"accessory": "Heyu",
"name": "Side Door Lights",
"device": "a3",
"service": "Light",
"dimmable": "yes"
}, {
"accessory": "Heyu",
"name": "Back Door Lights",
"device": "a4",
"service": "Light",
"dimmable": "yes"

}, {
"accessory": "Heyu",
"name": "Family Room Lights",
"device": "a5",
"service": "Light",
"dimmable": "yes"
}, {
"accessory": "Heyu",
"name": "Floor lamp",
"device": "a6",
"service": "Light",
"dimmable": "yes"

}, {
"accessory": "Heyu",
"name": "Fish tank",
"device": "a7",
"service": "Switch"

}, {
"accessory": "Heyu",
"name": "Master Left",
"device": "a11",
"service": "Light",
"dimmable": "yes"

}, {
"accessory": "Heyu",
"name": "Master Right",
"device": "a12",
"service": "Light",
"dimmable": "yes"

}, {
"accessory": "Heyu",
"name": "Living Room Lamp",
"device": "a13",
"service": "Light",
"dimmable": "yes"
"platforms": [],

"accessories": [{
"accessory": "Dht",
"name": "cputemp",
"service": "Temperature"
}, {
"accessory": "Heyu",
"name": "Staircase Lamp",
"device": "a14",
"service": "Light",
"dimmable": "no"
"accessory": "Dht",
"name": "Temp/Humidity Sensor",
"service": "dht22"
}]

}, {
"accessory": "Heyu",
"name": "Powder Room",
"device": "a15",
"service": "Light",
"dimmable": "yes"

}, {
"accessory": "Heyu",
"name": "Garage Outlet",
"device": "a16",
"service": "Switch"
}]
}

0 comments on commit f682fc7

Please sign in to comment.