/** * Copyright 2024 bthrock * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except * in compliance with the License. You may obtain a copy of the License at: * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License * for the specific language governing permissions and limitations under the License. * */ public static String version() {return "1.3.5"} metadata { definition(name: "Replica Thermostat", namespace: "replica", author: "bthrock", importUrl:"https://raw.githubusercontent.com/TheMegamind/Hubitat/main/Replica-Drivers/replicaThermostat.groovy") { capability "Actuator" capability "Battery" capability "Configuration" capability "Refresh" capability "Sensor" capability "Thermostat" capability "TemperatureMeasurement" command "setThermostatOperatingState", [[name: "Thermostat Operating State*", type: "ENUM", description: "Override the SmartThings Operating State or remove it", constraints: [ "idle", "vent economizer", "pending cool", "cooling", "heating", "pending heat", "fan only", "[remove attribute]" ]]] attribute "healthStatus", "enum", ["offline", "online"] } preferences { input(name:"deviceRefreshPollInterval", type: "enum", title: "Refresh Poll Interval", options: [ "manual":"Manual Poll Only", "runEvery1Minute":"1 Minute", "runEvery5Minutes":"5 Minutes", "runEvery10Minutes":"10 Minutes", "runEvery30Minutes":"30 Minutes", "runEvery1Hour":"1 Hour", "runEvery3Hours":"3 Hours"], defaultValue: "manual", required: false) input(name:"deviceInfoDisable", type: "bool", title: "Disable Info logging:", defaultValue: false) } } def installed() { initialize() } def updated() { initialize() } def initialize() { updateDataValue("triggers", groovy.json.JsonOutput.toJson(getReplicaTriggers())) updateDataValue("commands", groovy.json.JsonOutput.toJson(getReplicaCommands())) unschedule() if(settings?.deviceRefreshPollInterval && settings.deviceRefreshPollInterval!="manual") { "${settings.deviceRefreshPollInterval}"(refresh) } } def configure() { logInfo "${device.displayName} configured default rules" initialize() updateDataValue("rules", getReplicaRules()) sendCommand("configure") } // Methods documented here will show up in the Replica Command Configuration. These should be mostly setter in nature. static Map getReplicaCommands() { return ([ "setBatteryValue":[[name:"battery*",type:"NUMBER"]], "setCoolingSetpointValue":[[name:"temperature*",type:"NUMBER"]], "setHeatingSetpointValue":[[name:"temperature*",type:"NUMBER"]], "setSupportedThermostatFanModesValue":[[name:"supportedThermostatFanModes*",type:"ENUM"]], "setSupportedThermostatModesValue":[[name:"supportedThermostatModes*",type:"ENUM"]], "setTemperatureValue":[[name:"temperature*",type:"NUMBER"]], "setThermostatFanModeValue":[[name:"mode*",type:"ENUM"]], "setThermostatFanModeAuto":[], "setThermostatFanModeCirculate":[], "setThermostatFanModeOn":[],"setThermostatFanModeFollowSchedule":[], "setThermostatModeValue":[[name:"mode*",type:"ENUM"]], "setThermostatModeAuto":[], "setThermostatModeCool":[], "setThermostatModeEmergencyHeat":[], "setThermostatModeHeat":[], "setThermostatModeOff":[], "setThermostatOperatingStateValue":[[name:"thermostatOperatingState*",type:"ENUM"]], "setHealthStatusValue":[[name:"healthStatus*",type:"ENUM"]] ]) } def setBatteryValue(value) { String descriptionText = "${device.displayName} battery level is $value %" sendEvent(name: "battery", value: value, unit: "%", descriptionText: descriptionText) logInfo descriptionText } def setCoolingSetpointValue(value) { String unit = "°${getTemperatureScale()}" String descriptionText = "${device.displayName} coolingSetPoint is $value $unit" sendEvent(name: "coolingSetpoint", value: value?.toFloat(), unit: unit, descriptionText: descriptionText) if((device.currentValue("thermostatMode",true)=="cool" || device.currentValue("thermostatMode",true)=="auto")) { sendEvent(name: "thermostatSetpoint", value: value?.toFloat(), unit: unit) if(device.currentValue("heatingSetpoint",true)?.toFloat()