Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ICP-7174 ICP-7282 ICP-7283 ICP-7308 ICP-7309 ICP-7288 ICP-7289 Misc Stelpro fixes #3750

Merged
merged 14 commits into from Jan 3, 2019
Merged
Expand Up @@ -141,6 +141,7 @@ def setupHealthCheck() {

def configureSupportedRanges() {
sendEvent(name: "supportedThermostatModes", value: supportedThermostatModes, displayed: false)
// These are part of the deprecated Thermostat capability. Remove these when that capability is removed.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am checking to see if OneApp uses this in anyway. It didn't seem like its presence affected the range displayed in OneApp, but I want to make sure it isn't needed because of the reference to "Thermostat" in the capabilities.

This applies to all three device handlers.

sendEvent(name: "thermostatSetpointRange", value: thermostatSetpointRange, displayed: false)
sendEvent(name: "heatingSetpointRange", value: heatingSetpointRange, displayed: false)
}
Expand Down Expand Up @@ -170,6 +171,10 @@ def parse(String description) {
if (!device.currentValue("supportedThermostatModes")) {
configureSupportedRanges()
}
// Existing installations need the temperatureAlarm state initialized
if (device.currentValue("temperatureAlarm") == null) {
sendEvent(name: "temperatureAlarm", value: "cleared", displayed: false)
}

if (description == "updated") {
return null
Expand Down Expand Up @@ -291,22 +296,27 @@ def zwaveEvent(sensormultilevelv3.SensorMultilevelReport cmd) {

temp = map.value
// The specific values checked below represent ambient temperature alarm indicators
if (temp == "32765") { // 0x7FFD
if (temp == 0x7ffd) {
map.name = "temperatureAlarm"
map.value = "freeze"
map.unit = ""
} else if (temp == "32767") { // 0x7FFF
map.unit = null
dkirker marked this conversation as resolved.
Show resolved Hide resolved
} else if (temp == 0x7fff) {
map.name = "temperatureAlarm"
map.value = "heat"
map.unit = ""
} else if (temp == "-32768"){ // 0x8000
map.name = "temperatureAlarm"
map.value = "cleared"
map.unit = ""
map.unit = null
} else if (temp == 0x8000){
map.name = null
map.value = null
map.unit = null
map.descriptionText = "Received a temperature error"
} else {
tempfloat = (Math.round(temp.toFloat() * 2)) / 2
map.value = tempfloat
}

if (device.currentValue("temperatureAlarm") != "cleared" && map.name == "temperature") {
sendEvent(name: "temperatureAlarm", value: "cleared")
}
} else if (cmd.sensorType == sensormultilevelv3.SensorMultilevelReport.SENSOR_TYPE_RELATIVE_HUMIDITY_VERSION_2) {
map.value = cmd.scaledSensorValue
map.unit = "%"
Expand Down
Expand Up @@ -170,6 +170,7 @@ def setupHealthCheck() {

def configureSupportedRanges() {
sendEvent(name: "supportedThermostatModes", value: supportedThermostatModes, displayed: false)
// These are part of the deprecated Thermostat capability. Remove these when that capability is removed.
sendEvent(name: "thermostatSetpointRange", value: thermostatSetpointRange, displayed: false)
sendEvent(name: "heatingSetpointRange", value: heatingSetpointRange, displayed: false)
}
Expand Down Expand Up @@ -243,17 +244,18 @@ def parse(String description) {
map.unit = getTemperatureScale()
map.value = getTemperature(descMap.value)

if (intVal == 0x7ffd) { // 0x7FFD
if (intVal == 0x7ffd) {
map.name = "temperatureAlarm"
map.value = "freeze"
map.unit = ""
} else if (intVal == 0x7fff) { // 0x7FFF
map.unit = null
} else if (intVal == 0x7fff) {
map.name = "temperatureAlarm"
map.value = "heat"
map.unit = ""
} else if (intVal == 0x8000) { // 0x8000
map.unit = null
} else if (intVal == 0x8000) {
map.name = null
map.value = null
map.unit = null
map.descriptionText = "Received a temperature error"
} else if (intVal > 0x8000) {
map.value = -(Math.round(2*(655.36 - map.value))/2)
Expand All @@ -264,10 +266,11 @@ def parse(String description) {
}
} else if (descMap.attrInt == ATTRIBUTE_HEAT_SETPOINT) {
def intVal = Integer.parseInt(descMap.value, 16)
if (intVal != 0x8000) { // 0x8000
if (intVal != 0x8000) {
log.debug "HEATING SETPOINT"
map.name = "heatingSetpoint"
map.value = getTemperature(descMap.value)
map.unit = getTemperatureScale()
map.data = [heatingSetpointRange: heatingSetpointRange]
}
} else if (descMap.attrInt == ATTRIBUTE_SYSTEM_MODE) {
Expand Down Expand Up @@ -310,13 +313,16 @@ def parse(String description) {
def intVal = Integer.parseInt(descMap.value, 16)
log.debug "HEAT DEMAND"
map.name = "thermostatOperatingState"
if (intVal < 10) {
if (intVal < 0x10) {
map.value = "idle"
} else {
map.value = "heating"
}

if (settings.heatdetails == "No") {
// If the user does not want to see the Idle and Heating events in the event history,
// don't show them. Otherwise, don't show them more frequently than 30 seconds.
if (settings.heatdetails == "No" ||
!secondsPast(device.currentState("thermostatOperatingState").getLastUpdated(), 30)) {
dkirker marked this conversation as resolved.
Show resolved Hide resolved
map.displayed = false
}
}
Expand Down Expand Up @@ -394,7 +400,8 @@ def getTemperature(value) {
if (getTemperatureScale() == "C") {
return celsius
} else {
return Math.round(celsiusToFahrenheit(celsius))
def rounded = new BigDecimal(celsiusToFahrenheit(celsius)).setScale(0, BigDecimal.ROUND_HALF_UP)
return rounded
}
}
}
Expand Down Expand Up @@ -519,7 +526,7 @@ def configure() {
requests += zigbee.configureReporting(THERMOSTAT_CLUSTER, ATTRIBUTE_HEAT_SETPOINT, DataType.INT16, 1, 0, 50)
requests += zigbee.configureReporting(THERMOSTAT_CLUSTER, ATTRIBUTE_SYSTEM_MODE, DataType.ENUM8, 1, 0, 1)
requests += zigbee.configureReporting(THERMOSTAT_CLUSTER, ATTRIBUTE_MFR_SPEC_SETPOINT_MODE, DataType.ENUM8, 1, 0, 1)
requests += zigbee.configureReporting(THERMOSTAT_CLUSTER, ATTRIBUTE_PI_HEATING_STATE, DataType.UINT8, 300, 900, 5)
requests += zigbee.configureReporting(THERMOSTAT_CLUSTER, ATTRIBUTE_PI_HEATING_STATE, DataType.UINT8, 1, 900, 1)

// Configure Thermostat Ui Conf Cluster
requests += zigbee.configureReporting(THERMOSTAT_UI_CONFIG_CLUSTER, ATTRIBUTE_TEMP_DISP_MODE, DataType.ENUM8, 1, 0, 1)
Expand Down Expand Up @@ -570,4 +577,26 @@ def fanAuto() {
log.debug "${device.displayName} does not support fan auto"
}

/**
* Checks if the time elapsed from the provided timestamp is greater than the number of senconds provided
*
* @param timestamp: The timestamp
*
* @param seconds: The number of seconds
*
* @returns true if elapsed time is greater than number of seconds provided, else false
*/
private Boolean secondsPast(timestamp, seconds) {
if (!(timestamp instanceof Number)) {
if (timestamp instanceof Date) {
timestamp = timestamp.time
} else if ((timestamp instanceof String) && timestamp.isNumber()) {
timestamp = timestamp.toLong()
} else {
return true
}
}
return (now() - timestamp) > (seconds * 1000)
}


Expand Up @@ -182,6 +182,7 @@ def setupHealthCheck() {

def configureSupportedRanges() {
sendEvent(name: "supportedThermostatModes", value: supportedThermostatModes, displayed: false)
// These are part of the deprecated Thermostat capability. Remove these when that capability is removed.
sendEvent(name: "thermostatSetpointRange", value: thermostatSetpointRange, displayed: false)
sendEvent(name: "heatingSetpointRange", value: heatingSetpointRange, displayed: false)
}
Expand Down Expand Up @@ -255,17 +256,18 @@ def parse(String description) {
map.unit = getTemperatureScale()
map.value = getTemperature(descMap.value)

if (intVal == 0x7ffd) { // 0x7FFD
if (intVal == 0x7ffd) {
map.name = "temperatureAlarm"
map.value = "freeze"
map.unit = ""
} else if (intVal == 0x7fff) { // 0x7FFF
map.unit = null
} else if (intVal == 0x7fff) {
map.name = "temperatureAlarm"
map.value = "heat"
map.unit = ""
} else if (intVal == 0x8000) { // 0x8000
map.unit = null
} else if (intVal == 0x8000) {
map.name = null
map.value = null
map.unit = null
map.descriptionText = "Received a temperature error"
} else if (intVal > 0x8000) {
map.value = -(Math.round(2*(655.36 - map.value))/2)
Expand All @@ -276,23 +278,27 @@ def parse(String description) {
}
} else if (descMap.attrInt == ATTRIBUTE_HEAT_SETPOINT) {
def intVal = Integer.parseInt(descMap.value, 16)
if (intVal != 0x8000) { // 0x8000
if (intVal != 0x8000) {
log.debug "HEATING SETPOINT"
map.name = "heatingSetpoint"
map.value = getTemperature(descMap.value)
map.unit = getTemperatureScale()
map.data = [heatingSetpointRange: heatingSetpointRange]
}
} else if (descMap.attrInt == ATTRIBUTE_PI_HEATING_STATE) {
def intVal = Integer.parseInt(descMap.value, 16)
log.debug "HEAT DEMAND"
map.name = "thermostatOperatingState"
if (intVal < 10) {
if (intVal < 0x10) {
dkirker marked this conversation as resolved.
Show resolved Hide resolved
map.value = "idle"
} else {
map.value = "heating"
}

if (settings.heatdetails == "No") {
// If the user does not want to see the Idle and Heating events in the event history,
// don't show them. Otherwise, don't show them more frequently than 30 seconds.
if (settings.heatdetails == "No" ||
!secondsPast(device.currentState("thermostatOperatingState").getLastUpdated(), 30)) {
map.displayed = false
}
}
Expand Down Expand Up @@ -382,7 +388,8 @@ def getTemperature(value) {
if (getTemperatureScale() == "C") {
return celsius
} else {
return Math.round(celsiusToFahrenheit(celsius))
def rounded = new BigDecimal(celsiusToFahrenheit(celsius)).setScale(0, BigDecimal.ROUND_HALF_UP)
return rounded
}
}
}
Expand Down Expand Up @@ -479,7 +486,7 @@ def configure() {
// Configure Thermostat Cluster
requests += zigbee.configureReporting(THERMOSTAT_CLUSTER, ATTRIBUTE_LOCAL_TEMP, DataType.INT16, 10, 60, 50)
requests += zigbee.configureReporting(THERMOSTAT_CLUSTER, ATTRIBUTE_HEAT_SETPOINT, DataType.INT16, 1, 0, 50)
requests += zigbee.configureReporting(THERMOSTAT_CLUSTER, ATTRIBUTE_PI_HEATING_STATE, DataType.UINT8, 300, 900, 5)
requests += zigbee.configureReporting(THERMOSTAT_CLUSTER, ATTRIBUTE_PI_HEATING_STATE, DataType.UINT8, 1, 900, 1)

// Configure Thermostat Ui Conf Cluster
requests += zigbee.configureReporting(THERMOSTAT_UI_CONFIG_CLUSTER, ATTRIBUTE_TEMP_DISP_MODE, DataType.ENUM8, 1, 0, 1)
Expand Down Expand Up @@ -535,4 +542,26 @@ def fanAuto() {
log.debug "${device.displayName} does not support fan auto"
}

/**
* Checks if the time elapsed from the provided timestamp is greater than the number of senconds provided
*
* @param timestamp: The timestamp
*
* @param seconds: The number of seconds
*
* @returns true if elapsed time is greater than number of seconds provided, else false
*/
private Boolean secondsPast(timestamp, seconds) {
if (!(timestamp instanceof Number)) {
if (timestamp instanceof Date) {
timestamp = timestamp.time
} else if ((timestamp instanceof String) && timestamp.isNumber()) {
timestamp = timestamp.toLong()
} else {
return true
}
}
return (now() - timestamp) > (seconds * 1000)
}