Saturday, January 7, 2023

Use the Philips Hue motion sensor to monitor temperature...

I was looking through the Philips Hue API to see how to interact with the Philips Hue motion sensor, and I was happy to find that the motion sensor includes a temperature sensor.

The temperature sensor will show up in the list of sensors once you add the motion sensor to your Philips Hue Hub.

Here is an example of the response data for the temperature sensor (but only showing one sensor instead of all sensors):

curl http://$HUE_BRIDGE_IP/api/$HUE_USERNAME/sensors

{
    "5": {
     "state": {
     "temperature": 1929,
    "lastupdated": "2023-01-06T16:24:41"
     },
     "swupdate": {
     "state": "noupdates",
    "lastinstall": "2023-01-04T01:35:43"
    },
     "config": {
     "on": true,
     "battery": 100,
    "reachable": true,
    "alert": "none",
     "ledindication": false,
     "usertest": false,
    "pending": []
     },
     "name": "Hue temperature sensor",
     "type": "ZLLTemperature",
     "modelid": "SML003",
     "manufacturername": "Signify Netherlands B.V.",
     "productname": "Hue temperature sensor",
     "swversion": "2.53.6",
     "uniqueid": "00:11:22:33:bb:00:ee:33-22-4444",
     "capabilities": {
     "certified": true,
     "primary": false
    }
    }
}

The temperature value of "1929" converts to 66.72 degrees Fahrenheit.

Here is an example python app that will watch and print out the temperature value returned from the temperature sensor in the Philips Hue motion sensor.

The example app will monitor the temperature sensor, and print out the temperature for each sensor you ask to monitor via a comma separated string of sensor IDs you can pass in on the command line.

I have two motion sensors - one in the garage and one in a room in the house.

The following is the command line I used. Note that I used a comma separated string for the two temperature sensors, and set the monitoring interval to run every 10 seconds:

python3 main.py -b $HUE_BRIDGE_IP -u $HUE_USERNAME -s 5,18 -i 10


Here is an example of the output:

Temp is unchanged. Temp: 55.42

Temp is unchanged. Temp: 66.72

Temp is unchanged. Temp: 55.42

Temp changed! Temp: 67.17



Example app in Github: https://github.com/leewallen/motion-sensor