Error in Python script

Posted on
Sun Dec 06, 2020 7:36 am
Bildhauer offline
Posts: 65
Joined: Sep 30, 2019
Location: 22113 Oststeinbek (near Hamburg), Germany

Error in Python script

Hello,

what's wrong in my script?

Code: Select all
dev = indigo.devices[216829489] # "Temperatursensor Gästehaus"]
tempGaestehaus = (indigo.devices[216829489].states['sensorValue']-32)*5/9

indigo.variable.updateValue(114942988,u"{:03.1f}".format(tempGaestehaus))

a = u"merckens@gmx.de;maximilian@familie-merckens.de"
s = u"Änderung der Temperatur"
b = u"Die neue Temperatur ist nun "+ u"{:03.1f}".format(tempGaestehaus) + "ºC."

indigo.server.sendEmailTo(a, subject=s, body=b)


The variable tempGaestehaus is updated correctly ion Indigo's variable list . Error occurs in "b = u"Die neue Temperatur ist nun "+ u"{:03.1f}".format(tempGaestehaus) + "ºC."". Anyone able/ willing to help me?

Best regards

Bildhauer
Attachments
Notification_Center.jpg
Error
Notification_Center.jpg (77.95 KiB) Viewed 253 times

Posted on
Sun Dec 06, 2020 8:33 am
RogueProeliator offline
User avatar
Posts: 2385
Joined: Nov 13, 2012
Location: Baton Rouge, LA

Re: Error in Python script

b = u"Die neue Temperatur ist nun "+ u"{:03.1f}".format(tempGaestehaus) + "ºC."

Your issue is with the last section -- the degree symbol substring is not Unicode. Simply add the u in front of the substring like you did for the others. Note that you could also do this all in one line:

Code: Select all
b = u"Die neue Temperatur ist nun {:03.1f} ºC.".format(tempGaestehaus)

Adam

Posted on
Sun Dec 06, 2020 8:42 am
Bildhauer offline
Posts: 65
Joined: Sep 30, 2019
Location: 22113 Oststeinbek (near Hamburg), Germany

Re: Error in Python script

Thx a lot. It's working now!

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 1 guest