Python variable assignment no longer working

Posted on
Sun Nov 27, 2022 4:14 pm
towsled offline
Posts: 32
Joined: Jul 19, 2014

Python variable assignment no longer working

I have some python that sets a variable that stopped working some time ago and I am working to get it going ago. The error that I am getting is:

Script Error schedule "EMK Power Monitor" embedded script error:
Script Error name 'unicode' is not defined
Script Error Exception Traceback (most recent call shown last):

Here is an example of the code that worked fine for many years but now is causing an error:

# Get meter response and log date/time collected
response = sp.read(255)
indigo.variable.updateValue(1582391571, value=unicode(indigo.server.getTime())) #MeterLastReadTime

Any guidance on how to resolve would be greatly appreciated.

Thanks,
Dan..

Posted on
Sun Nov 27, 2022 6:47 pm
DaveL17 offline
User avatar
Posts: 6756
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Python variable assignment no longer working

In Python 3, all strings are Unicode. Try

Code: Select all
f"{indigo.server.getTime()}"

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Sat Dec 10, 2022 9:19 am
towsled offline
Posts: 32
Joined: Jul 19, 2014

Re: Python variable assignment no longer working

Just getting back to this. Thanks DaveL17, worked like a charm!

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 3 guests