I’ve looked through the topics regarding variables/values and using arithmetic operations and tried many variations based on those posts. I can’t find where I’m failing.
Items:
Group:Switch:OR(ON, OFF) gRegion "Someone In Town"
Switch U1_region "U1 in Town" (gRegion) {mqttitude="openhab_tcpbroker:owntracks/user/u1d/event:R1"}
Switch U2_region "U2 in Town" (gRegion) {mqttitude="openhab_tcpbroker:owntracks/user/u2d/event:R1"}
String Nest_Away "Structure Home/Away [%s]" {nest="=[structures(Home).away]"}
Number thermostat_TargetTemperatureMax "Target Temperature Max [%.1f °F]" {nest="=[thermostats(Home Thermostat).max_set_point]"}
Number thermostat_TargetTemperatureMin "Target Temperature Min [%.1f °F]" {nest="=[thermostats(Home Thermostat).min_set_point]"}
Rule:
rule "Adjust Nest Thermostat Targets"
when
Item gRegion changed
then
TargetMax = thermostat_TargetTemperatureMax.state as DecimalType
TargetMin = thermostat_TargetTemperatureMin.state as DecimalType
if (Nest_Away.state == "HOME")
{
if (gRegion.state == OFF)
{
TargetMax = TargetMax + 5.0
TargetMin = TargetMin - 5.0
}
else
{
TargetMax = TargetMax - 5.0
TargetMin = TargetMin + 5.0
}
thermostat_TargetTemperatureMax.sendCommand(TargetMax)
thermostat_TargetTemperatureMin.sendCommand(TargetMin)
}
end
I am not listing the errors I’ve received because as I’ve tried different syntax variations, I’ve received different errors (can’t assign to void, “minus sign” or “plus sign” is not recognized, etc.). I’m sure the solution will be simple for someone with a modicum of openHAB coding experience, i.e., not me
Basically, when I arrive/depart, I want to adjust the thermostat temperature set points. My Nest is configured for HEAT_COOL mode.
Regards.
Mike