Python Question: device dump, can't print degree character

Posted on
Tue Nov 29, 2016 5:57 pm
tiff offline
Posts: 7
Joined: Nov 29, 2016

Python Question: device dump, can't print degree character

New to Python here... but I'm trying to dump the device list using this:
for dev in indigo.devices:
indigo.server.log(dev.name)
indigo.server.log(str(dev))

When it gets to my Davis Vue weather station (Using WeatherSnoop), which has the state column showing 29.4 degrees F (using the degree symbol), it gives me the error:
Script weather davis vue
Script Error embedded script: 'ascii' codec can't encode character u'\xb0' in position 255: ordinal not in range(128)
Script Error Exception Traceback (most recent call shown last):
embedded script, line 3, at top level
UnicodeEncodeError: 'ascii' codec can't encode character u'\xb0' in position 255: ordinal not in range(128)

I changed the state column to humidity, but I still get the same error.

I ran into a similar problem with a different device name, and obviously changing the name fixed it:
Script kitchen powerstrip (µcell, Hue, Autelis)
Script Error embedded script: 'ascii' codec can't encode character u'\xb5' in position 563: ordinal not in range(128)
Script Error Exception Traceback (most recent call shown last):
embedded script, line 3, at top level
UnicodeEncodeError: 'ascii' codec can't encode character u'\xb5' in position 563: ordinal not in range(128)

For the WeatherSnoop device, Is there a different command other than 'str(dev)' that I should try?

Posted on
Tue Nov 29, 2016 6:19 pm
jay (support) offline
Site Admin
User avatar
Posts: 18219
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Python Question: device dump, can't print degree charac

Try unicode(dev) rather than str(dev).

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Sun Dec 04, 2016 9:22 am
tiff offline
Posts: 7
Joined: Nov 29, 2016

Re: Python Question: device dump, can't print degree charac

Thank you, that worked!

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 6 guests