change format to not have 2.5000000000001 strings in states

Posted on
Tue Oct 03, 2017 11:07 pm
kw123 offline
User avatar
Posts: 8333
Joined: May 12, 2013
Location: Dallas, TX

change format to not have 2.5000000000001 strings in states

suggestion to the authors or Matt,Jay:

with adding decimalPlaces :
Code: Select all
   def _addToBatchStatesChange(self, dev, key="", value="",decimalPlaces=""):
      devId = dev.id
      if devId not in self.batchStatesUpdate:
         self.batchStatesUpdate[devId] = []
      if decimalPlaces == "":
         self.batchStatesUpdate[devId].append({"key":key, "value":value})
      else:
         self.batchStatesUpdate[devId].append({"key":key, "value":value,"decimalPlaces":decimalPlaces})
      return

and adding decimalplaces to each of the calls with numbers to e.g.:
Code: Select all
         self._addToBatchStatesChange(self.tempList[sensor], key=u"currentMonthTotal", value=currentMonthTotal,decimalPlaces=2)         
It looks much better ===> "2.5000000000001" becomes "2.50"

Karl

Posted on
Tue Oct 03, 2017 11:11 pm
jay (support) offline
Site Admin
User avatar
Posts: 18199
Joined: Mar 19, 2008
Location: Austin, Texas

Re: change format to not have 2.5000000000001 strings in sta


Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Wed Oct 04, 2017 10:07 am
kw123 offline
User avatar
Posts: 8333
Joined: May 12, 2013
Location: Dallas, TX

Re: change format to not have 2.5000000000001 strings in sta

know the GitHub site.
The posted version does not have this option.
And I found no way to post/comment anything.

Thats why I posted it here.

Karl

Posted on
Wed Oct 04, 2017 1:04 pm
jay (support) offline
Site Admin
User avatar
Posts: 18199
Joined: Mar 19, 2008
Location: Austin, Texas

Re: change format to not have 2.5000000000001 strings in sta

Fork it, change it, and issue a pull request - since it's open source you can do the work yourself, that's the best way to get it done. Alternately, you can add an issue on Github for it and perhaps someone else will do it.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 3 guests