I emailed the author but I’ve not heard back so I’m using the HTTP binding too. How to return current temp from my thermostat? had some interesting ideas. My setup is below, works with OpenHAB v1.7.1.
items/ct50.items
/*
** WiFi Radio Thermostat CT50 3M-50
** Should work with CT-80, CT-100, etc.
**
** Based in information from:
** * https://github.com/openhab/openhab/wiki/Explanation-of-items
** * https://github.com/openhab/openhab/wiki/Http-Binding
** * https://community.openhab.org/t/how-to-return-current-temp-from-my-thermostat/3141
** * https://community.openhab.org/t/how-to-return-current-temp-from-my-thermostat/3141/8
**
** TODO Add notes to https://github.com/openhab/openhab/wiki/Samples-Binding-Config?
** TODO see what happened to radiothermostat bindings described in
** https://groups.google.com/forum/#!searchin/openhab/radiothermostat/openhab/mUxUm34k5fA/m3kMwqrA-0YJ
CT-50 has limited control/sensors (for example, no humidity). Sample JSON payload for reading current HEATING mode:
{
"temp": 69.50,
"tmode": 1,
"fmode": 0,
"override": 0,
"hold": 0,
"t_heat": 55.00,
"tstate": 0,
"fstate": 0,
"time": {
"day": 5,
"hour": 11,
"minute": 18
},
"t_type_post": 0
}
TODO/not-implemented:
* hold
* t_type_post
* cooling target; t_cool (tmode=2)
*/
Group All
Group gHVAC (All)
Group gHVAC_CT50 "House Heating/Cooling" <temperature> (gHVAC)
/*
** TODO set http caching up in openhab.cfg file to match URLs below
**
** # configuration of WiFi Radio Thermostat CT50 3M-50
** http:ct50-cache.url=http://192.168.11.39/tstat
** # once per minute
** http:ct50-cache.updateInterval=60000
*/
Number HVAC_CT50_CurrentTemp "Current Temperature [%.1f F]" <temperature> (gHVAC_CT50) { http="<[ct50-cache:60000:JSONPATH($.temp)]" }
Number HVAC_CT50_TargetHeatTemp "Target Heat Temperature [%.1f F]" <temperature> (gHVAC_CT50) { http="<[ct50-cache:60000:JSONPATH($.t_heat)]" }
String HVAC_CT50_Mode "Thermostat Mode [MAP(ct50_en.map):%s_prog]" (gHVAC_CT50) { http="<[ct50-cache:60000:JSONPATH($.tmode)]" }
String HVAC_CT50_Override "Override [%d]" (gHVAC_CT50) { http="<[ct50-cache:60000:JSONPATH($.override)]" }
String HVAC_CT50_State "HVAC State [MAP(ct50_en.map):%d]" (gHVAC_CT50) { http="<[ct50-cache:60000:JSONPATH($.tstate)]" }
String HVAC_CT50_FanMode "Fan mode [MAP(ct50_fan_en.map):%d]" (gHVAC_CT50) { http="<[ct50-cache:60000:JSONPATH($.fmode)]" }
Number HVAC_CT50_FanState "Fan state [%d]" (gHVAC_CT50) { http="<[ct50-cache:60000:JSONPATH($.fstate)]" }
String HVAC_CT50_DayTime "DayTime [%s]" (gHVAC_CT50) { http="<[ct50-cache:60000:JS(ct50_get_daytime.js)]" }
/*
String HVAC_CT50_Day "Day [%s]" (gHVAC_CT50) { http="<[ct50-cache:60000:JSONPATH($.time.day)]" }
String HVAC_CT50_Time "Time [%s]" (gHVAC_CT50) { http="<[ct50-cache:60000:JS(ct50_get_time.js)]" }
ct50_get_time.js:
// Wrap everything in a function
(function(json_str) {
var
data = JSON.parse(json_str);
return data.time.hour.toString() + ':' + data.time.minute.toString();
})(input)
// input variable contains data passed by openhab
*/
Switch HVAC_CT50_SetHeatTemp_55F "Set Target Heat Temperature to 55F" <temperature> (gHVAC_CT50)
Switch HVAC_CT50_SetHeatTemp_70F "Set Target Heat Temperature to 70F" <temperature> (gHVAC_CT50)
rules/ct50.rules
rule "Set Heating Target Temperature"
when
Item HVAC_CT50_TargetHeatTemp received command
then
logInfo("HVAC", "HVAC_CT50_TargetHeatTemp received: " + receivedCommand)
output = sendHttpPostRequest("http://192.168.11.39/tstat", "application/json", '{"tmode":1,"t_heat":' + receivedCommand + '}')
logInfo("HVAC", "HVAC Command sent - output: " + output)
end
rule "Set Heating Target Temperature 55F"
when
Item HVAC_CT50_SetHeatTemp_55F received command
then
logInfo("HVAC", "HVAC_CT50_SetHeatTemp_55F received: " + receivedCommand)
output = sendHttpPostRequest("http://192.168.11.39/tstat", "application/json", '{"tmode":1,"t_heat":55}')
logInfo("HVAC", "HVAC Command sent - output: " + output)
end
rule "Set Heating Target Temperature 70F"
when
Item HVAC_CT50_SetHeatTemp_70F received command
then
logInfo("HVAC", "HVAC_CT50_SetHeatTemp_70F received: " + receivedCommand)
output = sendHttpPostRequest("http://192.168.11.39/tstat", "application/json", '{"tmode":1,"t_heat":70}')
logInfo("HVAC", "HVAC Command sent - output: " + output)
end
rule "Set Fan"
when
Item HVAC_CT50_FanMode received command
then
logInfo("HVAC", "HVAC_CT50_FanMode received: " + receivedCommand)
output = sendHttpPostRequest("http://192.168.11.39/tstat/fmode", "application/json", '{"fmode":' + receivedCommand + '}')
logInfo("HVAC", "HVAC Command sent - output: " + output)
end
rule "Set Thermostat Mode"
when
Item HVAC_CT50_Mode received command
then
logInfo("HVAC", "HVAC_CT50_Mode received: " + receivedCommand)
output = sendHttpPostRequest("http://192.168.11.39/tstat", "application/json", '{"tmode":' + receivedCommand + '}')
logInfo("HVAC", "HVAC Command sent - output: " + output)
end
sitemaps/ct50.sitemap
/*
** Sitemap for WiFi Radio Thermostat CT50 3M-50
** See https://github.com/openhab/openhab/wiki/Explanation-of-Sitemaps
*/
sitemap house label="CT50 Thermostat"
{
Frame label="Thermostat" {
Text item=HVAC_CT50_DayTime
/*
Text item=HVAC_CT50_Day
Text item=HVAC_CT50_Time
*/
Text item=HVAC_CT50_CurrentTemp
Text item=HVAC_CT50_TargetHeatTemp
Text item=HVAC_CT50_Mode
Text item=HVAC_CT50_Override
Text item=HVAC_CT50_State
Text item=HVAC_CT50_FanMode
Text item=HVAC_CT50_FanState
Setpoint item=HVAC_CT50_TargetHeatTemp label="Set target Heating temperature [%d F]" icon="temperature" step=1
Switch item=HVAC_CT50_SetHeatTemp_70F mappings=[ON="70"]
Switch item=HVAC_CT50_SetHeatTemp_55F mappings=[ON="55"]
Switch item=HVAC_CT50_FanMode label="Fan" icon="settings" mappings=[0="Auto(Off)", 2="On"]
Switch item=HVAC_CT50_Mode mappings=[0="Off", 1="Heat", 2="Cool", 3="Auto"]
}
}
transform/ct50_en.map
0=OFF
0_prog=OFF
1_prog=Heating program
2_prog=Cool program
3_prog=Auto program
1=Heating
2=Cooling
transform/ct50_fan_en.map
0=OFF
2=On
transform/ct50_get_daytime.js
/*
** Parse JSON from WiFi Radio Thermostat CT50 3M-50
** https://github.com/openhab/openhab/wiki/Transformations#java-script-transformation-service
*/
// Wrap everything in a function
(function(json_str) {
var data = JSON.parse(json_str);
// Hard coded English days of the week
var day_description = {
0: 'Monday',
1: 'Tuesday',
2: 'Wednesday',
3: 'Thursday',
4: 'Friday',
5: 'Saturday',
6: 'Sunday',
};
//return data.time.day.toString() + ' ' + data.time.hour.toString() + ':' + data.time.minute.toString();
data = data.time
//return day_description[data.time.day] + ' ' + data.time.hour.toString() + ':' + data.time.minute.toString();
// Prefix with leading zero
return day_description[data.day] + ' ' + (data.hour <= 9 ? '0' : '') + data.hour.toString() + ':' + (data.minute <= 9 ? '0' : '') + data.minute.toString();
})(input)
// input variable contains data passed by openhab