Adding two variables together

Posted on
Tue May 28, 2019 2:39 pm
mwoodage offline
Posts: 71
Joined: Dec 19, 2014

Adding two variables together

Hello,
I've nearly managed to sort this out myself, but just need some help with the last bit! I'm writing a python script to add two variables together.

I'm trying to take a temperature reading from our hot tub, but the only place i can mount the probe gives a temperature reading that's 3 degrees lower than the actual temperature. So i've written the following which adds both variables together but it doesn't bring across the .68 (or what ever the figure after the decimal point is).

Can anyone help with how to transfer the .68 across?

Code: Select all
hottubtemp = int(float(indigo.variables[394455824].value))
hottubtempset = int(float(indigo.variables[1175215717].value))
hottubtempact = hottubtemp + hottubtempset
indigo.variable.updateValue(1590980300, value=str(float(hottubtempact)))


Thanks in advance
Martin
Attachments
Screenshot 2019-05-28 at 21.30.13.png
Screenshot 2019-05-28 at 21.30.13.png (51.87 KiB) Viewed 170 times

Posted on
Tue May 28, 2019 4:16 pm
racarter offline
User avatar
Posts: 204
Joined: Jun 18, 2016
Location: North Yorkshire, UK

Re: Adding two variables together

Remove the ints. You’re converting the first two numbers to integers, which always rounds down. Since you’ll then be adding two floats you won’t need the float on the last line.

Posted on
Wed May 29, 2019 6:18 am
mwoodage offline
Posts: 71
Joined: Dec 19, 2014

Re: Adding two variables together

racarter wrote:
Remove the ints. You’re converting the first two numbers to integers, which always rounds down. Since you’ll then be adding two floats you won’t need the float on the last line.


That works! Thank you so much, its easy when you know how :lol:

Martin

Posted on
Wed May 29, 2019 6:30 am
racarter offline
User avatar
Posts: 204
Joined: Jun 18, 2016
Location: North Yorkshire, UK

Re: Adding two variables together

Happy to help :)

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 2 guests