You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
See below for a working setup to pipe in the temperature for a Phillips Hue motion sensor into the temperatureFilePath that was introduced in v3.0.5. This is written from the perspective of a Raspberry Pi user, but it should work on any Unix based system
A machine that runs python (I used v2.7.10) and crontab (RPi is perfect for this)
1 - Get your API data:
Register for an API with Hue using the above link. Then, you'll need to find the specific sensor that you want to get data from. This will look something like http://<HUE_BRIDGE_IP_ADDRESS>/api/<USER_ID>/sensors.
If you have multiple sensors, you'll need to find which one is the right one from the JSON response (try looking at the name of the sensor vs the name in the hue app). Once you have found it, add the number to the end of your URL
(like this http://<HUE_BRIDGE_IP_ADDRESS>/api/<USER_ID>/sensors/**5**.
If you paste this URL in your browser, you will get the response for one motion sensor only, which is what we want.
2 - Get your system ready
Install the 'requests' package for python on the Pi (or whatever machine you're using) with apt-get install python-requests
3 - Edit this python script with your Hue API data
Replace 'http://HUE_BRIDGE_IP_ADDRESS/api/USER_ID/sensors/NUMBER' with your required information
Save this file as 'temp.py'. This script looks at the data from the API call, parses the rest of the JSON out to have just the temperature data (which is a 4 digit number, 2476 = 24.76C degrees), divides the 4 digit number by 100 to get a 2 digit number, then adds it to a file called 'temp' which lives /var/homebridge (this should create the file called 'temp' if it does not already exist).
Unfortunately this does not round the numbers very well. For example, if the response from the API is 2499 (24.99 degrees C), then the 2 digit number will be '24', not '25'. This can be fixed with 'round' or 'float' in the python, but I haven't done that yet (maybe v2).
In terminal, navigate to where temp.py is located (e.g. cd /var/homebridge, then run chmod a+x temp.py.
4 - Set up a cronjob to make the python script run every minute
On your Pi run 'crontab -e'. You may see a few options for where you want cron to run from, I don't think it maters which one you pick. I set this script to run every minute using * * * * * /var/homebridge/temp.py. You can use this handy website to find how to use cron and what options to use for different times. Using '* * * * *' means it will run every minute.
5 - Edit you config.json file
In your config.json file, the path for 'temperatureFilePath' should be "/var/homebridge/temp".
That's it! You should now have your temperature value piping into your Air Conditioner. Comment if you have any troubles and I'll do my best to help. Thanks to @lprhodes for the plugin!
The text was updated successfully, but these errors were encountered:
lprhodes
changed the title
(Solution provided) - Config for external temperature source (issue 244)
Config for external temperature source
Mar 20, 2018
See below for a working setup to pipe in the temperature for a Phillips Hue motion sensor into the
temperatureFilePath
that was introduced in v3.0.5. This is written from the perspective of a Raspberry Pi user, but it should work on any Unix based systemPrerequisites:
1 - Get your API data:
Register for an API with Hue using the above link. Then, you'll need to find the specific sensor that you want to get data from. This will look something like
http://<HUE_BRIDGE_IP_ADDRESS>/api/<USER_ID>/sensors
.If you have multiple sensors, you'll need to find which one is the right one from the JSON response (try looking at the name of the sensor vs the name in the hue app). Once you have found it, add the number to the end of your URL
(like this
http://<HUE_BRIDGE_IP_ADDRESS>/api/<USER_ID>/sensors/**5**
.If you paste this URL in your browser, you will get the response for one motion sensor only, which is what we want.
2 - Get your system ready
Install the 'requests' package for python on the Pi (or whatever machine you're using) with
apt-get install python-requests
3 - Edit this python script with your Hue API data
Replace 'http://HUE_BRIDGE_IP_ADDRESS/api/USER_ID/sensors/NUMBER' with your required information
Save this file as 'temp.py'. This script looks at the data from the API call, parses the rest of the JSON out to have just the temperature data (which is a 4 digit number, 2476 = 24.76C degrees), divides the 4 digit number by 100 to get a 2 digit number, then adds it to a file called 'temp' which lives /var/homebridge (this should create the file called 'temp' if it does not already exist).
Unfortunately this does not round the numbers very well. For example, if the response from the API is 2499 (24.99 degrees C), then the 2 digit number will be '24', not '25'. This can be fixed with 'round' or 'float' in the python, but I haven't done that yet (maybe v2).
In terminal, navigate to where temp.py is located (e.g.
cd /var/homebridge,
then runchmod a+x temp.py
.4 - Set up a cronjob to make the python script run every minute
On your Pi run 'crontab -e'. You may see a few options for where you want cron to run from, I don't think it maters which one you pick. I set this script to run every minute using
* * * * * /var/homebridge/temp.py
. You can use this handy website to find how to use cron and what options to use for different times. Using '* * * * *' means it will run every minute.5 - Edit you config.json file
In your config.json file, the path for 'temperatureFilePath' should be "/var/homebridge/temp".
That's it! You should now have your temperature value piping into your Air Conditioner. Comment if you have any troubles and I'll do my best to help. Thanks to @lprhodes for the plugin!
The text was updated successfully, but these errors were encountered: