Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).

## 2024-11-12

### sdm-api-app:1.1.3
### sdm-api-thermostat:1.0.2
* Round heat/cool set points and dead band calculation to one decimal place
* Addresses issue with invalid set points when within the dead band range

## 2024-05-07

### sdm-api-app:1.1.2
Expand Down
4 changes: 2 additions & 2 deletions packageManifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"required": true,
"oauth": true,
"primary": true,
"version": "1.1.2"
"version": "1.1.3"
}
],
"drivers": [
Expand All @@ -24,7 +24,7 @@
"namespace": "dkilgore90",
"location": "https://raw.githubusercontent.com/dkilgore90/google-sdm-api/master/sdm-api-thermostat.groovy",
"required": false,
"version": "1.0.1"
"version": "1.0.2"
},
{
"id": "207a67b0-8790-41b9-8b5f-00467d55a00a",
Expand Down
14 changes: 5 additions & 9 deletions sdm-api-app.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import groovy.json.JsonOutput
* See the License for the specific language governing permissions and
* limitations under the License.
*
* version: 1.1.2
* version: 1.1.3
*/

definition(
Expand Down Expand Up @@ -540,7 +540,7 @@ def convertAndRoundTemp(value) {
if (getTemperatureScale() == 'F') {
return new Double(celsiusToFahrenheit(value)).round()
} else {
return new Double(value * 2).round() / 2
return new Double(value).round(1)
}
}

Expand Down Expand Up @@ -823,16 +823,12 @@ def deviceSetTemperatureSetpoint(com.hubitat.app.DeviceWrapper device, heatPoint
log.warn('Cannot adjust temperature setpoint(s) when device is in MANUAL_ECO mode')
return
}
if (device.currentValue('tempScale') == 'FAHRENHEIT') {
coolPoint = coolPoint ? fahrenheitToCelsius(coolPoint) : null
heatPoint = heatPoint ? fahrenheitToCelsius(heatPoint) : null
}
if (coolPoint && heatPoint) {
deviceSendCommand(device, 'sdm.devices.commands.ThermostatTemperatureSetpoint.SetRange', [coolCelsius: coolPoint, heatCelsius: heatPoint])
deviceSendCommand(device, 'sdm.devices.commands.ThermostatTemperatureSetpoint.SetRange', [coolCelsius: convertAndRoundTemp(coolPoint), heatCelsius: convertAndRoundTemp(heatPoint)])
} else if (coolPoint) {
deviceSendCommand(device, 'sdm.devices.commands.ThermostatTemperatureSetpoint.SetCool', [coolCelsius: coolPoint])
deviceSendCommand(device, 'sdm.devices.commands.ThermostatTemperatureSetpoint.SetCool', [coolCelsius: convertAndRoundTemp(coolPoint)])
} else if (heatPoint) {
deviceSendCommand(device, 'sdm.devices.commands.ThermostatTemperatureSetpoint.SetHeat', [heatCelsius: heatPoint])
deviceSendCommand(device, 'sdm.devices.commands.ThermostatTemperatureSetpoint.SetHeat', [heatCelsius: convertAndRoundTemp(heatPoint)])
}
}

Expand Down
22 changes: 14 additions & 8 deletions sdm-api-thermostat.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import groovy.json.JsonOutput
* See the License for the specific language governing permissions and
* limitations under the License.
*
* version: 1.0.1
* version: 1.0.2
*/

metadata {
Expand Down Expand Up @@ -118,8 +118,9 @@ def setCoolingSetpoint(temp) {
} else if (mode == 'auto') {
def heat = device.currentValue('heatingSetpoint')
def tempMovement = checkDeadband(heat, temp)
// if the cool set point violates the necessary dead band, then decrease the heat set point from the cool setpoint
if (tempMovement > 0) {
heat = heat.toFloat() - tempMovement.toFloat()
heat = temp - tempMovement
}
parent.deviceSetTemperatureSetpoint(device, heat, temp)
} else {
Expand All @@ -134,8 +135,9 @@ def setHeatingSetpoint(temp) {
} else if (mode == 'auto') {
def cool = device.currentValue('coolingSetpoint')
def tempMovement = checkDeadband(temp, cool)
// if the heat set point violates the necessary dead band, then increase the cool set point from the heat setpoint
if (tempMovement > 0) {
cool = cool.toFloat() + tempMovement.toFloat()
cool = temp + tempMovement
}
parent.deviceSetTemperatureSetpoint(device, temp, cool)
} else {
Expand All @@ -146,8 +148,8 @@ def setHeatingSetpoint(temp) {
def setHeatCoolSetpoint(heat, cool) {
def mode = device.currentValue('thermostatMode')
if (mode == 'auto') {
def tempMovement = checkDeadband(heat, cool)
if (tempMovement <= 0) {
// when setting heat and cool, we do not know which set point to adjust for the deadband, so log an error
if (checkDeadband(heat, cool) == 0) {
parent.deviceSetTemperatureSetpoint(device, heat, cool)
} else {
log.error("Heat/Cool setpoints require a minimum deadband of 1.5*C or 2.7*F -- inputs: ${heat} / ${cool}")
Expand All @@ -160,10 +162,14 @@ def setHeatCoolSetpoint(heat, cool) {
def checkDeadband(heat, cool) {
try {
def deadband = getTemperatureScale() == 'F' ? 2.7 : 1.5
def tempMovement = heat.toFloat() - cool.toFloat() + deadband
return tempMovement
// check if we have the necessary deadband between the heat and cool set points
if ((cool - heat) < deadband) {
return (deadband)
} else {
return (0.0)
}
} catch (NullPointerException e) {
return 0
return (0.0)
}
}

Expand Down