You are missing a var in your definition of TargetMax and TargetMin.
Also, you should use Number instead of DecimalType to avoid the “ambiguous function call” error when you sendCommand later.
var TargetMax = thermostat_TargetTemperatureMax.state as Number
Not an error, but one thing that will make it easier for users on this forum to help will be to use the standard naming conventions. It isn’t really complicated:
- Items start with a capital letter and use “_” and/or camel case (e.g FirstSecond)
- vars start with a lower case and use camel case (e.g. firstSecond)
- vals use all caps and “_” (e.g. FIRST_SECOND)
It’s a little thing, but when you follow the common convention, it is really easy for us to read and understand immediately what is an Item and what is a variable. Above I had to jump all over the place to figure out what was what.
Also, instead of using quotes, use How to use code fences.
The code above was simple enough but it is a lot easier to read when all the indentation and line spacing is preserved.
Let me know if that fixes it. If not, please do post the exact errors you are receiving with the exact code you are posting. It may not tell you anything but it tells us a ton.