Scale a value or convert value from Celcius to Ferenheit

Anyone know of a quick way to rescale a variable or value into something else ? (ex: Degrees Celcius to Ferenheit and back) or anything else.

Temperature requires a formula (Divide by 5, then multiply by 9, then add 32) and the other way around.

Rescale a value (ex: 0-10 rescaled to 0-100) would be different, but linear

Maybe a User App someone as created or RM ?

For temperature there are a few built in methods that make it easier.

  • celsiusToFahrenheit
  • fahrenheitToCelsius
  • getTemperatureScale
  • convertTemperatureIfNeeded (I use this one a lot)

https://docs.hubitat.com/index.php?title=Common_Methods_Object

Rescaling linear values I find much easier with simple formula and adjust it as needed. You could probably make a generic method to handle linear scaling.

1 Like

Thank-you @gavincampbell, I will look into this, so this is all done with Groovy ?