Python 3

Posted on
Mon Jul 31, 2023 10:36 am
durosity offline
User avatar
Posts: 4320
Joined: May 10, 2012
Location: Newcastle Upon Tyne, Ye Ol' England.

Python 3

I’m guessing this plugin is long dead and won’t be getting a Python 3 update? I’d actually completely forgotten I had one of these which is still in use.. testament to how reliable it’s been I guess!


Sent from my iPhone using Tapatalk Pro

Computer says no.

Posted on
Tue Oct 03, 2023 3:50 pm
Colly offline
Posts: 535
Joined: Jan 16, 2016
Location: Ireland

Re: Python 3

Hi Durosity,
I'm assuming you didn't manage to get this issue solved. Hopefully I'm wrong. :wink:
Anyone else out there willing to take a look at it? Going to prevent me updating to newer versions of Indigo for the time being. :(

Posted on
Tue Oct 03, 2023 6:40 pm
jay (support) offline
Site Admin
User avatar
Posts: 18225
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Python 3

I just pinged the developer on the plugin's github repository - we'll see what he says.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Tue Oct 03, 2023 11:46 pm
Colly offline
Posts: 535
Joined: Jan 16, 2016
Location: Ireland

Re: Python 3

Thanks Jay. Did the same back in March but heard nothing.

Posted on
Wed Oct 04, 2023 5:02 am
DaveL17 offline
User avatar
Posts: 6759
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Python 3

I opened the plugin up in my development environment (PyCharm) and chose a Python 3.10 interpreter. I didn't see any obvious syntax errors so it may just be a simple fix to update the info.plist file ServerApiVersion node from:

Code: Select all
   <key>ServerApiVersion</key>
   <string>2.0</string>
to:

Code: Select all
   <key>ServerApiVersion</key>
   <string>3.0</string>
I have not tested this, so it's definitely a caveat emptor situation. I read somewhere about issues with https:// vs. http:// (maybe it was with the other 8-channel relay plugin?) so there's no guarantees my suggestion above will work. If trying this out, don't risk mission critical stuff.

If the developer doesn't respond or doesn't want to do the update, I'm willing to take a run at updating it to Python 3 (if it's added to the Indigo Open Source library).

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

[My Plugins] - [My Forums]

Posted on
Wed Oct 04, 2023 6:35 am
Colly offline
Posts: 535
Joined: Jan 16, 2016
Location: Ireland

Re: Python 3

Thanks Dave, I might get brave and try it out. I’d like to keep using the board as it’s been solid since day 1. I have some workaround options if all else fails.
Happy to test if you do manage to take it over.

Posted on
Wed Oct 04, 2023 11:44 am
Colly offline
Posts: 535
Joined: Jan 16, 2016
Location: Ireland

Re: Python 3

OK so, I got brave and made suggested change. Got the following errors in the log. Changed back to original version so working again.
Code: Select all
/Frameworks/Python.framework/Versions/3.10/lib/python3.10/telnetlib.py", line 288, in write
type: 'in <string>' requires string as left operand, not bytes

   8 Channel Network Relay Error   plugin runConcurrentThread function returned or failed (will attempt again in 10 seconds)
   8 Channel Network Relay Error   Error in plugin execution runConcurrentThread:

  File "plugin.py", line 129, in runConcurrentThread
  File "plugin.py", line 320, in set_device_states
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/telnetlib.py", line 288, in write
type: 'in <string>' requires string as left operand, not bytes

   8 Channel Network Relay Error   plugin runConcurrentThread function returned or failed (will attempt again in 10 seconds)
   8 Channel Network Relay Error   Error in plugin execution runConcurrentThread:

  File "plugin.py", line 129, in runConcurrentThread
  File "plugin.py", line 320, in set_device_states
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/telnetlib.py", line 288, in write
type: 'in <string>' requires string as left operand, not bytes

   8 Channel Network Relay Error   plugin runConcurrentThread function returned or failed (will attempt again in 10 seconds)
   8 Channel Network Relay Error   Error in plugin execution runConcurrentThread:

  File "plugin.py", line 129, in runConcurrentThread
  File "plugin.py", line 320, in set_device_states
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/telnetlib.py", line 288, in write
type: 'in <string>' requires string as left operand, not bytes

Posted on
Wed Oct 04, 2023 12:12 pm
DaveL17 offline
User avatar
Posts: 6759
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Python 3

Yep, those are very common errors when converting a plugin to Python 3. Shouldn't be too hard to overcome once the plugin lands in the Indigo Open Source library (hence clearance from the original author). The plugin license may allow for that anyway, but it's up to Jay and Matt to make that call.

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

[My Plugins] - [My Forums]

Posted on
Wed Oct 04, 2023 2:07 pm
jay (support) offline
Site Admin
User avatar
Posts: 18225
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Python 3

The license is GPLv2, which is somewhat problematic in that it calls for specific language to be attached to the product, but the developer only references GPLv2 in the Readme file (he references a LICENSE file which is not actually present in the repo, so that sorta violates the license). We are not fans of the GPL license and much prefer the MIT license, but that's just us...

Bottom line, we're not going to fork this into our open source repo without explicit permission from the developer to do so. However, anyone that wants to fork it from his repo, make the changes, then issue a PR to him is more than welcome to do it. Hopefully if a PR shows up on his repo he will take a quick look, merge it, and create a new release.

Feel free to contact him through GitHub to encourage him to do something.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Sun Oct 08, 2023 2:25 pm
Colly offline
Posts: 535
Joined: Jan 16, 2016
Location: Ireland

Re: Python 3

@Jay Does this plugin (https://www.indigodomo.com/pluginstore/245/) make it any easier to adopt? I've tried it and it works albeit with errors in the log. I actually forgot about trying this previously. I tried to contact the developer on GitHub back in May however never got any response..

Posted on
Sun Oct 08, 2023 7:43 pm
jay (support) offline
Site Admin
User avatar
Posts: 18225
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Python 3

I don't think they are the same, but I don't know.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Wed Nov 08, 2023 10:43 pm
Korey offline
User avatar
Posts: 813
Joined: Jun 04, 2008
Location: Henderson, NV

Re: Python 3

Well this was one of the last ones I was waiting for to upgrade to then new, (no Python 2 Indigo Version)

I had an extra Zooz ZEN17 kicking around, so I provisioned it and it fits the bill. ( at least for what I need)

In case anyone else is waiting for a Python 3 update to this plugin, this is a cheap option.

--
Korey

Posted on
Wed Nov 22, 2023 12:38 pm
pacman offline
Posts: 67
Joined: Sep 17, 2008
Location: Pacifica, CA

Re: Python 3

I am looking at all the possible issues I can find before upgrading to Indigo 2023.x. This is my https://forums.indigodomo.com/viewtopic.php?f=364&t=27603 from yesterday trying to resolve a similar issue. The 8ChannelNetwork board does not have a compatible plugin upgrade for 2023.x but I found I can operate relays with URL commands using Python2 script bypassing the plugin. According to the reply from yesterday's post, the text needs to be changed to Python3 but is doable. This same logic should apply for the following script:

myURL1 = "http://admin:1Dc333@192.168.0.61/relay_en.cgi?relayoff1=off"
myURL2 = "http://admin:1Dc333@192.168.0.61/relay_en.cgi?relayoff2=off"
myURL3 = "http://admin:1Dc333@192.168.0.61/relay_en.cgi?relayoff3=off"
myURL4 = "http://admin:1Dc333@192.168.0.61/relay_en.cgi?relayon4=on"
myURL5 = "http://admin:1Dc333@192.168.0.61/relay_en.cgi?relayon5=on"
myURL6 = "http://admin:1Dc333@192.168.0.61/relay_en.cgi?relayoff6=off"
myURL7 = "http://admin:1Dc333@192.168.0.61/relay_en.cgi?relayoff7=off"
myURL8 = "http://admin:1Dc333@192.168.0.61/relay_en.cgi?relayoff8=off"


import urllib
urllib.urlopen(myURL1)
urllib.urlopen(myURL2)
urllib.urlopen(myURL3)
urllib.urlopen(myURL4)
urllib.urlopen(myURL5)
urllib.urlopen(myURL6)
urllib.urlopen(myURL7)
urllib.urlopen(myURL8)

I just need expert advise on how to create Python3 script to accomplish the same result for above v2 script. There isn't a real question here but I do want someone to point me toward proper Python3 syntax. After years of using Indigo Server, I rarely have to make scripting changes, so updating to a whole new version is difficult.

Also, I haven't figured out how to read into Indigo a relay board's input change of state without using the plugin.

Posted on
Wed Nov 22, 2023 1:30 pm
FlyingDiver offline
User avatar
Posts: 7222
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Python 3

That should work, but the better option for Python3 is:
Code: Select all
import requests

myURL1 = "http://admin:1Dc333@192.168.0.61/relay_en.cgi?relayoff1=off"
myURL2 = "http://admin:1Dc333@192.168.0.61/relay_en.cgi?relayoff2=off"
myURL3 = "http://admin:1Dc333@192.168.0.61/relay_en.cgi?relayoff3=off"
myURL4 = "http://admin:1Dc333@192.168.0.61/relay_en.cgi?relayon4=on"
myURL5 = "http://admin:1Dc333@192.168.0.61/relay_en.cgi?relayon5=on"
myURL6 = "http://admin:1Dc333@192.168.0.61/relay_en.cgi?relayoff6=off"
myURL7 = "http://admin:1Dc333@192.168.0.61/relay_en.cgi?relayoff7=off"
myURL8 = "http://admin:1Dc333@192.168.0.61/relay_en.cgi?relayoff8=off"

requests.get(myURL1)
requests.get(myURL2)
requests.get(myURL3)
requests.get(myURL4)
requests.get(myURL5)
requests.get(myURL6)
requests.get(myURL7)
requests.get(myURL8)


joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Thu Nov 30, 2023 4:49 pm
Colly offline
Posts: 535
Joined: Jan 16, 2016
Location: Ireland

Re: Python 3

FlyingDiver wrote:
That should work, but the better option for Python3 is:
Code: Select all
import requests

myURL1 = "http://admin:1Dc333@192.168.0.61/relay_en.cgi?relayoff1=off"
myURL2 = "http://admin:1Dc333@192.168.0.61/relay_en.cgi?relayoff2=off"
myURL3 = "http://admin:1Dc333@192.168.0.61/relay_en.cgi?relayoff3=off"
myURL4 = "http://admin:1Dc333@192.168.0.61/relay_en.cgi?relayon4=on"
myURL5 = "http://admin:1Dc333@192.168.0.61/relay_en.cgi?relayon5=on"
myURL6 = "http://admin:1Dc333@192.168.0.61/relay_en.cgi?relayoff6=off"
myURL7 = "http://admin:1Dc333@192.168.0.61/relay_en.cgi?relayoff7=off"
myURL8 = "http://admin:1Dc333@192.168.0.61/relay_en.cgi?relayoff8=off"

requests.get(myURL1)
requests.get(myURL2)
requests.get(myURL3)
requests.get(myURL4)
requests.get(myURL5)
requests.get(myURL6)
requests.get(myURL7)
requests.get(myURL8)


This works for me which is great, any chance of some help in requesting status and updating a variable?

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 7 guests