Device name containing accented characters

Posted on
Fri Nov 16, 2012 12:01 pm
DomoPat offline
User avatar
Posts: 210
Joined: Jul 17, 2010
Location: Toulouse, France

Device name containing accented characters

I have a device whose name is "Entrée", with an accent in the fourth character, works fine except when I use it in an Action group. Then I have an error in the log:
---
Action Group Parfumateur 3 heures
RFXCOM Error Error in plugin execution ExecuteAction:

Traceback (most recent call last):
File "plugin.py", line 76, in actionControlDimmerRelay
<type 'exceptions.UnicodeEncodeError'>: 'ascii' codec can't encode character u'\xe9' in position 4: ordinal not in range(128)
---

ho ho, error in position 4 !

Line 76 is the last line of:
Code: Select all
   ###### TURN ON ######
      if action.deviceAction == indigo.kDeviceAction.TurnOn:
         # Command hardware module (dev) to turn ON here:
         self.debugLog(u"Variabelen: \"%s\" %s %s" % (self, action, dev))


As it is a 'debugging line' I commented it and the error disappeared, but it might need a better fix. I don't see why the accent crashes, my rudimentary knowldege of Python tells me the 'u' should take care of that, but evidently not.

Posted on
Mon Nov 19, 2012 3:57 pm
matt (support) offline
Site Admin
User avatar
Posts: 21417
Joined: Jan 27, 2003
Location: Texas

Re: Device name containing accented characters

Try changing this line:

Code: Select all
         self.debugLog(u"Variabelen: \"%s\" %s %s" % (self, action, dev))


to:

Code: Select all
         self.debugLog(u"Variabelen: \"%s\" %s %s" % (self, action, dev.name))


Indigo does handle logging unicode strings correctly, but the original line is trying to dump the entire dev instance to the log file. The code that converts the object instance attributes to key/value strings isn't handling the unicode conversion optimally, which is why the error occurs. I'll look into improving that. In the mean time, if you change it to explicitly just log the name and not the entire instance, it should prevent the error.

Image

Posted on
Mon Nov 19, 2012 4:33 pm
matt (support) offline
Site Admin
User avatar
Posts: 21417
Joined: Jan 27, 2003
Location: Texas

Re: Device name containing accented characters

I believe I have Indigo's handling of logging the entire device instance working in the next beta of Indigo 6 (not yet available).

Image

Posted on
Tue Nov 20, 2012 4:38 am
DomoPat offline
User avatar
Posts: 210
Joined: Jul 17, 2010
Location: Toulouse, France

Re: Device name containing accented characters

Thank you for the help and the explanation of the solution, I learned a bit more. I see that in the other cases it is dev.name that is used, not the whole instance.

Posted on
Tue Nov 20, 2012 1:52 pm
nsheldon offline
Posts: 2469
Joined: Aug 09, 2010
Location: CA

Re: Device name containing accented characters

matt (support) wrote:
I believe I have Indigo's handling of logging the entire device instance working in the next beta of Indigo 6 (not yet available).

Yay! :-) That bit of unicode mishandling in the device key:value display method was wreaking havoc on my Pioneer Receiver plugin's debugLog calls when any of the device states contained a special character (Internet radio station names, etc), to the point where I just had to catch the error and basically say "I can't show you the device info because it's special." Hahaha.

Posted on
Tue Nov 20, 2012 3:47 pm
RJdeKok offline
Posts: 125
Joined: Mar 27, 2012

Re: Device name containing accented characters

The problem is solved, a new version is available here:http://www.rjdekok.nl/downloads/RFXCOM.indigoPlugin.zip

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 13 guests

cron