Skip to content

Commit 80bc998

Browse files
committed
Fix issues #24, #25, #26.
1 parent 0feba62 commit 80bc998

2 files changed

Lines changed: 65 additions & 7 deletions

File tree

src/D_EcobeeThermostat1.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@
3939
<serviceId>urn:upnp-org:serviceId:TemperatureSetpoint1_Cool</serviceId>
4040
<SCPDURL>S_TemperatureSetpoint1.xml</SCPDURL>
4141
</service>
42+
<service>
43+
<serviceType>urn:schemas-upnp-org:service:TemperatureSetpoint:1</serviceType>
44+
<serviceId>urn:upnp-org:serviceId:TemperatureSetpoint1</serviceId>
45+
<SCPDURL>S_TemperatureSetpoint1.xml</SCPDURL>
46+
</service>
4247
<service>
4348
<serviceType>urn:schemas-micasaverde-com:service:EnergyMetering:1</serviceType>
4449
<serviceId>urn:micasaverde-com:serviceId:EnergyMetering1</serviceId>

src/I_Ecobee1.xml

Lines changed: 60 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<!--
33
MiOS (Vera) Plugin for ecobee Thermostats
44
5-
Copyright (C) 2013-2015 John W. Cocula and others
5+
Copyright (C) 2013-2016 John W. Cocula and others
66
77
This program is free software: you can redistribute it and/or modify
88
it under the terms of the GNU General Public License as published by
@@ -104,11 +104,12 @@ decompress_lzo_file() {
104104
end
105105

106106
-- constants
107-
local PLUGIN_VERSION = "1.5"
107+
local PLUGIN_VERSION = "1.6"
108108
local ECOBEE_SID = "urn:ecobee-com:serviceId:Ecobee1"
109109
local TEMP_SENSOR_SID = "urn:upnp-org:serviceId:TemperatureSensor1"
110110
local TEMP_SETPOINT_HEAT_SID = "urn:upnp-org:serviceId:TemperatureSetpoint1_Heat"
111111
local TEMP_SETPOINT_COOL_SID = "urn:upnp-org:serviceId:TemperatureSetpoint1_Cool"
112+
local TEMP_SETPOINT_SID = "urn:upnp-org:serviceId:TemperatureSetpoint1"
112113
local HUMIDITY_SENSOR_SID = "urn:micasaverde-com:serviceId:HumiditySensor1"
113114
local HVAC_FAN_SID = "urn:upnp-org:serviceId:HVAC_FanOperatingMode1"
114115
local HVAC_USER_SID = "urn:upnp-org:serviceId:HVAC_UserOperatingMode1"
@@ -232,6 +233,7 @@ decompress_lzo_file() {
232233
["equipmentStatus"] = function(r) return r.equipmentStatus or "unknown" end,
233234
["quickSaveSetBack"] = function(t) return tostring(t.settings.quickSaveSetBack) end,
234235
["quickSaveSetForward"] = function(t) return tostring(t.settings.quickSaveSetForward) end,
236+
["holdType"] = function(t) return "indefinite" end, -- default value on device creation
235237
["currentEventType"] = function(t)
236238
local event = getCurrentEvent(t.events)
237239
return (event and event["type"]) and event["type"] or "none"
@@ -267,6 +269,14 @@ decompress_lzo_file() {
267269
["Application"] = function() return "Cooling" end,
268270
["CurrentSetpoint"] = function(t) return tostring(localizeTemp(t.runtime.desiredCool)) end
269271
},
272+
[TEMP_SETPOINT_SID] = {
273+
["Application"] = function() return "DualHeatingCooling" end,
274+
["CurrentSetpoint"] = function(t)
275+
local desiredTemp = (t.settings.hvacMode == "heat") and t.runtime.desiredHeat or
276+
((t.settings.hvacMode == "cool") and t.runtime.desiredCool or ((t.runtime.desiredHeat + t.runtime.desiredCool) / 2))
277+
return tostring(localizeTemp(desiredTemp))
278+
end
279+
},
270280
[HUMIDITY_SENSOR_SID] = {
271281
["CurrentLevel"] = function(t, cap) return (not cap) and tostring(t.runtime.actualHumidity) or (cap.value == "unknown" and "0" or cap.value) end
272282
},
@@ -378,6 +388,13 @@ decompress_lzo_file() {
378388
end
379389
}
380390
},
391+
[TEMP_SETPOINT_SID] = {
392+
["SetCurrentSetpoint"] = {
393+
["NewCurrentSetpoint"] = function(lul_settings)
394+
return delocalizeTemp(lul_settings.NewCurrentSetpoint)
395+
end
396+
}
397+
},
381398
[HVAC_FAN_SID] = {
382399
["SetMode"] = {
383400
["NewMode"] = function(lul_settings)
@@ -581,9 +598,11 @@ decompress_lzo_file() {
581598
"\n" .. ecobeeToUpnpParam(ECOBEE_SID, "equipmentStatus", r) ..
582599
"\n" .. ecobeeToUpnpParam(ECOBEE_SID, "quickSaveSetBack", t) ..
583600
"\n" .. ecobeeToUpnpParam(ECOBEE_SID, "quickSaveSetForward", t) ..
601+
"\n" .. ecobeeToUpnpParam(ECOBEE_SID, "holdType", t) ..
584602
"\n" .. ecobeeToUpnpParam(TEMP_SENSOR_SID, "CurrentTemperature", t) ..
585603
"\n" .. ecobeeToUpnpParam(TEMP_SETPOINT_HEAT_SID, "CurrentSetpoint", t) ..
586604
"\n" .. ecobeeToUpnpParam(TEMP_SETPOINT_COOL_SID, "CurrentSetpoint", t) ..
605+
"\n" .. ecobeeToUpnpParam(TEMP_SETPOINT_SID, "CurrentSetpoint", t) ..
587606
"\n" .. ecobeeToUpnpParam(HVAC_FAN_SID, "Mode", t) ..
588607
"\n" .. ecobeeToUpnpParam(HVAC_FAN_SID, "FanStatus", t) ..
589608
"\n" .. ecobeeToUpnpParam(HVAC_USER_SID, "ModeStatus", t) ..
@@ -707,9 +726,11 @@ decompress_lzo_file() {
707726
writeVariableFromEcobeeIfChanged(child, ECOBEE_SID, "equipmentStatus", r)
708727
writeVariableFromEcobeeIfChanged(child, ECOBEE_SID, "quickSaveSetBack", t)
709728
writeVariableFromEcobeeIfChanged(child, ECOBEE_SID, "quickSaveSetForward", t)
729+
readVariableOrInit(child, ECOBEE_SID, "holdType", "indefinite") -- create device variable if doesn't exist
710730
writeVariableFromEcobeeIfChanged(child, TEMP_SENSOR_SID, "CurrentTemperature", t)
711731
writeVariableFromEcobeeIfChanged(child, TEMP_SETPOINT_HEAT_SID, "CurrentSetpoint", t)
712732
writeVariableFromEcobeeIfChanged(child, TEMP_SETPOINT_COOL_SID, "CurrentSetpoint", t)
733+
writeVariableFromEcobeeIfChanged(child, TEMP_SETPOINT_SID, "CurrentSetpoint", t)
713734
writeVariableFromEcobeeIfChanged(child, HVAC_FAN_SID, "Mode", t)
714735
writeVariableFromEcobeeIfChanged(child, HVAC_FAN_SID, "FanStatus", t)
715736
writeVariableFromEcobeeIfChanged(child, HVAC_USER_SID, "ModeStatus", t)
@@ -819,6 +840,9 @@ decompress_lzo_file() {
819840
return false
820841
end
821842

843+
-- determine which type of hold to set
844+
func.params.holdType = readVariableOrInit(lul_device, ECOBEE_SID, "holdType", "indefinite")
845+
822846
-- if selection is nil, we will make our own.
823847
selection = selection or getSelection(session, lul_device)
824848

@@ -852,7 +876,7 @@ decompress_lzo_file() {
852876
end
853877

854878
local function setClimateHold(session, selection, lul_device, holdClimateRef)
855-
local func = ecobee.setHoldFunction(nil, nil, "indefinite")
879+
local func = ecobee.setHoldFunction()
856880
func.params.holdClimateRef = holdClimateRef
857881
return setHold(session, selection, lul_device, func)
858882
end
@@ -876,7 +900,7 @@ decompress_lzo_file() {
876900
local quickSaveSetForward = luup.variable_get(ECOBEE_SID, "quickSaveSetForward", lul_device)
877901
quickSaveSetForward = tonumber(quickSaveSetForward) or 40 -- TODO
878902

879-
local func = ecobee.setHoldFunction(nil, nil, "indefinite")
903+
local func = ecobee.setHoldFunction()
880904
func.params.coolRelativeTemp = quickSaveSetForward
881905
func.params.heatRelativeTemp = quickSaveSetBack
882906
func.params.isTemperatureRelative = false
@@ -1070,7 +1094,7 @@ decompress_lzo_file() {
10701094
<run>
10711095
local heatHoldTemp = upnpToEcobee(TEMP_SETPOINT_HEAT_SID, "SetCurrentSetpoint", "NewCurrentSetpoint", lul_settings)
10721096
local session = loadSession()
1073-
local func = ecobee.setHoldFunction(nil, heatHoldTemp, "indefinite")
1097+
local func = ecobee.setHoldFunction(nil, heatHoldTemp)
10741098
if not setHold(session, nil, lul_device, func) then
10751099
task("Failed to set heat temperature setpoint.")
10761100
end
@@ -1096,7 +1120,7 @@ decompress_lzo_file() {
10961120
<run>
10971121
local coolHoldTemp = upnpToEcobee(TEMP_SETPOINT_COOL_SID, "SetCurrentSetpoint", "NewCurrentSetpoint", lul_settings)
10981122
local session = loadSession()
1099-
local func = ecobee.setHoldFunction(coolHoldTemp, nil, "indefinite")
1123+
local func = ecobee.setHoldFunction(coolHoldTemp, nil)
11001124
if not setHold(session, nil, lul_device, func) then
11011125
task("Failed to set cool temperature setpoint.")
11021126
end
@@ -1109,6 +1133,35 @@ decompress_lzo_file() {
11091133
return luup.variable_get(TEMP_SETPOINT_COOL_SID, "CurrentSetpoint", lul_device)
11101134
</run>
11111135
</action>
1136+
<action>
1137+
<serviceId>urn:upnp-org:serviceId:TemperatureSetpoint1</serviceId>
1138+
<name>GetApplication</name>
1139+
<run>
1140+
return ecobeeToUpnp(TEMP_SETPOINT_SID, "Application")
1141+
</run>
1142+
</action>
1143+
<action>
1144+
<serviceId>urn:upnp-org:serviceId:TemperatureSetpoint1</serviceId>
1145+
<name>SetCurrentSetpoint</name>
1146+
<run>
1147+
local holdTemp = upnpToEcobee(TEMP_SETPOINT_SID, "SetCurrentSetpoint", "NewCurrentSetpoint", lul_settings)
1148+
local modeStatus = luup.variable_get(HVAC_USER_SID, "ModeStatus", lul_device) or "AutoChangeOver"
1149+
local heatHoldTemp = (modeStatus ~= "CoolOn") and holdTemp or nil
1150+
local coolHoldTemp = (modeStatus ~= "HeatOn") and holdTemp or nil
1151+
local session = loadSession()
1152+
local func = ecobee.setHoldFunction(coolHoldTemp, heatHoldTemp)
1153+
if not setHold(session, nil, lul_device, func) then
1154+
task("Failed to set temperature setpoint.")
1155+
end
1156+
</run>
1157+
</action>
1158+
<action>
1159+
<serviceId>urn:upnp-org:serviceId:TemperatureSetpoint1</serviceId>
1160+
<name>GetCurrentSetpoint</name>
1161+
<run>
1162+
return luup.variable_get(TEMP_SETPOINT_SID, "CurrentSetpoint", lul_device)
1163+
</run>
1164+
</action>
11121165
<action>
11131166
<serviceId>urn:upnp-org:serviceId:HVAC_UserOperatingMode1</serviceId>
11141167
<name>SetModeTarget</name>
@@ -1145,7 +1198,7 @@ decompress_lzo_file() {
11451198
<name>SetMode</name>
11461199
<run>
11471200
local session = loadSession()
1148-
local func = ecobee.setHoldFunction(nil, nil, "indefinite")
1201+
local func = ecobee.setHoldFunction()
11491202
func.params.fan = upnpToEcobee(HVAC_FAN_SID, "SetMode", "NewMode", lul_settings)
11501203
if not setHold(session, nil, lul_device, func) then
11511204
task("Failed to set fan mode to " .. tostring(mode))

0 commit comments

Comments
 (0)