How to round Variable values

I’m not getting it… I’m probably staring at the solution and just don’t see it. I also just want the temperature to be rounded to “no decimals”. This is how I get the temperature, but don’t see how to round it in the saved variables.

…and for these 2 devices, is it easier to somehow just make the devices themselves report the rounded temperature in SmartThings?

I don’t know how to add round to what you already have but you can add another action for each variable
https://lab.sharptools.dev/math
{
“formula”: “round($HighTemp)”
}

That would be the right approach to me. With expressions in beta, they could even do it all in one step:

Set $HighTemp = round($context.response.data.daily.0.temp.max)

Edit: Where are you using the device and variable data? Keep in mind that some dashboard tiles like Hero Attribute and Super Tiles can round the displayed data. Otherwise the original feedback above about rounding it within the rule applies if you want the data to be rounded elsewhere.

In this rule, I’m just using data from 2 Z-Wave devices that report adding 2 decimal places that I’d like to drop.

Thanks Terri-
Can you post how you use this?

It was covered further up in the thread.

I’ve added you to the beta and would suggest you use the native expression feature. :smiley:

Just add 2 more http actions (like your first action) using what I posted above to the end or as Josh suggested trying using the beta expression feature.

2 Likes

A post was merged into an existing topic: [BETA] Math / Date Expressions

2 posts were split to a new topic: How to reference context variable with underscore