Page 1 of 1

Select comma vs period

PostPosted: Wed Jan 11, 2017 7:18 am
by haavarda
Hi Dave.
I have hopefully a quite easy request. I a working on some voice feedback from my sonos system.
One issue is that when the temperature is spoken it says that temperature is now 5 "period" 4 degrees. In Norwegian this sounds strange. It should have been comma instead.
Is it possible to make a selection on this? Or maybe a new state that converts to "," instead of "."?

thanks for your work on this plugin. It is rock solid and me and my family use this every day.

Re: Select comma vs period

PostPosted: Wed Jan 11, 2017 4:50 pm
by DaveL17
haavarda wrote:
Hi Dave.
I have hopefully a quite easy request. I a working on some voice feedback from my sonos system.
One issue is that when the temperature is spoken it says that temperature is now 5 "period" 4 degrees. In Norwegian this sounds strange. It should have been comma instead.
Is it possible to make a selection on this? Or maybe a new state that converts to "," instead of "."?

thanks for your work on this plugin. It is rock solid and me and my family use this every day.

That would sound strange in every language I'm guessing. Does this behavior relate to all decimal numbers or only selected states? I will add this to the list of things to take a look at for the next update. The plugin should really use local settings for stuff like that.

I'm glad you're enjoying the plugin. Hopefully, WU will get the API gremlins under control in the new year.

Dave

Re: Select comma vs period

PostPosted: Thu Jan 12, 2017 12:38 am
by haavarda
Thanks. At least in Scandinavia comma is the decimal separator. I agree that this should be handled in the WU data...


Sent from my iPhone using Tapatalk

Re: Select comma vs period

PostPosted: Tue Jan 24, 2017 5:12 pm
by howartp
Out of pure interest, not directly related to the question.

How would you pronounce "5,7 degrees" in this instance?

Do you still pronounce it "5 point 7 degrees" like English?

Or "5 comma 7 degrees"?


Sent from my iPhone using Tapatalk

Re: Select comma vs period

PostPosted: Tue Jan 24, 2017 6:35 pm
by jay (support)
howartp wrote:
How would you pronounce "5,7 degrees" in this instance?


+1

Though, I guess if it's a non-English language it wouldn't really help much to know... :lol:

Re: Select comma vs period

PostPosted: Tue Jan 24, 2017 11:09 pm
by haavarda
We say 5 comma 8 degrees.


Sent from my iPhone using Tapatalk

Re: Select comma vs period

PostPosted: Wed Jan 25, 2017 4:52 am
by DaveL17
haavarda wrote:
Hi Dave.
I have hopefully a quite easy request. I a working on some voice feedback from my sonos system.
One issue is that when the temperature is spoken it says that temperature is now 5 "period" 4 degrees. In Norwegian this sounds strange. It should have been comma instead.
Is it possible to make a selection on this? Or maybe a new state that converts to "," instead of "."?

thanks for your work on this plugin. It is rock solid and me and my family use this every day.


I'm honestly not sure what to do about this. I'm not sure how I'd make a setting to convert the values as they should all be stored as integers or floats. It's certainly possible to add additional states with the decimal converted to a comma, but which ones? What I would suggest is a small Python script that saves the current temperature to a variable (whenever the temperature value changes) and then speak from that. The conversion should be easy (untested):

Code: Select all
num = str(indigo.devices[12345678].states['temp']).replace('.', ',')
indigo.variable.updateValue(12345678, num)

If anyone has any other tips, I'm all ears.

Re: Select comma vs period

PostPosted: Wed Jan 25, 2017 5:55 am
by krissh
http://www.statisticalconsultants.co.nz ... imals.html

The most universal would probably be using locale I suppose. I don't know enough about this to tell whether this would affect other parts of a plugin or Indigo.

Re: Select comma vs period

PostPosted: Wed Jan 25, 2017 8:11 am
by DaveL17
krissh wrote:
http://www.statisticalconsultants.co.nz/blog/how-the-world-separates-its-decimals.html

The most universal would probably be using locale I suppose. I don't know enough about this to tell whether this would affect other parts of a plugin or Indigo.

Thanks krissh.

I guess I'm still a bit at sea. I'm storing the value as a float so I would expect that the server's localization settings would handle things that should be adjusted. I could certainly add a setting that could adjust the 'state.ui' value based on locale, but I suspect that most folks won't be keying on that for things like speech (although it would improve users' experience for display on control pages I suppose). I'd rather not add a bunch of new states (the plugin has a huge number already).

In any event, I want to be responsive to the need, I'm just not sure what the best approach is. Maybe adjusting the state.ui value is the best approach.

Re: Select comma vs period

PostPosted: Wed Jan 25, 2017 8:51 am
by krissh
Since I'm also in a "comma" country (same as haavarda) I've also experienced some dot/comma issues as the Indigo device states in general have dot/period rather than comma. It hasn't been a problem for me though, since Mac OS speech will pronounce 2.5 as "2 comma 5" when speaking Norwegian.

I was thinking in lines of having a text field in plugins config where users could enter a locale name, "nb_NO" for Norway and so on. And then have one additional state 'state.locale' for example. This would make it possible to have both thousand separators and decmial point correct for all countries. Best would be if this was possible in Indigo server of course. And I think matt or jay may have to comment on feasibility of using locale in a plugin, if this might break other things etc..

Another possibility is maybe to have a function included in a separate plugin with wrapper devices, such as the Adapters plugin for example. It may very well be possible already using the custom formula adapter, although I haven't tried it.

Re: Select comma vs period

PostPosted: Wed Jan 25, 2017 9:08 am
by haavarda
Thanks for the script Dave. I think this kind of fix will work for me.


Sent from my iPhone using Tapatalk

Re: Select comma vs period

PostPosted: Wed Jan 25, 2017 8:57 pm
by DaveL17
krissh wrote:
Another possibility is maybe to have a function included in a separate plugin with wrapper devices, such as the Adapters plugin for example. It may very well be possible already using the custom formula adapter, although I haven't tried it.

Actually, the Adapters Plugin sounds like a superior option. I can't easily test this, but after reading the docs, I *believe* that this setup *should* yield the string '37,2'.

Screen Shot 2017-01-25 at 8.50.02 PM.png
Screen Shot 2017-01-25 at 8.50.02 PM.png (59.76 KiB) Viewed 6101 times


Will need to rely on someone with a proper locale setting to test it out, however.

https://docs.python.org/2/library/string.html#format-specification-mini-language

Re: Select comma vs period

PostPosted: Thu Jan 26, 2017 12:53 am
by krissh
I did a quick test, and it returns the decimal number, but with period: 37.2 :?

I'm guessing the locale has to be set within the plugin, but again don't know if this would mess up other things in Indigo or the plugin..

Tried this:
Code: Select all
>>> import locale
>>> locale.getdefaultlocale()
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/locale.py", line 511, in getdefaultlocale
    return _parse_localename(localename)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/locale.py", line 443, in _parse_localename
    raise ValueError, 'unknown locale: %s' % localename
ValueError: unknown locale: UTF-8
>>> locale.getlocale()
(None, None)


The only thing I can see in os.environ that seems related to locale is this
Code: Select all
'LC_CTYPE': 'UTF-8'

Re: Select comma vs period

PostPosted: Wed Jan 27, 2021 1:27 am
by tazswe
I have the same problem with dot instead of comma in the Weatherflow plugin.

Did you find any solution with the dot, comma problem?


Skickat från min iPad med Tapatalk