metadata { definition(name: "Tasmota Ar Condicionado IR Zero.1", namespace: "jorgepalmeira", author: "Jorge Palmeira") { capability "Switch" capability "Thermostat" capability "Thermostat Cooling Setpoint" capability "Thermostat Setpoint" capability "Sensor" capability "Actuator" capability "Configuration" capability "Refresh" capability "HealthCheck" } } preferences { input name: "TasmotaIP", title:"local IP address of Tasmota IR", type: "string", required: true input name: "username", title:"Username of Tasmota IR", type: "string" input name: "password", title:"Password of Tasmota IR", type: "string" input name: "ACvendor", title:"Vendor string of Air Conditioner", options: ["SAMSUNG_AC", "LG", "LG2", "COOLIX", "DAIKIN", "KELVINATOR", "MITSUBISHI_AC", "GREE", "ARGO", "TROTEC", "TOSHIBA_AC", "FUJITSU_AC", "MIDEA", "HAIER_AC", "HITACHI_AC", "HAIER_AC_YRW02", "WHIRLPOOL_AC", "ELECTRA_AC", "PANASONIC_AC", "DAIKIN2", "VESTEL_AC", "TECO", "TCL112AC", "MITSUBISHI_HEAVY_88", "MITSUBISHI_HEAVY_152", "DAIKIN216", "SHARP_AC", "GOODWEATHER", "DAIKIN160", "NEOCLIMA", "DAIKIN176", "DAIKIN128"], type: "enum", required: true, defaultValue: "SAMSUNG_AC" input name: "offThreshold", title:"Off Threshold Power (W)", type: "number", required: true, defaultValue: 3.9 input name: "onThreshold", title:"On Threshold Power (W)", type: "number", required: true, defaultValue: 4 } def parse(String description) { log.debug description } def installed() { initialize() } def updated() { initialize() } def initialize() { } def on() { sendTasmota('IRhvac {"Vendor":"'+VENDOR+'", "Power":"On","Mode":"Cool","FanSpeed":"Auto","Temp":"'+device.currentValue("coolingSetpoint")+'","Quiet":"Off","Turbo":"Off","Econo":"Off","Light":"On"}') sendEvent(name: "switch", value: "on") sendEvent(name: "thermostatMode", value: "cool", descriptionText: "Thermostat Mode set to cool", isStateChange: true) } def off() { sendTasmota('IRhvac {"Vendor":"'+VENDOR+'", "Power":"Off"}') sendEvent(name: "thermostatMode", value: "off", descriptionText: "Thermostat Mode set to off", isStateChange: true) sendEvent(name: "switch", value: "off", displayed: true, isStateChange: true) } // colei aqui pra baixo def setCoolingSetpoint(temperature) { sendTasmota('IRhvac {"Vendor":"'+VENDOR+'","Power":"On","Mode":"Cool","FanSpeed":"Auto","Temp":"'+temperature+'","Quiet":"Off","Turbo":"Off","Econo":"Off","Light":"On"}') sendEvent(name: "coolingSetpoint", value: temperature) } def emergencyStop() { sendEvent(name: "thermostatMode", value: "emergency stop") } def heat() { sendEvent(name: "thermostatMode", value: "heat", descriptionText: "Thermostat Mode set to heat", isStateChange: true) sendTasmota('IRhvac {"Vendor":"'+VENDOR+'","Power":"On","Mode":"Cool","FanSpeed":"Min","Temp":"'+temperature+'","Quiet":"Off","Turbo":"Off","Econo":"Off","Light":"On"}') } def auto() { sendEvent(name: "thermostatMode", value: "auto", descriptionText: "Thermostat Mode set to auto", isStateChange: true) sendTasmota('IRhvac {"Vendor":"'+VENDOR+'","Power":"On","Mode":"Cool","FanSpeed":"Auto","Temp":"'+temperature+'","Quiet":"Off","Turbo":"Off","Econo":"Off","Light":"On"}') } def emergencyHeat() { sendEvent(name: "thermostatMode", value: "emergency heat") } def cool() { sendEvent(name: "thermostatMode", value: "cool", descriptionText: "Thermostat Mode set to cool", isStateChange: true) sendTasmota('IRhvac {"Vendor":"'+VENDOR+'","Power":"On","Mode":"Cool","FanSpeed":"Auto","Temp":"'+temperature+'","Quiet":"Off","Turbo":"On","Econo":"Off","Light":"On"}') } def fan() { send_Event(name: "thermostatMode", value: "fan", descriptionText: "Thermostat Mode set to fan", isStateChange: true) } def dry() { sendEvent(name: "thermostatMode", value: "dry", descriptionText: "Thermostat Mode set to dry", isStateChange: true) } def poll() { null } // colei aqui def sendTasmota(command) { def options = [ method: "GET", headers: [HOST: settings.TasmotaIP+":80"], path: "/cm?user=" + (settings.username ?: "") + "&password=" + (settings.password ?: "") + "&cmnd=" + URLEncoder.encode(command, "UTF-8").replaceAll(/\+/,'%20') ] log.debug options def hubAction = new hubitat.device.HubAction(options, null) //Alterei sendHubCommand(hubAction) } def getVENDOR() { return (settings.ACvendor ?: "SAMSUNG_AC") } def getFANMODE() { return (device.currentValue("thermostatFanMode") == "turbo" ? "max" : device.currentValue("thermostatFanMode")) }