metadata { definition(name: "Tasmota Switch IR", namespace: "jorgespneto", author: "Jorge Palmeira") { capability "Switch" } } 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: "OnIRsend", title:"On - Código IR", type: "string" input name: "OffIRsend", title:"Off - Código IR", type: "string" 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('IRsend '+ONIR) sendEvent(name: "switch", value: "on") } def off() { sendTasmota('IRsend '+OFFIR) sendEvent(name: "switch", value: "off") } 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 getONIR() { return (settings.OnIRsend ?: "") } def getOFFIR() { return (settings.OffIRsend ?: "") }