Select comma vs period

Posted on
Wed Jan 11, 2017 7:18 am
haavarda offline
User avatar
Posts: 693
Joined: Aug 18, 2012
Location: Norway

Select comma vs period

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.

Håvard

Posted on
Wed Jan 11, 2017 4:50 pm
DaveL17 offline
User avatar
Posts: 5364
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Select comma vs period

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

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

[My Plugins] - [My Forums]

Posted on
Thu Jan 12, 2017 12:38 am
haavarda offline
User avatar
Posts: 693
Joined: Aug 18, 2012
Location: Norway

Re: Select comma vs period

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

Håvard

Posted on
Tue Jan 24, 2017 5:12 pm
howartp offline
Posts: 3937
Joined: Jan 09, 2014
Location: West Yorkshire, UK

Re: Select comma vs period

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

Posted on
Tue Jan 24, 2017 6:35 pm
jay (support) offline
Site Admin
User avatar
Posts: 16112
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Select comma vs period

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:

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Tue Jan 24, 2017 11:09 pm
haavarda offline
User avatar
Posts: 693
Joined: Aug 18, 2012
Location: Norway

Re: Select comma vs period

We say 5 comma 8 degrees.


Sent from my iPhone using Tapatalk

Håvard

Posted on
Wed Jan 25, 2017 4:52 am
DaveL17 offline
User avatar
Posts: 5364
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Select comma vs period

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.

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

[My Plugins] - [My Forums]

Posted on
Wed Jan 25, 2017 5:55 am
krissh offline
Posts: 104
Joined: Nov 18, 2012
Location: Norway

Re: Select comma vs period

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.

Posted on
Wed Jan 25, 2017 8:11 am
DaveL17 offline
User avatar
Posts: 5364
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Select comma vs period

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.

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

[My Plugins] - [My Forums]

Posted on
Wed Jan 25, 2017 8:51 am
krissh offline
Posts: 104
Joined: Nov 18, 2012
Location: Norway

Re: Select comma vs period

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.

Posted on
Wed Jan 25, 2017 9:08 am
haavarda offline
User avatar
Posts: 693
Joined: Aug 18, 2012
Location: Norway

Re: Select comma vs period

Thanks for the script Dave. I think this kind of fix will work for me.


Sent from my iPhone using Tapatalk

Håvard

Posted on
Wed Jan 25, 2017 8:57 pm
DaveL17 offline
User avatar
Posts: 5364
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Select comma vs period

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 1811 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

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

[My Plugins] - [My Forums]

Posted on
Thu Jan 26, 2017 12:53 am
krissh offline
Posts: 104
Joined: Nov 18, 2012
Location: Norway

Re: Select comma vs period

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'

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 1 guest