Use the temperature status from Philips Hue motion sensors to control Honeywell Lyric Thermostat

My living room has west facing windows that admit a lot of heat even with the blinds closed. And my thermostat is in a hallway on the other side of the house. So in the afternoon my living room can heat up to over 80°F while my thermostat reads 68°F. Another problem is that the Winter sun shines on my thermostat around noon through a south facing window so my thermostat effectively stops working in the middle of the day when it heats up above 68°F. What I needed was a remote sensor for my thermostat and now I have one.

This is because I noticed that my Philips Hue motion sensors also measure temperature.

Here’s what the sensor looks like in the Hue CLIP API Debugger (https://www.developers.meethue.com/documentation/getting-started)

"18": {
		"state": {
			"temperature": 1700,
			"lastupdated": "2018-04-16T19:50:48"
		},
		"swupdate": {
			"state": "noupdates",
			"lastinstall": null
		},
		"config": {
			"on": true,
			"battery": 100,
			"reachable": true,
			"alert": "none",
			"ledindication": false,
			"usertest": false,
			"pending": []
		},
		"name": "Hue temperature sensor 2",
		"type": "ZLLTemperature",
		"modelid": "SML001",
		"manufacturername": "Philips",
		"productname": "Hue temperature sensor",
		"swversion": "6.1.0.18912",
		"uniqueid": "00:17:88:01:02:00:9e:44-02-0402",
		"capabilities": {
			"certified": true
		}
	},
	"19": {
		"state": {
			"presence": false,
			"lastupdated": "2018-04-16T17:59:31"
		},
		"swupdate": {
			"state": "noupdates",
			"lastinstall": null
		},
		"config": {
			"on": true,
			"battery": 100,
			"reachable": true,
			"alert": "none",
			"ledindication": false,
			"usertest": false,
			"sensitivity": 2,
			"sensitivitymax": 2,
			"pending": []
		},
		"name": "Living room lamps sensor",
		"type": "ZLLPresence",
		"modelid": "SML001",
		"manufacturername": "Philips",
		"productname": "Hue motion sensor",
		"swversion": "6.1.0.18912",
		"uniqueid": "00:17:88:01:02:00:9e:44-02-0406",
		"capabilities": {
			"certified": true
		}
	},

Note that the name you give the motion sensor will appear for the motion sensor item (e.g “name”: “Living room lamps sensor” - item 19 above) but the temperature sensor name will be like “Hue temperature sensor 2”, so you can tell your temperature sensors apart by finding your motion sensor by name and then the item before it will be the temperature sensor and the item after the motion sensor is the ambient light sensor associated with that motion sensor.

With this info I created OpenHAB items like this

Number	HUE_Temp_Livingroom	"Livingroom temp [%.2f  f]"	<temperature>	(gSkur) { http="<[HTTP://10.0.0.126/api/<API  KEY>/sensors/18:300000:JS(getHueTemperature.js)]"}

and getHueTemperature.js

(function(i) {
    var json = JSON.parse(i);
    return (((json['state']['temperature']))/100*9/5+32).toFixed(2);
})(input)

Unfortunately I have not mastered the API of my Honeywell Lyric thermostat and there is no OpenHAB binding for it. But IFTTT supports both OpenHAB and the Lyric, so I just needed two IFTTT applets. One applet uses an OpenHAB trigger for when “Item state raises above” 74°F, then set the thermostat fan to ON. Another applet uses an OpenHAB trigger for when "Item state drops below " 74°F, then set the thermostat fan to OFF.

Now for the 1st time in 19 years, when the sun blasts down on my living room windows in the afternoon, cool air from my bedroom (which was always the coldest room in the house) gets circulated with the warm air in the living room making both rooms more comfortable.

2 Likes

Thanks for posting. I have a similar issue only it is the basement that is much cooler than the main floor and the top floor is much warmer than the other floors. So I built some DIY temp sensors on ESP8266s to report temp and humidity on the top floor and basement and use the temperature differential to turn on/off the furnace’s blower (I don’t have an air conditioner but I do have a forced air heater so can use that as a house fan).

Number aNest_TargetTemp "Furnace Target Temp [%.0f °F]"
    <temperature> (gChart)
    { nest="=[thermostats(Entryway).target_temperature_f]" }

Switch aNest_Fan "Fan [%s]"
    <fan> (gChart) ["Switchable"]
    { nest="=[thermostats(Entryway).fan_timer_active]" }

// Sensors
Number vNest_Temp "Main Floor Ambient Temp [%d °F]"
    <temperature> (gChart, gIndoorTemps)
    { nest="<[thermostats(Entryway).ambient_temperature_f]" }

// top floor
Number vMBR_Temperature  "Master Bedroom Temperature [%.0f °F]"
    <temperature> (gChart, gIndoorTemps, gResetExpire)
    { mqtt="<[mosquitto:mbr-sensors/climate/temperature:state:default]", expire="2m,state=NULL" }

// basement
Number vBasement_Temperature  "Basement Temperature [%.0f °F]"
    <temperature> (gChart, gIndoorTemps, gResetExpire)
    { mqtt="<[mosquitto:basement-sensors/climate/temperature:state:default]", expire="2m,state=NULL" }
var lastchange = now
val logName = "climate"

rule "Turn on the fan when necessary"
when
    Item aNest_TargetTemp changed or
    Item vMBR_Temperature changed or
    Item vBasement_Temperature changed
then
    // get the current temps and the target
    var lowerState = if(vBasement_Temperature.state == NULL) null else vBasement_Temperature.state as Number
    var upperState = if(vMBR_Temperature.state == NULL) null else vMBR_Temperature.state as Number
    var targetState = if(aNest_TargetTemp.state == NULL) null else aNest_TargetTemp.state as Number
    val middleState = if(vNest_Temp.state == NULL) null else vNest_Temp.state as Number

    // Use alternates if the expected sensor value is null
    if(lowerState == null && targetState != null) lowerState = targetState // use the target temp for lower
    if(upperState == null && middleState != null) upperState = middleState // use the main floor temp for upper

    // Exit if we don't have all the values we need
    if(lowerState == null || upperState == null || targetState == null) {
        logError(logName, "Not enough information to make the fan decision: Lower = " + lowerState +
                 " Upper = " + upperState + " Target = " + targetState)
        return;
    }

    // Determine if the fan should be on or off
    val diff = upperState - lowerState // difference between upper floor and lower floor
    var String fanState = "Stay"       // defaul to doing nothing
    if(diff >= 0 && upperState > targetState && upperState > 70) fanState = "ON" // Turn on if temps are the same or upper is greater than target and it's warm
    else if(upperState < targetState - 1) fanState = "OFF" // Turn off if upper is one degree or more lower than the target

    // If we need to change the fan state and it has been at least five minutes since the last change, do it
    if(fanState != "Stay" && lastchange.isBefore(now.minusMinutes(5)) && aNest_Fan.state.toString != fanState){
        logInfo(logName, "Setting house fan to " + fanState)
        aNest_Fan.sendCommand(fanState)
        lastchange = now
    }
end

Posted for those who may want to try to make something work without the dependence on IFTTT. The Rule itself is pretty independent of the type of sensors or thermostats.

1 Like

You may find this project of interest : https://philips-hue-log-and-notify.github.io

It is able to log the temperature to a file so you can then parse it with another program. If you have a hue hub and motion sensors, then it is going to open up further possibilities beyond just this use case.