Precision of values

Posted on
Sat Jun 11, 2016 12:01 pm
Nine offline
Posts: 78
Joined: Feb 15, 2015
Location: Zurich, Switzerland

Precision of values

If I set the precision of some values in the config to 0:
Bildschirmfoto 2016-06-11 um 19.54.09.png
Bildschirmfoto 2016-06-11 um 19.54.09.png (97.26 KiB) Viewed 1648 times


the WUnderground-Device shows everything correctly:
Bildschirmfoto 2016-06-11 um 19.54.22.png
Bildschirmfoto 2016-06-11 um 19.54.22.png (25.01 KiB) Viewed 1648 times


But if I then write out the value of eg the max temp to a variable, there is a decimal place:
Bildschirmfoto 2016-06-11 um 19.54.31.png
Bildschirmfoto 2016-06-11 um 19.54.31.png (8.38 KiB) Viewed 1648 times


Is that a bug or make I a mistake?

Nine

Posted on
Sat Jun 11, 2016 12:54 pm
DaveL17 offline
User avatar
Posts: 6742
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Precision of values

Is that a bug or make I a mistake?

Neither. Indigo has the capacity to maintain two values for each device state--(1) the actual state value, and (2) one to display in Indigo's UI. When you change the decimal precision value in the plugin, you're affecting only the UI value (the actual value remains unchanged.) This is purposeful behavior.

How are you writing out the value to the variable? If you're using Python, it's an easy fix.
Code: Select all
x = indigo.devices[1258163860].states["foreHigh1"]
y = indigo.devices[1258163860].states["foreHigh1.ui"]

indigo.server.log(unicode(x))
indigo.server.log(unicode(y))


Which yields this:
Code: Select all
Jun 11, 2016, 1:53:22 PM
  Script                          93.0
  Script                          93°

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Sun Jun 12, 2016 3:28 am
Nine offline
Posts: 78
Joined: Feb 15, 2015
Location: Zurich, Switzerland

Re: Precision of values

Thx for your explanations Dave. I can not use "foreHigh1.ui" because the TTS for german does not speak the degree-sign correctly (it says "degree-sign" instead of "degree")... so I will have to convert the "foreHigh1" to a number without decimal place...

Nine

Posted on
Sun Jun 12, 2016 5:17 am
DaveL17 offline
User avatar
Posts: 6742
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Precision of values

That sounds like the best approach to me, too. Good luck!


Sent from my iPhone using Tapatalk

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 2 guests