UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2
Re: UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2
I have a many Hue device types (i think 5 or 6...)
I'll change them all...
I'll change them all...
Re: UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2
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:
Line 4784 is one of the 8 or so lines I changed to:
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.)
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)
Code: Select all
self.debugLog(u"Data from hub: {}".format(r.content))(ps: it STILL has the same problem assigning a NEW indigo device to a Hue device with an apostrophe.)
- FlyingDiver
- Posts: 7830
- Joined: Sat Jun 07, 2014 10:36 am
- Location: Southwest Florida, USA
Re: UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2
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
my plugins: http://forums.indigodomo.com/viewforum.php?f=177
- Colorado4Wheeler
- Posts: 2794
- Joined: Mon Jul 20, 2009 10:48 am
- Location: Colorado
Re: UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2
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
HomeKit Bridge | Device Extensions | Security Manager | LCD Creator | Room-O-Matic | Smart Dimmer | Scene Toggle | Powermiser | Homebridge Buddy
Check Them Out Here
Re: UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2
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
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
- FlyingDiver
- Posts: 7830
- Joined: Sat Jun 07, 2014 10:36 am
- Location: Southwest Florida, USA
Re: UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2
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.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?
joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177
my plugins: http://forums.indigodomo.com/viewforum.php?f=177
Re: UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2
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
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
Re: UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2
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.
- FlyingDiver
- Posts: 7830
- Joined: Sat Jun 07, 2014 10:36 am
- Location: Southwest Florida, USA
Re: UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2
Can you rename one of your devices with a unicode character in it? And maybe try some variants on the string conversion, like using: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.
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
my plugins: http://forums.indigodomo.com/viewforum.php?f=177
Re: UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2
Yea. I’ll try that. That should be a good enough test. It’ll probably take me a bit to get a fix out.
- FlyingDiver
- Posts: 7830
- Joined: Sat Jun 07, 2014 10:36 am
- Location: Southwest Florida, USA
Re: UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2
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
my plugins: http://forums.indigodomo.com/viewforum.php?f=177
Re: UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2
Thanks for the recommendation.