Code part 2:
Copy in below code part 1
private parseweatherResponse(resp,childDevice) {
log.debug("Executing parseweatherResponse: "+resp.data)
log.debug("Output status: "+resp.status)
def temperatureUnit = state.tempunit
log.debug("Temperature Unit is ${temperatureUnit}")
if(resp.status == 200) {
log.debug("Executing parseResponse.successTrue")
def outsidetemperature
if (temperatureUnit == "C") {
outsidetemperature = resp.data.outsideTemperature.celsius
}
else if(temperatureUnit == "F"){
outsidetemperature = resp.data.outsideTemperature.fahrenheit
}
log.debug("Read outside temperature: " + outsidetemperature)
childDevice?.sendEvent(name: 'outsidetemperature', value: outsidetemperature, unit: temperatureUnit)
log.debug("Send Outside Temperature Event Fired")
return result
}else if(resp.status == 201){
log.debug("Something was created/updated")
}
}
def getidCommand(){
log.debug "Executing 'sendCommand.getidCommand'"
sendCommand("getid",null,[])
}
def getTempUnitCommand(){
log.debug "Executing 'sendCommand.getidCommand'"
sendCommand("gettempunit",null,[])
}
def getZonesCommand(){
log.debug "Executing 'sendCommand.getzones'"
sendCommand("getzones",null,[])
}
def getMobileDevicesCommand(){
log.debug "Executing 'sendCommand.getMobileDevices'"
sendCommand("getMobileDevices",null,[])
}
def weatherStatusCommand(childDevice){
def item = (childDevice.device.deviceNetworkId).tokenize('|')
def deviceId = item[0]
def deviceType = item[1]
def deviceToken = item[2]
log.debug "Executing 'sendCommand.weatherStatusCommand'"
def result = sendCommand("weatherStatus",childDevice,[deviceId])
}
def getCapabilitiesCommand(childDevice, deviceDNI){
log.debug("childDevice is: " + childDevice.inspect())
log.debug("deviceDNI is: " + deviceDNI.inspect())
def item = deviceDNI.tokenize('|')
def deviceId = item[0]
def deviceType = item[1]
def deviceToken = item[2]
log.debug "Executing 'sendCommand.getcapabilities'"
sendCommand("getcapabilities",childDevice,[deviceId])
}
private removeChildDevices(delete) {
try {
delete.each {
deleteChildDevice(it.deviceNetworkId)
log.info "Successfully Removed Child Device: ${it.displayName} (${it.deviceNetworkId})"
}
}
catch (e) { log.error "There was an error (${e}) when trying to delete the child device" }
}
def parseCapabilityData(Map results){
log.debug "in parseCapabilityData"
def result
results.each { name, value ->
if (name == "value")
{
log.debug "Map Name Returned, ${name} and Value is ${value}"
result = value.toString()
log.debug "Result is ${result}"
//return result
}
}
return result
}
// -------------------------------------------------------------------------------------------------------------------------------------------------------------------------
//Device Commands Below Here
// -------------------------------------------------------------------------------------------------------------------------------------------------------------------------
def autoCommand(childDevice){
log.debug "Executing 'sendCommand.autoCommand' on device ${childDevice.device.name}"
def terminationmode = settings.manualmode
def traperror
def item = (childDevice.device.deviceNetworkId).tokenize('|')
def deviceId = item[0]
def deviceType = item[1]
def deviceToken = item[2]
if (deviceType == "AIR_CONDITIONING")
{
def capabilitySupportsAuto = parseCapabilityData(childDevice.getCapabilitySupportsAuto())
def capabilitySupportsAutoSwing = parseCapabilityData(childDevice.getCapabilitySupportsAutoSwing())
def capabilitysupported = capabilitySupportsAuto
if (capabilitysupported == "true"){
log.debug "Executing 'sendCommand.autoCommand' on device ${childDevice.device.name}"
def jsonbody
if (capabilitySupportsAutoSwing == "true")
{
jsonbody = new groovy.json.JsonOutput().toJson([setting:[mode:"AUTO", power:"ON", swing:"OFF", type:"AIR_CONDITIONING"], termination:[type:terminationmode]])
}
else
{
jsonbody = new groovy.json.JsonOutput().toJson([setting:[mode:"AUTO", power:"ON", type:"AIR_CONDITIONING"], termination:[type:terminationmode]])
}
sendCommand("temperature",dchildDevice,[deviceId,jsonbody])
statusCommand(device)
} else {
log.debug("Sorry Auto Capability not supported on device ${childDevice.device.name}")
}
}
if(deviceType == "HEATING")
{
def initialsetpointtemp
if(childDevice.device.currentValue("thermostatSetpoint"))
{
traperror = ((childDevice.device.currentValue("thermostatSetpoint")).intValue())
}
else
{
log.debug "Existing Setpoint is not set"
traperror = 0
}
if(traperror == 0){
initialsetpointtemp = settings.defHeatingTemp
} else {
initialsetpointtemp = childDevice.device.currentValue("thermostatSetpoint")
}
def jsonbody = new groovy.json.JsonOutput().toJson([setting:[power:"ON", temperature:[celsius:initialsetpointtemp], type:"HEATING"], termination:[type:terminationmode]])
sendCommand("temperature",childDevice,[deviceId,jsonbody])
statusCommand(childDevice)
}
if (deviceType == "HOT_WATER")
{
log.debug "Executing 'sendCommand.autoCommand'"
def initialsetpointtemp
def jsonbody
def capabilitySupportsWaterTempControl = parseCapabilityData(childDevice.getCapabilitySupportsWaterTempControl())
if(capabilitySupportsWaterTempControl == "true"){
if(childDevice.device.currentValue("thermostatSetpoint"))
{
traperror = ((childDevice.device.currentValue("thermostatSetpoint")).intValue())
}
else
{
log.debug "Existing Setpoint is not set"
traperror = 0
}
if(traperror == 0){
initialsetpointtemp = settings.defHeatingTemp
} else {
initialsetpointtemp = childDevice.device.currentValue("thermostatSetpoint")
}
jsonbody = new groovy.json.JsonOutput().toJson([setting:[power:"ON", temperature:[celsius:initialsetpointtemp], type:"HOT_WATER"], termination:[type:terminationmode]])
} else {
jsonbody = new groovy.json.JsonOutput().toJson([setting:[power:"ON", type:"HOT_WATER"], termination:[type:terminationmode]])
}
sendCommand("temperature",childDevice,[deviceId,jsonbody])
statusCommand(childDevice)
}
}
def dryCommand(childDevice){
def item = (childDevice.device.deviceNetworkId).tokenize('|')
def deviceId = item[0]
def deviceType = item[1]
def deviceToken = item[2]
def capabilitySupportsDry = parseCapabilityData(childDevice.getCapabilitySupportsDry())
def capabilitySupportsDrySwing = parseCapabilityData(childDevice.getCapabilitySupportsDrySwing())
def capabilitysupported = capabilitySupportsDry
if (capabilitysupported == "true"){
def terminationmode = settings.manualmode
log.debug "Executing 'sendCommand.dryCommand' on device ${childDevice.device.name}"
def jsonbody
if (capabilitySupportsDrySwing == "true")
{
jsonbody = new groovy.json.JsonOutput().toJson([setting:[mode:"DRY", power:"ON", swing:"OFF", type:"AIR_CONDITIONING"], termination:[type:terminationmode]])
}
else
{
jsonbody = new groovy.json.JsonOutput().toJson([setting:[mode:"DRY", power:"ON", type:"AIR_CONDITIONING"], termination:[type:terminationmode]])
}
sendCommand("temperature",childDevice,[deviceId,jsonbody])
statusCommand(childDevice)
} else {
log.debug("Sorry Dry Capability not supported on device ${childDevice.device.name}")
}
}
def fanAuto(childDevice){
def item = (childDevice.device.deviceNetworkId).tokenize('|')
def deviceId = item[0]
def deviceType = item[1]
def deviceToken = item[2]
def capabilitySupportsFan = parseCapabilityData(childDevice.getCapabilitySupportsFan())
def capabilitySupportsFanSwing = parseCapabilityData(childDevice.getCapabilitySupportsFanSwing())
def capabilitysupported = capabilitySupportsFan
if (capabilitysupported == "true"){
def terminationmode = settings.manualmode
log.debug "Executing 'sendCommand.fanAutoCommand' on device ${childDevice.device.name}"
def jsonbody
if (capabilitySupportsFanSwing == "true")
{
jsonbody = new groovy.json.JsonOutput().toJson([setting:[mode:"FAN", power:"ON", swing:"OFF", type:"AIR_CONDITIONING"], termination:[type:terminationmode]])
}
else
{
jsonbody = new groovy.json.JsonOutput().toJson([setting:[mode:"FAN", power:"ON", type:"AIR_CONDITIONING"], termination:[type:terminationmode]])
}
sendCommand("temperature",childDevice,[deviceId,jsonbody])
statusCommand(childDevice)
} else {
log.debug("Sorry Fan Capability not supported by your HVAC Device")
}
}
def endManualControl(childDevice){
log.debug "Executing 'sendCommand.endManualControl' on device ${childDevice.device.name}"
def item = (childDevice.device.deviceNetworkId).tokenize('|')
def deviceId = item[0]
def deviceType = item[1]
def deviceToken = item[2]
sendCommand("deleteEntry",childDevice,[deviceId])
statusCommand(childDevice)
}
def cmdFanSpeedAuto(childDevice){
def supportedfanspeed
def terminationmode = settings.manualmode
def item = (childDevice.device.deviceNetworkId).tokenize('|')
def deviceId = item[0]
def deviceType = item[1]
def deviceToken = item[2]
def jsonbody
def capabilitySupportsCool = parseCapabilityData(childDevice.getCapabilitySupportsCool())
def capabilitysupported = capabilitySupportsCool
def capabilitySupportsCoolAutoFanSpeed = parseCapabilityData(childDevice.getCapabilitySupportsCoolAutoFanSpeed())
def fancapabilitysupported = capabilitySupportsCoolAutoFanSpeed
if (fancapabilitysupported == "true"){
supportedfanspeed = "AUTO"
} else {
supportedfanspeed = "HIGH"
}
def curSetTemp = (childDevice.device.currentValue("thermostatSetpoint"))
def curMode = ((childDevice.device.currentValue("thermostatMode")).toUpperCase())
if (curMode == "COOL" || curMode == "HEAT"){
if (capabilitySupportsCoolSwing == "true" || capabilitySupportsHeatSwing == "true")
{
if (state.tempunit == "C") {
jsonbody = new groovy.json.JsonOutput().toJson([setting:[fanSpeed:supportedfanspeed, mode:curMode, power:"ON", swing:"OFF", temperature:[celsius:curSetTemp], type:"AIR_CONDITIONING"], termination:[type:terminationmode]])
}
else if(state.tempunit == "F"){
jsonbody = new groovy.json.JsonOutput().toJson([setting:[fanSpeed:supportedfanspeed, mode:curMode, power:"ON", swing:"OFF", temperature:[fahrenheit:curSetTemp], type:"AIR_CONDITIONING"], termination:[type:terminationmode]])
}
}
else
{
if (state.tempunit == "C") {
jsonbody = new groovy.json.JsonOutput().toJson([setting:[fanSpeed:supportedfanspeed, mode:curMode, power:"ON", temperature:[celsius:curSetTemp], type:"AIR_CONDITIONING"], termination:[type:terminationmode]])
}
else if(state.tempunit == "F"){
jsonbody = new groovy.json.JsonOutput().toJson([setting:[fanSpeed:supportedfanspeed, mode:curMode, power:"ON", temperature:[fahrenheit:curSetTemp], type:"AIR_CONDITIONING"], termination:[type:terminationmode]])
}
}
log.debug "Executing 'sendCommand.fanSpeedAuto' to ${supportedfanspeed}"
sendCommand("temperature",childDevice,[deviceId,jsonbody])
statusCommand(childDevice)
}
}
def cmdFanSpeedHigh(childDevice){
def item = (childDevice.device.deviceNetworkId).tokenize('|')
def deviceId = item[0]
def deviceType = item[1]
def deviceToken = item[2]
def jsonbody
def supportedfanspeed = "HIGH"
def terminationmode = settings.manualmode
def curSetTemp = (childDevice.device.currentValue("thermostatSetpoint"))
def curMode = ((childDevice.device.currentValue("thermostatMode")).toUpperCase())
if (curMode == "COOL" || curMode == "HEAT"){
if (capabilitySupportsCoolSwing == "true" || capabilitySupportsHeatSwing == "true")
{
if (state.tempunit == "C") {
jsonbody = new groovy.json.JsonOutput().toJson([setting:[fanSpeed:supportedfanspeed, mode:curMode, power:"ON", swing:"OFF", temperature:[celsius:curSetTemp], type:"AIR_CONDITIONING"], termination:[type:terminationmode]])
}
else if(state.tempunit == "F"){
jsonbody = new groovy.json.JsonOutput().toJson([setting:[fanSpeed:supportedfanspeed, mode:curMode, power:"ON", swing:"OFF", temperature:[fahrenheit:curSetTemp], type:"AIR_CONDITIONING"], termination:[type:terminationmode]])
}
}
else
{
if (state.tempunit == "C") {
jsonbody = new groovy.json.JsonOutput().toJson([setting:[fanSpeed:supportedfanspeed, mode:curMode, power:"ON", temperature:[celsius:curSetTemp], type:"AIR_CONDITIONING"], termination:[type:terminationmode]])
}
else if(state.tempunit == "F"){
jsonbody = new groovy.json.JsonOutput().toJson([setting:[fanSpeed:supportedfanspeed, mode:curMode, power:"ON", temperature:[fahrenheit:curSetTemp], type:"AIR_CONDITIONING"], termination:[type:terminationmode]])
}
}
log.debug "Executing 'sendCommand.fanSpeedAuto' to ${supportedfanspeed}"
sendCommand("temperature",childDevice,[deviceId,jsonbody])
statusCommand(childDevice)
}
}
def cmdFanSpeedMid(childDevice){
def item = (childDevice.device.deviceNetworkId).tokenize('|')
def deviceId = item[0]
def deviceType = item[1]
def deviceToken = item[2]
def supportedfanspeed = "MIDDLE"
def terminationmode = settings.manualmode
def jsonbody
def curSetTemp = (childDevice.device.currentValue("thermostatSetpoint"))
def curMode = ((childDevice.device.currentValue("thermostatMode")).toUpperCase())
if (curMode == "COOL" || curMode == "HEAT"){
if (capabilitySupportsCoolSwing == "true" || capabilitySupportsHeatSwing == "true")
{
if (state.tempunit == "C") {
jsonbody = new groovy.json.JsonOutput().toJson([setting:[fanSpeed:supportedfanspeed, mode:curMode, power:"ON", swing:"OFF", temperature:[celsius:curSetTemp], type:"AIR_CONDITIONING"], termination:[type:terminationmode]])
}
else if(state.tempunit == "F"){
jsonbody = new groovy.json.JsonOutput().toJson([setting:[fanSpeed:supportedfanspeed, mode:curMode, power:"ON", swing:"OFF", temperature:[fahrenheit:curSetTemp], type:"AIR_CONDITIONING"], termination:[type:terminationmode]])
}
}
else
{
if (state.tempunit == "C") {
jsonbody = new groovy.json.JsonOutput().toJson([setting:[fanSpeed:supportedfanspeed, mode:curMode, power:"ON", temperature:[celsius:curSetTemp], type:"AIR_CONDITIONING"], termination:[type:terminationmode]])
}
else if(state.tempunit == "F"){
jsonbody = new groovy.json.JsonOutput().toJson([setting:[fanSpeed:supportedfanspeed, mode:curMode, power:"ON", temperature:[fahrenheit:curSetTemp], type:"AIR_CONDITIONING"], termination:[type:terminationmode]])
}
}
log.debug "Executing 'sendCommand.fanSpeedMid' to ${supportedfanspeed}"
sendCommand("temperature",childDevice,[deviceId,jsonbody])
statusCommand(childDevice)
}
}
def cmdFanSpeedLow(childDevice){
def item = (childDevice.device.deviceNetworkId).tokenize('|')
def deviceId = item[0]
def deviceType = item[1]
def deviceToken = item[2]
def capabilitySupportsCoolSwing = parseCapabilityData(childDevice.getCapabilitySupportsCoolSwing())
def capabilitySupportsHeatSwing = parseCapabilityData(childDevice.getCapabilitySupportsHeatSwing())
def supportedfanspeed = "LOW"
def terminationmode = settings.manualmode
def jsonbody
def curSetTemp = (childDevice.device.currentValue("thermostatSetpoint"))
def curMode = ((childDevice.device.currentValue("thermostatMode")).toUpperCase())
if (curMode == "COOL" || curMode == "HEAT"){
if (capabilitySupportsCoolSwing == "true" || capabilitySupportsHeatSwing == "true")
{
if (state.tempunit == "C") {
jsonbody = new groovy.json.JsonOutput().toJson([setting:[fanSpeed:supportedfanspeed, mode:curMode, power:"ON", swing:"OFF", temperature:[celsius:curSetTemp], type:"AIR_CONDITIONING"], termination:[type:terminationmode]])
}
else if(state.tempunit == "F"){
jsonbody = new groovy.json.JsonOutput().toJson([setting:[fanSpeed:supportedfanspeed, mode:curMode, power:"ON", swing:"OFF", temperature:[fahrenheit:curSetTemp], type:"AIR_CONDITIONING"], termination:[type:terminationmode]])
}
}
else
{
if (state.tempunit == "C") {
jsonbody = new groovy.json.JsonOutput().toJson([setting:[fanSpeed:supportedfanspeed, mode:curMode, power:"ON", temperature:[celsius:curSetTemp], type:"AIR_CONDITIONING"], termination:[type:terminationmode]])
}
else if(state.tempunit == "F"){
jsonbody = new groovy.json.JsonOutput().toJson([setting:[fanSpeed:supportedfanspeed, mode:curMode, power:"ON", temperature:[fahrenheit:curSetTemp], type:"AIR_CONDITIONING"], termination:[type:terminationmode]])
}
}
log.debug "Executing 'sendCommand.fanSpeedLow' to ${supportedfanspeed}"
sendCommand("temperature",childDevice,[deviceId,jsonbody])
statusCommand(childDevice)
}
}
def setCoolingTempCommand(childDevice,targetTemperature){
def terminationmode = settings.manualmode
def item = (childDevice.device.deviceNetworkId).tokenize('|')
def deviceId = item[0]
def deviceType = item[1]
def deviceToken = item[2]
def supportedfanspeed
def capabilitySupportsCool = parseCapabilityData(childDevice.getCapabilitySupportsCool())
def capabilitySupportsCoolSwing = parseCapabilityData(childDevice.getCapabilitySupportsCoolSwing())
def capabilitysupported = capabilitySupportsCool
def capabilitySupportsCoolFanSpeed = parseCapabilityData(childDevice.getCapabilitySupportsCoolFanSpeed())
def capabilitySupportsCoolAutoFanSpeed = parseCapabilityData(childDevice.getCapabilitySupportsCoolAutoFanSpeed())
def fancapabilitysupported = capabilitySupportsCoolAutoFanSpeed
def jsonbody
if (fancapabilitysupported == "true"){
supportedfanspeed = "AUTO"
} else {
supportedfanspeed = "HIGH"
}
if (capabilitySupportsCoolSwing == "true" && capabilitySupportsCoolFanSpeed == "true")
{
if (state.tempunit == "C") {
jsonbody = new groovy.json.JsonOutput().toJson([setting:[fanSpeed:supportedfanspeed, mode:"COOL", power:"ON", swing:"OFF", temperature:[celsius:targetTemperature], type:"AIR_CONDITIONING"], termination:[type:terminationmode]])
}
else if(state.tempunit == "F"){
jsonbody = new groovy.json.JsonOutput().toJson([setting:[fanSpeed:supportedfanspeed, mode:"COOL", power:"ON", swing:"OFF", temperature:[fahrenheit:targetTemperature], type:"AIR_CONDITIONING"], termination:[type:terminationmode]])
}
}
else if(capabilitySupportsCoolSwing == "true" && capabilitySupportsCoolFanSpeed == "false"){
if (state.tempunit == "C") {
jsonbody = new groovy.json.JsonOutput().toJson([setting:[mode:"COOL", power:"ON", swing:"OFF", temperature:[celsius:targetTemperature], type:"AIR_CONDITIONING"], termination:[type:terminationmode]])
}
else if(state.tempunit == "F"){
jsonbody = new groovy.json.JsonOutput().toJson([setting:[mode:"COOL", power:"ON", swing:"OFF", temperature:[fahrenheit:targetTemperature], type:"AIR_CONDITIONING"], termination:[type:terminationmode]])
}
}
else if(capabilitySupportsCoolSwing == "false" && capabilitySupportsCoolFanSpeed == "false"){
if (state.tempunit == "C") {
jsonbody = new groovy.json.JsonOutput().toJson([setting:[mode:"COOL", power:"ON", temperature:[celsius:targetTemperature], type:"AIR_CONDITIONING"], termination:[type:terminationmode]])
}
else if(state.tempunit == "F"){
jsonbody = new groovy.json.JsonOutput().toJson([setting:[mode:"COOL", power:"ON", temperature:[fahrenheit:targetTemperature], type:"AIR_CONDITIONING"], termination:[type:terminationmode]])
}
}
else
{
if (state.tempunit == "C") {
jsonbody = new groovy.json.JsonOutput().toJson([setting:[fanSpeed:supportedfanspeed, mode:"COOL", power:"ON", temperature:[celsius:targetTemperature], type:"AIR_CONDITIONING"], termination:[type:terminationmode]])
}
else if(state.tempunit == "F"){
jsonbody = new groovy.json.JsonOutput().toJson([setting:[fanSpeed:supportedfanspeed, mode:"COOL", power:"ON", temperature:[fahrenheit:targetTemperature], type:"AIR_CONDITIONING"], termination:[type:terminationmode]])
}
}
log.debug "Executing 'sendCommand.setCoolingTempCommand' to ${targetTemperature} on device ${childDevice.device.name}"
sendCommand("temperature",childDevice,[deviceId,jsonbody])
}
def setHeatingTempCommand(childDevice,targetTemperature){
def terminationmode = settings.manualmode
def item = (childDevice.device.deviceNetworkId).tokenize('|')
def deviceId = item[0]
def deviceType = item[1]
def deviceToken = item[2]
if(deviceType == "AIR_CONDITIONING")
{
def capabilitySupportsHeat = parseCapabilityData(childDevice.getCapabilitySupportsHeat())
def capabilitysupported = capabilitySupportsHeat
def capabilitySupportsHeatSwing = parseCapabilityData(childDevice.getCapabilitySupportsHeatSwing())
def capabilitySupportsHeatAutoFanSpeed = parseCapabilityData(childDevice.getCapabilitySupportsHeatAutoFanSpeed())
def capabilitySupportsHeatFanSpeed = parseCapabilityData(childDevice.getCapabilitySupportsHeatFanSpeed())
def fancapabilitysupported = capabilitySupportsHeatAutoFanSpeed
def supportedfanspeed
def jsonbody
if (fancapabilitysupported == "true")
{
supportedfanspeed = "AUTO"
}
else
{
supportedfanspeed = "HIGH"
}
if (capabilitySupportsHeatSwing == "true" && capabilitySupportsHeatFanSpeed == "true")
{
if (state.tempunit == "C") {
jsonbody = new groovy.json.JsonOutput().toJson([setting:[fanSpeed:supportedfanspeed, mode:"HEAT", power:"ON", swing:"OFF", temperature:[celsius:targetTemperature], type:"AIR_CONDITIONING"], termination:[type:terminationmode]])
}
else if(state.tempunit == "F"){
jsonbody = new groovy.json.JsonOutput().toJson([setting:[fanSpeed:supportedfanspeed, mode:"HEAT", power:"ON", swing:"OFF", temperature:[fahrenheit:targetTemperature], type:"AIR_CONDITIONING"], termination:[type:terminationmode]])
}
}
else if(capabilitySupportsHeatSwing == "true" && capabilitySupportsHeatFanSpeed == "false"){
if (state.tempunit == "C") {
jsonbody = new groovy.json.JsonOutput().toJson([setting:[mode:"HEAT", power:"ON", swing:"OFF", temperature:[celsius:targetTemperature], type:"AIR_CONDITIONING"], termination:[type:terminationmode]])
}
else if(state.tempunit == "F"){
jsonbody = new groovy.json.JsonOutput().toJson([setting:[mode:"HEAT", power:"ON", swing:"OFF", temperature:[fahrenheit:targetTemperature], type:"AIR_CONDITIONING"], termination:[type:terminationmode]])
}
}
else if(capabilitySupportsHeatSwing == "false" && capabilitySupportsHeatFanSpeed == "false"){
if (state.tempunit == "C") {
jsonbody = new groovy.json.JsonOutput().toJson([setting:[mode:"HEAT", power:"ON", temperature:[celsius:targetTemperature], type:"AIR_CONDITIONING"], termination:[type:terminationmode]])
}
else if(state.tempunit == "F"){
jsonbody = new groovy.json.JsonOutput().toJson([setting:[mode:"HEAT", power:"ON", temperature:[fahrenheit:targetTemperature], type:"AIR_CONDITIONING"], termination:[type:terminationmode]])
}
}
else
{
if (state.tempunit == "C") {
jsonbody = new groovy.json.JsonOutput().toJson([setting:[fanSpeed:supportedfanspeed, mode:"HEAT", power:"ON", temperature:[celsius:targetTemperature], type:"AIR_CONDITIONING"], termination:[type:terminationmode]])
}
else if(state.tempunit == "F"){
jsonbody = new groovy.json.JsonOutput().toJson([setting:[fanSpeed:supportedfanspeed, mode:"HEAT", power:"ON", temperature:[fahrenheit:targetTemperature], type:"AIR_CONDITIONING"], termination:[type:terminationmode]])
}
}
log.debug "Executing 'sendCommand.setHeatingTempCommand' to ${targetTemperature} on device ${childDevice.device.name}"
sendCommand("temperature",childDevice,[deviceId,jsonbody])
}
if(deviceType == "HEATING")
{
def jsonbody
if (state.tempunit == "C") {
jsonbody = new groovy.json.JsonOutput().toJson([setting:[power:"ON", temperature:[celsius:targetTemperature], type:"HEATING"], termination:[type:terminationmode]])
}
else if(state.tempunit == "F"){
jsonbody = new groovy.json.JsonOutput().toJson([setting:[power:"ON", temperature:[fahrenheit:targetTemperature], type:"HEATING"], termination:[type:terminationmode]])
}
log.debug "Executing 'sendCommand.setHeatingTempCommand' to ${targetTemperature} on device ${childDevice.device.name}"
sendCommand("temperature",childDevice,[deviceId,jsonbody])
}
if(deviceType == "HOT_WATER")
{
def jsonbody
def capabilitySupportsWaterTempControl = parseCapabilityData(childDevice.getCapabilitySupportsWaterTempControl())
if(capabilitySupportsWaterTempControl == "true"){
if (state.tempunit == "C") {
jsonbody = new groovy.json.JsonOutput().toJson([setting:[power:"ON", temperature:[celsius:targetTemperature], type:"HOT_WATER"], termination:[type:terminationmode]])
}
else if(state.tempunit == "F"){
jsonbody = new groovy.json.JsonOutput().toJson([setting:[power:"ON", temperature:[fahrenheit:targetTemperature], type:"HOT_WATER"], termination:[type:terminationmode]])
}
log.debug "Executing 'sendCommand.setHeatingTempCommand' to ${targetTemperature} on device ${childDevice.device.name}"
sendCommand("temperature",[jsonbody])
} else {
log.debug "Hot Water Temperature Capability Not Supported on device ${childDevice.device.name}"
}
}
}
def offCommand(childDevice){
log.debug "Executing 'sendCommand.offCommand' on device ${childDevice.device.name}"
def terminationmode = settings.manualmode
def item = (childDevice.device.deviceNetworkId).tokenize('|')
def deviceId = item[0]
def deviceType = item[1]
def deviceToken = item[2]
def jsonbody = new groovy.json.JsonOutput().toJson([setting:[type:deviceType, power:"OFF"], termination:[type:terminationmode]])
sendCommand("temperature",childDevice,[deviceId,jsonbody])
}
def onCommand(childDevice){
log.debug "Executing 'sendCommand.onCommand'"
def item = (childDevice.device.deviceNetworkId).tokenize('|')
def deviceId = item[0]
def deviceType = item[1]
def deviceToken = item[2]
if(deviceType == "AIR_CONDITIONING")
{
coolCommand(childDevice)
}
if(deviceType == "HEATING" || deviceType == "HOT_WATER")
{
heatCommand(childDevice)
}
}
def coolCommand(childDevice){
log.debug "Executing 'sendCommand.coolCommand'"
def terminationmode = settings.manualmode
def item = (childDevice.device.deviceNetworkId).tokenize('|')
def deviceId = item[0]
def deviceType = item[1]
def deviceToken = item[2]
def initialsetpointtemp
def supportedfanspeed
def capabilitySupportsCool = parseCapabilityData(childDevice.getCapabilitySupportsCool())
def capabilitySupportsCoolSwing = parseCapabilityData(childDevice.getCapabilitySupportsCoolSwing())
def capabilitysupported = capabilitySupportsCool
def capabilitySupportsCoolAutoFanSpeed = parseCapabilityData(childDevice.getCapabilitySupportsCoolAutoFanSpeed())
def capabilitySupportsCoolFanSpeed = parseCapabilityData(childDevice.getCapabilitySupportsCoolFanSpeed())
def fancapabilitysupported = capabilitySupportsCoolAutoFanSpeed
def traperror
if(childDevice.device.currentValue("thermostatSetpoint"))
{
traperror = ((childDevice.device.currentValue("thermostatSetpoint")).intValue())
}
else
{
log.debug "Existing Setpoint is not set"
traperror = 0
}
if (fancapabilitysupported == "true"){
supportedfanspeed = "AUTO"
} else {
supportedfanspeed = "HIGH"
}
if(traperror == 0){
initialsetpointtemp = settings.defCoolingTemp
} else {
initialsetpointtemp = childDevice.device.currentValue("thermostatSetpoint")
}
def jsonbody
if (capabilitySupportsCoolSwing == "true" && capabilitySupportsCoolFanSpeed == "true")
{
if (state.tempunit == "C") {
jsonbody = new groovy.json.JsonOutput().toJson([setting:[fanSpeed:supportedfanspeed, mode:"COOL", power:"ON", swing:"OFF", temperature:[celsius:initialsetpointtemp], type:"AIR_CONDITIONING"], termination:[type:terminationmode]])
}
else if (state.tempunit == "F"){
jsonbody = new groovy.json.JsonOutput().toJson([setting:[fanSpeed:supportedfanspeed, mode:"COOL", power:"ON", swing:"OFF", temperature:[fahrenheit:initialsetpointtemp], type:"AIR_CONDITIONING"], termination:[type:terminationmode]])
}
}
else if(capabilitySupportsCoolSwing == "true" && capabilitySupportsCoolFanSpeed == "false"){
if (state.tempunit == "C") {
jsonbody = new groovy.json.JsonOutput().toJson([setting:[mode:"COOL", power:"ON", swing:"OFF", temperature:[celsius:initialsetpointtemp], type:"AIR_CONDITIONING"], termination:[type:terminationmode]])
}
else if(state.tempunit == "F"){
jsonbody = new groovy.json.JsonOutput().toJson([setting:[mode:"COOL", power:"ON", swing:"OFF", temperature:[fahrenheit:initialsetpointtemp], type:"AIR_CONDITIONING"], termination:[type:terminationmode]])
}
}
else if(capabilitySupportsCoolSwing == "false" && capabilitySupportsCoolFanSpeed == "false"){
if (state.tempunit == "C") {
jsonbody = new groovy.json.JsonOutput().toJson([setting:[mode:"COOL", power:"ON", temperature:[celsius:initialsetpointtemp], type:"AIR_CONDITIONING"], termination:[type:terminationmode]])
}
else if(state.tempunit == "F"){
jsonbody = new groovy.json.JsonOutput().toJson([setting:[mode:"COOL", power:"ON", temperature:[fahrenheit:initialsetpointtemp], type:"AIR_CONDITIONING"], termination:[type:terminationmode]])
}
}
else
{
if (state.tempunit == "C") {
jsonbody = new groovy.json.JsonOutput().toJson([setting:[fanSpeed:supportedfanspeed, mode:"COOL", power:"ON", temperature:[celsius:initialsetpointtemp], type:"AIR_CONDITIONING"], termination:[type:terminationmode]])
}
else if (state.tempunit == "F"){
jsonbody = new groovy.json.JsonOutput().toJson([setting:[fanSpeed:supportedfanspeed, mode:"COOL", power:"ON", temperature:[fahrenheit:initialsetpointtemp], type:"AIR_CONDITIONING"], termination:[type:terminationmode]])
}
}
sendCommand("temperature",childDevice,[deviceId,jsonbody])
}
def heatCommand(childDevice){
log.debug "Executing 'sendCommand.heatCommand' on device ${childDevice.device.name}"
def terminationmode = settings.manualmode
def item = (childDevice.device.deviceNetworkId).tokenize('|')
def deviceId = item[0]
def deviceType = item[1]
def deviceToken = item[2]
if(deviceType == "AIR_CONDITIONING")
{
def initialsetpointtemp
def supportedfanspeed
def traperror
def capabilitySupportsHeat = parseCapabilityData(childDevice.getCapabilitySupportsHeat())
def capabilitySupportsHeatSwing = parseCapabilityData(childDevice.getCapabilitySupportsHeatSwing())
def capabilitysupported = capabilitySupportsHeat
def capabilitySupportsHeatAutoFanSpeed = parseCapabilityData(childDevice.getCapabilitySupportsHeatAutoFanSpeed())
def capabilitySupportsHeatFanSpeed = parseCapabilityData(childDevice.getCapabilitySupportsHeatFanSpeed())
def fancapabilitysupported = capabilitySupportsHeatAutoFanSpeed
if(childDevice.device.currentValue("thermostatSetpoint"))
{
traperror = ((childDevice.device.currentValue("thermostatSetpoint")).intValue())
}
else
{
log.debug "Existing Setpoint is not set"
traperror = 0
}
if (fancapabilitysupported == "true")
{
supportedfanspeed = "AUTO"
}
else
{
supportedfanspeed = "HIGH"
}
if(traperror == 0)
{
initialsetpointtemp = settings.defHeatingTemp
}
else
{
initialsetpointtemp = childDevice.device.currentValue("thermostatSetpoint")
}
def jsonbody
if (capabilitySupportsHeatSwing == "true" && capabilitySupportsHeatFanSpeed == "true")
{
if (state.tempunit == "C") {
jsonbody = new groovy.json.JsonOutput().toJson([setting:[fanSpeed:supportedfanspeed, mode:"HEAT", power:"ON", swing:"OFF", temperature:[celsius:initialsetpointtemp], type:"AIR_CONDITIONING"], termination:[type:terminationmode]])
}
else if (state.tempunit == "F"){
jsonbody = new groovy.json.JsonOutput().toJson([setting:[fanSpeed:supportedfanspeed, mode:"HEAT", power:"ON", swing:"OFF", temperature:[fahrenheit:initialsetpointtemp], type:"AIR_CONDITIONING"], termination:[type:terminationmode]])
}
}
else if(capabilitySupportsHeatSwing == "true" && capabilitySupportsHeatFanSpeed == "false"){
if (state.tempunit == "C") {
jsonbody = new groovy.json.JsonOutput().toJson([setting:[mode:"HEAT", power:"ON", swing:"OFF", temperature:[celsius:initialsetpointtemp], type:"AIR_CONDITIONING"], termination:[type:terminationmode]])
}
else if(state.tempunit == "F"){
jsonbody = new groovy.json.JsonOutput().toJson([setting:[mode:"HEAT", power:"ON", swing:"OFF", temperature:[fahrenheit:initialsetpointtemp], type:"AIR_CONDITIONING"], termination:[type:terminationmode]])
}
}
else if(capabilitySupportsHeatSwing == "false" && capabilitySupportsHeatFanSpeed == "false"){
if (state.tempunit == "C") {
jsonbody = new groovy.json.JsonOutput().toJson([setting:[mode:"HEAT", power:"ON", temperature:[celsius:initialsetpointtemp], type:"AIR_CONDITIONING"], termination:[type:terminationmode]])
}
else if(state.tempunit == "F"){
jsonbody = new groovy.json.JsonOutput().toJson([setting:[mode:"HEAT", power:"ON", temperature:[fahrenheit:initialsetpointtemp], type:"AIR_CONDITIONING"], termination:[type:terminationmode]])
}
}
else
{
if (state.tempunit == "C") {
jsonbody = new groovy.json.JsonOutput().toJson([setting:[fanSpeed:supportedfanspeed, mode:"HEAT", power:"ON", temperature:[celsius:initialsetpointtemp], type:"AIR_CONDITIONING"], termination:[type:terminationmode]])
}
else if (state.tempunit == "F"){
jsonbody = new groovy.json.JsonOutput().toJson([setting:[fanSpeed:supportedfanspeed, mode:"HEAT", power:"ON", temperature:[fahrenheit:initialsetpointtemp], type:"AIR_CONDITIONING"], termination:[type:terminationmode]])
}
}
sendCommand("temperature",childDevice,[deviceId,jsonbody])
}
if(deviceType == "HEATING")
{
def initialsetpointtemp
def traperror
if(childDevice.device.currentValue("thermostatSetpoint"))
{
traperror = ((childDevice.device.currentValue("thermostatSetpoint")).intValue())
}
else
{
log.debug "Existing Setpoint is not set"
traperror = 0
}
if(traperror == 0)
{
initialsetpointtemp = settings.defHeatingTemp
}
else
{
initialsetpointtemp = childDevice.device.currentValue("thermostatSetpoint")
}
def jsonbody
if (state.tempunit == "C") {
jsonbody = new groovy.json.JsonOutput().toJson([setting:[power:"ON", temperature:[celsius:initialsetpointtemp], type:"HEATING"], termination:[type:terminationmode]])
}
else if (state.tempunit == "F"){
jsonbody = new groovy.json.JsonOutput().toJson([setting:[power:"ON", temperature:[fahrenheit:initialsetpointtemp], type:"HEATING"], termination:[type:terminationmode]])
}
sendCommand("temperature",childDevice,[deviceId,jsonbody])
}
if(deviceType == "HOT_WATER")
{
def jsonbody
def initialsetpointtemp
def traperror
def capabilitySupportsWaterTempControl = parseCapabilityData(childDevice.getCapabilitySupportsWaterTempControl())
if(capabilitySupportsWaterTempControl == "true"){
if(childDevice.device.currentValue("thermostatSetpoint"))
{
traperror = ((childDevice.device.currentValue("thermostatSetpoint")).intValue())
}
else
{
log.debug "Existing Setpoint is not set"
traperror = 0
}
if(traperror == 0){
initialsetpointtemp = settings.defHeatingTemp
} else {
initialsetpointtemp = childDevice.device.currentValue("thermostatSetpoint")
}
if (state.tempunit == "C") {
jsonbody = new groovy.json.JsonOutput().toJson([setting:[power:"ON", temperature:[celsius:initialsetpointtemp], type:"HOT_WATER"], termination:[type:terminationmode]])
}
else if (state.tempunit == "F"){
jsonbody = new groovy.json.JsonOutput().toJson([setting:[power:"ON", temperature:[fahrenheit:initialsetpointtemp], type:"HOT_WATER"], termination:[type:terminationmode]])
}
} else {
jsonbody = new groovy.json.JsonOutput().toJson([setting:[power:"ON", type:"HOT_WATER"], termination:[type:terminationmode]])
}
sendCommand("temperature",childDevice,[deviceId,jsonbody])
}
}
def emergencyHeat(childDevice){
log.debug "Executing 'sendCommand.heatCommand' on device ${childDevice.device.name}"
def traperror
def item = (childDevice.device.deviceNetworkId).tokenize('|')
def deviceId = item[0]
def deviceType = item[1]
def deviceToken = item[2]
if(deviceType == "AIR_CONDITIONING")
{
def capabilitySupportsHeat = parseCapabilityData(childDevice.getCapabilitySupportsHeat())
def capabilitysupported = capabilitySupportsHeat
def capabilitySupportsHeatSwing = parseCapabilityData(childDevice.getCapabilitySupportsHeatSwing())
def capabilitySupportsHeatAutoFanSpeed = parseCapabilityData(childDevice.getCapabilitySupportsHeatAutoFanSpeed())
def capabilitySupportsHeatFanSpeed = parseCapabilityData(childDevice.getCapabilitySupportsHeatFanSpeed())
def fancapabilitysupported = capabilitySupportsHeatAutoFanSpeed
if(childDevice.device.currentValue("thermostatSetpoint"))
{
traperror = ((childDevice.device.currentValue("thermostatSetpoint")).intValue())
}
else
{
log.debug "Existing Setpoint is not set"
traperror = 0
}
if (capabilitysupported == "true")
{
def initialsetpointtemp
def supportedfanspeed
if (fancapabilitysupported == "true")
{
supportedfanspeed = "AUTO"
}
else
{
supportedfanspeed = "HIGH"
}
if(traperror == 0)
{
initialsetpointtemp = settings.defHeatingTemp
}
else
{
initialsetpointtemp = childDevice.device.currentValue("thermostatSetpoint")
}
def jsonbody
if (capabilitySupportsHeatSwing == "true" && capabilitySupportsHeatFanSpeed == "true")
{
if (state.tempunit == "C") {
jsonbody = new groovy.json.JsonOutput().toJson([setting:[fanSpeed:supportedfanspeed, mode:"HEAT", power:"ON", swing:"OFF", temperature:[celsius:initialsetpointtemp], type:"AIR_CONDITIONING"], termination:[durationInSeconds:"3600", type:"TIMER"]])
}
else if (state.tempunit == "F"){
jsonbody = new groovy.json.JsonOutput().toJson([setting:[fanSpeed:supportedfanspeed, mode:"HEAT", power:"ON", swing:"OFF", temperature:[fahrenheit:initialsetpointtemp], type:"AIR_CONDITIONING"], termination:[durationInSeconds:"3600", type:"TIMER"]])
}
}
else if(capabilitySupportsHeatSwing == "true" && capabilitySupportsHeatFanSpeed == "false"){
if (state.tempunit == "C") {
jsonbody = new groovy.json.JsonOutput().toJson([setting:[mode:"HEAT", power:"ON", swing:"OFF", temperature:[celsius:initialsetpointtemp], type:"AIR_CONDITIONING"], termination:[type:terminationmode]])
}
else if(state.tempunit == "F"){
jsonbody = new groovy.json.JsonOutput().toJson([setting:[mode:"HEAT", power:"ON", swing:"OFF", temperature:[fahrenheit:initialsetpointtemp], type:"AIR_CONDITIONING"], termination:[type:terminationmode]])
}
}
else if(capabilitySupportsHeatSwing == "false" && capabilitySupportsHeatFanSpeed == "false"){
if (state.tempunit == "C") {
jsonbody = new groovy.json.JsonOutput().toJson([setting:[mode:"HEAT", power:"ON", temperature:[celsius:initialsetpointtemp], type:"AIR_CONDITIONING"], termination:[type:terminationmode]])
}
else if(state.tempunit == "F"){
jsonbody = new groovy.json.JsonOutput().toJson([setting:[mode:"HEAT", power:"ON", temperature:[fahrenheit:initialsetpointtemp], type:"AIR_CONDITIONING"], termination:[type:terminationmode]])
}
}
else
{
if (state.tempunit == "C") {
jsonbody = new groovy.json.JsonOutput().toJson([setting:[fanSpeed:supportedfanspeed, mode:"HEAT", power:"ON", temperature:[celsius:initialsetpointtemp], type:"AIR_CONDITIONING"], termination:[durationInSeconds:"3600", type:"TIMER"]])
}
else if (state.tempunit == "F"){
jsonbody = new groovy.json.JsonOutput().toJson([setting:[fanSpeed:supportedfanspeed, mode:"HEAT", power:"ON", temperature:[fahrenheit:initialsetpointtemp], type:"AIR_CONDITIONING"], termination:[durationInSeconds:"3600", type:"TIMER"]])
}
}
sendCommand("temperature",childDevice,[deviceId,jsonbody])
statusCommand(device)
}
else
{
log.debug("Sorry Heat Capability not supported on device ${childDevice.device.name}")
}
}
if(deviceType == "HEATING")
{
def initialsetpointtemp
if(childDevice.device.currentValue("thermostatSetpoint"))
{
traperror = ((childDevice.device.currentValue("thermostatSetpoint")).intValue())
}
else
{
log.debug "Existing Setpoint is not set"
traperror = 0
}
if(traperror == 0)
{
initialsetpointtemp = settings.defHeatingTemp
}
else
{
initialsetpointtemp = childDevice.device.currentValue("thermostatSetpoint")
}
def jsonbody
if (state.tempunit == "C") {
jsonbody = new groovy.json.JsonOutput().toJson([setting:[power:"ON", temperature:[celsius:initialsetpointtemp], type:"HEATING"], termination:[durationInSeconds:"3600", type:"TIMER"]])
}
else if (state.tempunit == "F"){
jsonbody = new groovy.json.JsonOutput().toJson([setting:[power:"ON", temperature:[fahrenheit:initialsetpointtemp], type:"HEATING"], termination:[durationInSeconds:"3600", type:"TIMER"]])
}
sendCommand("temperature",childDevice,[deviceId,jsonbody])
statusCommand(childDevice)
}
(deviceType == "HOT_WATER")
{
def initialsetpointtemp
def jsonbody
def capabilitySupportsWaterTempControl = parseCapabilityData(childDevice.getCapabilitySupportsWaterTempControl())
if(capabilitySupportsWaterTempControl == "true"){
if(childDevice.device.currentValue("thermostatSetpoint"))
{
traperror = ((childDevice.device.currentValue("thermostatSetpoint")).intValue())
}
else
{
log.debug "Existing Setpoint is not set"
traperror = 0
}
if(traperror == 0)
{
initialsetpointtemp = settings.defHeatingTemp
}
else
{
initialsetpointtemp = childDevice.device.currentValue("thermostatSetpoint")
}
if (state.tempunit == "C") {
jsonbody = new groovy.json.JsonOutput().toJson([setting:[power:"ON", temperature:[celsius:initialsetpointtemp], type:"HOT_WATER"], termination:[durationInSeconds:"3600", type:"TIMER"]])
}
else if (state.tempunit == "F"){
jsonbody = new groovy.json.JsonOutput().toJson([setting:[power:"ON", temperature:[fahrenheit:initialsetpointtemp], type:"HOT_WATER"], termination:[durationInSeconds:"3600", type:"TIMER"]])
}
}
else
{
jsonbody = new groovy.json.JsonOutput().toJson([setting:[power:"ON", type:"HOT_WATER"], termination:[durationInSeconds:"3600", type:"TIMER"]])
}
sendCommand("temperature",childDevice,[deviceId,jsonbody])
statusCommand(childDevice)
}
}
def statusCommand(childDevice){
def item = (childDevice.device.deviceNetworkId).tokenize('|')
def deviceId = item[0]
def deviceType = item[1]
def deviceToken = item[2]
log.debug "Executing 'sendCommand.statusCommand'"
sendCommand("status",childDevice,[deviceId])
}
def userStatusCommand(childDevice){
try{
log.debug "Executing 'sendCommand.userStatusCommand'"
sendCommand("userStatus",childDevice,[])
} catch(Exception e) { log.debug("Failed in setting userStatusCommand: " + e)
}
}
// -------------------------------------------------------------------------------------------------------------------------------------------------------------------
// OAuth methods
// -------------------------------------------------------------------------------------------------------------------------------------------------------------------
def oauthAccessTokenGrant() {
log.debug "Executing OAuth 2 Autorization Flow: Request Access Token"
def params = [
uri: getOauthTokenUri(),
path: getOauthTokenPath(),
body: [
client_id: getClientId(),
client_secret: getClientSecret(),
username: settings.username,
password: settings.password,
grant_type: "password"
]
]
try {
log.debug "Parameters for token request:" + " " + params
httpPost(params)
{ resp ->
log.debug "Response data:" + " " + resp.data
log.debug "Respones succes:" + " " + resp.success//
if (resp && resp.data && resp.success) {
log.debug "Access token granted"
state.refreshToken = resp.data.refresh_token
state.authToken = resp.data.access_token
state.authTokenExpires = (now() + (resp.data.expires_in * 1000)) - 60000
log.debug "Token expires:" + " " + state.authTokenExpires
} else { log.error "Failed to retreive access token" }
}
}
catch (e) {
log.error "OAuth error: ${e}"
}
}
def refreshToken() {
def result = false
log.debug "Refreshing OAuth token"
try {
def params = [
uri: getOauthTokenUri(),
path: getOauthTokenPath(),
body: [
client_id: getClientId(),
client_secret: getClientSecret(),
refresh_token: getRefreshToken(),
grant_type: "refresh_token"
] ]
log.debug "Parameters for token refresh:" + " " + params
httpPost(params) { resp ->
log.debug "Response data:" + " " + resp.data
log.debug "Respones succes:" + " " + resp.success
if (resp && resp.data && resp.success) {
log.debug "Token refreshed successfully"
state.refreshToken = resp.data.refresh_token
state.authToken = resp.data.access_token
state.authTokenExpires = now() + (resp.data.expires_in * 1000) - 60000
log.debug "Token expires:" + " " + state.authTokenExpires
result = true
}
else {
log.error "Failed to refresh token"
state.authToken = null
result = false
}
}
}
catch (e) {
log.error "Failed to refresh token: ${e}"
state.authToken = null
result = false
}
return result
}