Page 1 of 1

Error in Python script

PostPosted: Sun Dec 06, 2020 7:36 am
by Bildhauer
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

Re: Error in Python script

PostPosted: Sun Dec 06, 2020 8:33 am
by RogueProeliator
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

Re: Error in Python script

PostPosted: Sun Dec 06, 2020 8:42 am
by Bildhauer
Thx a lot. It's working now!