[RELEASE] New Virtual Thermostat With Device

Hello all. I have attempted to modify this for cooling instead of heating, using some of the contributions above, and some of my own(my contributions were mainly just for modifying the GUI, and changing the word heat to cool throughout), but am now having some trouble.
When the desired temperature is set to a value lower than the temperature sensor reading, then the virtual switch turns on as expected. When, however, the desired temperature is set above the current temperature sensor reading, the virtual switch also gets a turn on command.
For some reason, no matter what I do, I cant get the virtual switch to turn off via this smart app. Any help here would be greatly appreciated.

Here’s the smart app fork:

https://github.com/enishoca/SmartThings-VirtualThermostat-WithDTH/pull/1/commits/68961e42290800d834feccd7751fb9d31c4c7fab?file-filters%5B%5D=#diff-6b85cfbc4777d3b542e32b39fecd82ab

And here’s the device handler fork:
https://github.com/dantor19/SmartThings-VirtualThermostat-WithDTH/commit/9fd313aa120bf9a8298f51f5ce61ffab7dbadd3f

2 Likes

I followed your code very quickly as I did not have the time to delve further and I observed something that could point to the issue you described with the turn-off command. See below – rows 193 to 197 in the Smart App fork.

log.debug "Heating in Emergency Mode Now"
outlet.on()  //HERE -- "outlet"
thermostat.setEmergencyMode(true)
} else {
	log.debug "Heating off Now"
	outlets.off() //HERE -- "outletS"

Could it be related to outlet vs outletS (in case the user has specified multiple outlets to be handled) that’s causing the issue? Again, not sure of the code structure and logic, so this is just an observation that could point to the right direction.

Thank you for the effort! I hope I can take your work and modify the code at some point to support both heating and cooling via the GUI (with some sort of selection that would dictate the rest of the code to use the coresponding functions.

Yes! That seemed to do it! It seems like the rest of the program was getting hung up on this error. After changing outlet.on(), to outlets.on(), almost everything seems to work as it should. The only exception is that the emergency temp must be set to some value, otherwise the smart app always commands the outlets on for some reason. I suppose decent workaround for those who don’t wish to use this feature would be to just set the emergency temp to a very high setting. Annoying, but the best I can figure for now…

1 Like

I’m glad this helped solve the issue. Also, which version of the Smartthings app are you using – classic or new? When I’m using the new app, almost all thermostat controls (up/down etc) are not showing when clicking on the virtual thermo device (not automation).

I’m using the classic app. When I open the device/smartapp in the new app, I have the same lack of controls. I’ve been told that the new app isn’t really fully functional yet, and many smartapp/device features simply haven’t been implemented thus far, so this isn’t entirely surprising to me.

On an unrelated note, I’m trying to figure out a way to get a separate group of outlets to be excluded from the logic of this smartapp when a virtual switch is turned off. I’m thinking that the easiest way to do this would be to have two groups of outlets, lets say “outlets” and “excluded_outlets”, and a switch, say “exclude_switch”. I’m thinking I would then just modify the definitions for “coolingOn” and “coolingOff” to each include an if-then statement that references the state of “exclude_switch”. The problem is, that for the life of me, I can’t figure out to implement this into the code, or, for some reason, find any examples of similar implementations with virtual switches.
Also, do I have to modify the device handler as part of this process? Below is the excerpt mentioned above. Below that is a link to the full code.
Any help here would be extremely appreciated.

def coolingOn() {
if(thermostat.currentValue(‘thermostatMode’) == ‘cool’ || force) {
log.debug “Heating on Now”
outlets.on()
log.debug(“Outlets on 1”)
thermostat.setCoolingStatus(true)
} else {
coolingOff(true)
log.debug(“cooling off 6”)
}
}

def coolingOff(coolingOff) {
def thisTemp = getAverageTemperature()
if (thisTemp >= emergencySetpoint) {
log.debug “Heating in Emergency Mode Now”
outlets.on()
log.debug(“Outlets on 2”)
thermostat.setEmergencyMode(true)
} else {
log.debug “Heating off Now”
outlets.off()
log.debug(“outlets off 1”)
if(coolingOff) {
thermostat.setCoolingOff(true)
} else {
thermostat.setCoolingStatus(false)
}
}
}

https://github.com/dantor19/SmartThingsPublic/blob/97ec91463338917f37ee74dcb4c68aa838c254d6/smartapps/piratemedia/smartthings/virtual-thermostat-with-device.src/virtual-thermostat-with-device.groovy

Ive managed to add a motion sensor to this. The heating only works if there has been motion within a present period, i use 10 mins. Not sure if I’ve done it the best way but it works a treat. Thanks for this its excellent

Recently installed this and love it…

I was wondering if anyone can guide me in changing the code to allow me to increase and decrease the target temp in 0.5 degree increments instead of 1.0 please? I’ve already managed to change the threshold to 0.3 in the app, but I would like finer control of the actual target.

I’ve had a look, but I’m struggling.

Recently installed this and love it…

I was wondering if anyone can guide me in changing the code to allow me to increase and decrease the target temp in 0.5 degree increments please?

I’ve had a look, but I’m struggling.

I’ve had a quick look (and I’m knew to Smartthings) but it appears all you need to do is modify the device handler code:

Modify line 27: command “setVirtualTemperature”, [“number”]
To be: command “setVirtualTemperature”, [“string”]

Modify line 243: if(hsp + 1.0 > highRange()) return;
To be: if(hsp + 0.5 > highRange()) return;

Modify line 244: setHeatingSetpoint(hsp + 1.0)
To be: setHeatingSetpoint(hsp + 0.5)

Modify line: 249: if(hsp - 1.0 < lowRange()) return;
To be: if(hsp - 0.5 < lowRange()) return;

Modify line 250: setHeatingSetpoint(hsp - 1.0)
To be: setHeatingSetpoint(hsp - 0.5)

Modify line 255: if(hsp + 1.0 > highRange()) return;
To be: if(hsp + 0.5 > highRange()) return;

Modify line 256: setHeatingSetpoint(hsp + 1.0)
To be: setHeatingSetpoint(hsp + 0.5)

Modify line 261: if(hsp - 1.0 < lowRange()) return;
To be: if(hsp - 0.5 < lowRange()) return;

Modify line 262: setHeatingSetpoint(hsp - 1.0)
To be: setHeatingSetpoint(hsp - 0.5)

Hope this helps :slight_smile:

J.

Hi there,
I just installed the DH and device. Seem great! But…how the hell can i link my ACs and temp sensors to this thermostat? Thanks!

© 2019 SmartThings, Inc. All Rights Reserved. Terms of Use | Privacy Policy

SmartThings; SmartApps®; Physical Graph; Hello, Home; and Hello, Smart Home are all trademarks of the SmartThings, Inc.