UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2

This forum is archived topics from before the plugin was moved to the new owner. All topics are locked, but are preserved here for future reference.
Jann
Posts: 120
Joined: Sun Mar 12, 2006 10:20 am
Location: Auburndale, FL
Contact:

Re: UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2

Post by Jann »

I have a many Hue device types (i think 5 or 6...)

I'll change them all...
Jann
Posts: 120
Joined: Sun Mar 12, 2006 10:20 am
Location: Auburndale, FL
Contact:

Re: UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2

Post by Jann »

Well, SHOOT!

It didn't work. Indigo still complaining. This one is different tho...

I changed the name of the Hue device to have the smart apostrophe, made the changes to all the debug lines in the python script, rebooted the server (for good measure) Then - for funsies - I just went to that device in indigo and hit "Send Status Request," the following happened:

Code: Select all

 Hue Lights Error                Error in plugin execution ExecuteAction:

Traceback (most recent call last):
  File "plugin.py", line 3443, in actionControlDimmerRelay
  File "plugin.py", line 4784, in getBulbStatus
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 176: ordinal not in range(128)

Line 4784 is one of the 8 or so lines I changed to:

Code: Select all

self.debugLog(u"Data from hub: {}".format(r.content))
Are we sure that's the line to use?
(ps: it STILL has the same problem assigning a NEW indigo device to a Hue device with an apostrophe.)
User avatar
FlyingDiver
Posts: 7830
Joined: Sat Jun 07, 2014 10:36 am
Location: Southwest Florida, USA

Re: UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2

Post by FlyingDiver »

Since those are just debug logging lines, you could just comment them out and see if it works.

Code: Select all

# self.debugLog(u"Data from hub: {}".format(r.content))
joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177
User avatar
Colorado4Wheeler
Posts: 2794
Joined: Mon Jul 20, 2009 10:48 am
Location: Colorado

Re: UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2

Post by Colorado4Wheeler »

You could try opening it up in TextWrangler and doing a replace all:

Code: Select all

replace self.debugLog with # self.debugLog
My Modest Contributions to Indigo:

HomeKit Bridge | Device Extensions | Security Manager | LCD Creator | Room-O-Matic | Smart Dimmer | Scene Toggle | Powermiser | Homebridge Buddy

Check Them Out Here
Jann
Posts: 120
Joined: Sun Mar 12, 2006 10:20 am
Location: Auburndale, FL
Contact:

Re: UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2

Post by Jann »

Duh! (that "Duh" was for ME not YOU! Sorry....)

I'm a programmer and didn't think of this. I am just not a PYTHON programmer. BTW: what is the best way to restart after changing the python plugin? I rebooted the mini to make sure but Plug ins->Hue Lights->reload didn't seem to load the newly changed python script?

Thanks for ALL your help!

Jann
User avatar
FlyingDiver
Posts: 7830
Joined: Sat Jun 07, 2014 10:36 am
Location: Southwest Florida, USA

Re: UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2

Post by FlyingDiver »

Jann wrote:I'm a programmer and didn't think of this. I am just not a PYTHON programmer. BTW: what is the best way to restart after changing the python plugin? I rebooted the mini to make sure but Plug ins->Hue Lights->reload didn't seem to load the newly changed python script?
It should, if you're actually editing the correct files. That's what I do 99% of the time while working on a plugin. Just do a restart on the plugin.
joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177
Jann
Posts: 120
Joined: Sun Mar 12, 2006 10:20 am
Location: Auburndale, FL
Contact:

Re: UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2

Post by Jann »

FINALLY!

The "commenting out" worked...

As did the "reload" of the plug-in. I just hadn't waited for the important thing upon reload...the plugin stops, starts and UNTIL it gets the JSON from the hue hub it doesn't get the "changed" name of the hue light... so I was trying to do things too fast.

Oh, well. I hope this gets fixed in the regular release...cos commenting out debug lines isn't the best fix.

Thanks for all the help!

Jann
nsheldon
Posts: 2469
Joined: Mon Aug 09, 2010 2:12 pm
Location: CA
Contact:

Re: UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2

Post by nsheldon »

In order for me to fix the debug lines, I need to be able to test this error condition, so it’d be gelpful to see the actual data coming from the Hue hub. Hard to get that if the debug lines are commented out though. Haha.
User avatar
FlyingDiver
Posts: 7830
Joined: Sat Jun 07, 2014 10:36 am
Location: Southwest Florida, USA

Re: UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2

Post by FlyingDiver »

nsheldon wrote:In order for me to fix the debug lines, I need to be able to test this error condition, so it’d be gelpful to see the actual data coming from the Hue hub. Hard to get that if the debug lines are commented out though. Haha.
Can you rename one of your devices with a unicode character in it? And maybe try some variants on the string conversion, like using:

Code: Select all

print(u"Something interesting: {0}".format(some_var.decode('utf-8')))
joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177
nsheldon
Posts: 2469
Joined: Mon Aug 09, 2010 2:12 pm
Location: CA
Contact:

Re: UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2

Post by nsheldon »

Yea. I’ll try that. That should be a good enough test. It’ll probably take me a bit to get a fix out.
User avatar
FlyingDiver
Posts: 7830
Joined: Sat Jun 07, 2014 10:36 am
Location: Southwest Florida, USA

Re: UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2

Post by FlyingDiver »

I would also recommend doing the debug statement on the resulting JSON data, not the raw data from the request. That would probably eliminate the error totally, as the JSON conversion should correctly identify the strings as unicode.
joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177
nsheldon
Posts: 2469
Joined: Mon Aug 09, 2010 2:12 pm
Location: CA
Contact:

Re: UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2

Post by nsheldon »

Thanks for the recommendation.
Locked

Return to “Archives”