Help converting serial string generator script.

Posted on
Sun Apr 23, 2023 7:27 am
hamw offline
Posts: 1212
Joined: Mar 31, 2008

Help converting serial string generator script.

I have used this script for years to control a Vaux matrix switch:

Code: Select all
simpleSerialId = indigo.server.getPlugin("org.yergeyjDoesntHaveaURL.simpleserial")
if simpleSerialId.isEnabled():
   message = "%s\n" % (indigo.variables["direct_Vaux_Send"].value)
   simpleSerialId.executeAction("textToSerial", deviceId=775789076, props={"newCommand":message})


but it is now returning this error:

Code: Select all
   Script Error                    trigger "direct Vaux Send TEST" embedded script error:
   Script Error                    unable to convert python exception
   Script Error                    Exception Traceback (most recent call shown last):

     embedded script, line 4, at top level
RuntimeError: unable to convert python exception


Joe @FlyingDiver kindly recommended the .encode addition to this line:

Code: Select all
message = ("%s\n" % (indigo.variables["direct_Vaux_Send"].value)).encode("utf-8")


and in reading this forum and looking at the other documentation I added ("utf-8"), but it still failing.

Code: Select all
simpleSerialId = indigo.server.getPlugin("org.yergeyjDoesntHaveaURL.simpleserial")
if simpleSerialId.isEnabled():
    message = ("%s\n" % (indigo.variables["direct_Vaux_Send"].value)).encode("utf-8")
    simpleSerialId.executeAction("textToSerial", deviceId=775789076, props={"newCommand": message})


I tried running it through ChatGPT with no success. Any thoughts would be much appreciated.

Posted on
Sun Apr 23, 2023 8:13 am
hamw offline
Posts: 1212
Joined: Mar 31, 2008

Re: Help converting serial string generator script.

I'd like to engage someone to update my scripts for this device. Please PM me or send email to hamw at comcast dot net and I'll attach the files. Would be happy to discuss pricing.

Thanks!

Posted on
Sun Apr 23, 2023 9:58 am
FlyingDiver offline
User avatar
Posts: 7220
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Help converting serial string generator script.

Before you go to that effort, do these steps:

1. In the Indigo Preferences dialog, on the Plugins tab, check the "Enable debugging menus" box.

2. Restart the plugin using the "Reload in Interactive Shell" menu command (this is new when you enable the debugging menus). When you do this, a Terminal window will open.

3. At the bottom of the Plugins menu is an entry "Open Scripting Shell". Do that. A second terminal window will open.

4. Run your script in that (second) window.

Paste the contents of both shell windows into a reply in this thread or your previous one. Please use the CODE tags.

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

Posted on
Sun Apr 23, 2023 3:41 pm
hamw offline
Posts: 1212
Joined: Mar 31, 2008

Re: Help converting serial string generator script.

debugger:

Code: Select all
Starting shell for plugin SimpleSerial.indigoPlugin.
To access the plugin instance use the global named self.

Python 3.10.2 (v3.10.2:a58ebcc701, Jan 13 2022, 14:50:16) [Clang 13.0.0 (clang-1300.0.29.30)]
Connected to Indigo Server v2022.2.2, api v3.2 (localhost:1176)
Started Plugin Simple Serial v1.0.1
>>>



Scripting Shell:
Code: Select all
Python 3.10.2 (v3.10.2:a58ebcc701, Jan 13 2022, 14:50:16) [Clang 13.0.0 (clang-1300.0.29.30)]
Connected to Indigo Server v2022.2.2, api v3.2 (localhost:1176)
>>> simpleSerialId = indigo.server.getPlugin("org.yergeyjDoesntHaveaURL.simpleserial")
>>> if simpleSerialId.isEnabled():
...     message = ("%s\n" % (indigo.variables["direct_Vaux_Send"].value)).encode("utf-8")
...     simpleSerialId.executeAction("textToSerial", deviceId=775789076, props={"newCommand": message})
...
Traceback (most recent call last):
  File "<console>", line 3, in <module>
RuntimeError: unable to convert python exception


Doesn't seem to do much more than this? I can paste some of the plugin code if that would help.

Posted on
Sun Apr 23, 2023 3:54 pm
FlyingDiver offline
User avatar
Posts: 7220
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Help converting serial string generator script.

Hmm. Line 3 is:

Code: Select all
    message = ("%s\n" % (indigo.variables["direct_Vaux_Send"].value)).encode("utf-8")


Try this:

Code: Select all
simpleSerialId = indigo.server.getPlugin("org.yergeyjDoesntHaveaURL.simpleserial")
if simpleSerialId.isEnabled():
    send_val = indigo.variables[VARIABLEIDHERE].value
    message = f"{send_val}\n".encode("utf-8")
    simpleSerialId.executeAction("textToSerial", deviceId=775789076, props={"newCommand":message})


You'll need to put in your variable ID, not the variable name

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

Posted on
Sun Apr 23, 2023 4:45 pm
hamw offline
Posts: 1212
Joined: Mar 31, 2008

Re: Help converting serial string generator script.

I added the variable ID:

Code: Select all
simpleSerialId = indigo.server.getPlugin("org.yergeyjDoesntHaveaURL.simpleserial")
if simpleSerialId.isEnabled():
    send_val = indigo.variables[1659039123].value
    message = f"{send_val}\n".encode("utf-8")
    simpleSerialId.executeAction("textToSerial", deviceId=775789076, props={"newCommand":message})


and the code still is throwing an exception.

Code: Select all
  Script Error                    embedded script error:
   Script Error                    unable to convert python exception
   Script Error                    Exception Traceback (most recent call shown last):

     embedded script, line 5, at top level
RuntimeError: unable to convert python exception


If helpful, this is string the code is trying to send to the Vaux unit.... *CW,91,1,0,0,0

Posted on
Sun Apr 23, 2023 4:49 pm
FlyingDiver offline
User avatar
Posts: 7220
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Help converting serial string generator script.

Ok, then it must be the SimpleSerial plugin actually throwing the exception. HI just looked up that plugin. It's abandoned, and the author did not include a license that allows someone else to fix it.

You're going to have to find a solution that doesn't require that plugin.

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

Posted on
Sun Apr 23, 2023 6:57 pm
FlyingDiver offline
User avatar
Posts: 7220
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Help converting serial string generator script.

I had totally forgotten that I had written a plugin that I think is similar to SimpleSerial, but never released it. I don't even remember why I wrote it.

It's available here: https://github.com/FlyingDiver/Indigo-miniSerial

I'll try to update it to Python3 soon.

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

Posted on
Sat Nov 11, 2023 6:05 pm
brianlloyd offline
User avatar
Posts: 226
Joined: May 26, 2013
Location: San Antonio, TX, USA

Re: Help converting serial string generator script.

Well, I think you wrote it for me so I could control my Somfy roller shades. The roller shades can't be controlled by their ethernet interface device because the roller blinds use the "stop" command and their interface doesn't support it. I had to use the older URTS-II controller, which is RS232 or RS485.

Well, I just upgraded Indigo and ... oops, no shade control.

If there is another serial line interface I will use that (is there?) but failing that ...

Thanks!

Posted on
Sat Nov 11, 2023 7:03 pm
FlyingDiver offline
User avatar
Posts: 7220
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Help converting serial string generator script.

Are those Somfy with an RF remote? You should try one of the Bond Home devices and see if it can control them.

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

Posted on
Sat Nov 11, 2023 8:45 pm
brianlloyd offline
User avatar
Posts: 226
Joined: May 26, 2013
Location: San Antonio, TX, USA

Re: Help converting serial string generator script.

Well, I suppose I could get new hardware and then try to find a plug in that would work. I spent a LOT of time trying to figure out how to make them work before and finally settled on serial to the URTS-II. It has been working reliably for years with your mini-serial plug-in.

For that matter, it seems like being able to send strings over serial devices should be a core functionality of Indigo. There are still a lot of devices that are controlled by serial data over wires. There are a lot of devices that are RS485/modbus controlled.

Anyway, I just took a look at the Bond site. They don't tout Indigo support. No doubt it could be made to work but probably by the application of more effort than just making the miniserial plug-in work under Python3.

Posted on
Sat Nov 11, 2023 8:46 pm
FlyingDiver offline
User avatar
Posts: 7220
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Help converting serial string generator script.

brianlloyd wrote:
Anyway, I just took a look at the Bond site. They don't tout Indigo support. No doubt it could be made to work but probably by the application of more effort than just making the miniserial plug-in work under Python3.


I wrote a plugin for the Bond units. It's in the store. I have two of them (well, three, but only the two new Pro units in use).

Very useful device. I use it for ceiling fans, hurricane shutters, my electric fireplace, and my Christmas tree.

I'll try to find some time to take a look at the miniSerial plugin.

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

Posted on
Sun Nov 12, 2023 1:35 pm
brianlloyd offline
User avatar
Posts: 226
Joined: May 26, 2013
Location: San Antonio, TX, USA

Re: Help converting serial string generator script.

Does the Bond hub do the "stop" command for the Somfy shades/blinds? That is the critical question. If it does and there is a driver for Indigo, I could change to that.

To make the roller blinds work you need to be able to issue "up", "down", and "stop" commands. Somfy, in their infinite wisdom, decided to overload the "stop" command on their roller-blinds.. When the blinds are in transition between up and down, "stop" stops the blinds at current position. However, if the blinds are down (actually down and open) sending the "stop" command causes them to rotate to the closed position. Sending the "down" command then causes them to rotate to the open position.

Somfy's Ethernet interface does not support the "stop" command. Only the URTS-II did, which is how I got to where I am.

Posted on
Sun Nov 12, 2023 2:03 pm
FlyingDiver offline
User avatar
Posts: 7220
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Help converting serial string generator script.

The Bond is (for most devices) a learning remote. It learns the RF signal sent by the remote that came with the shades and then just re-transmits it. So if you remote has a stop button, you're good.

For some common devices, it has pre-learned codes. I just checked, and the app shows both Somfy Shades (open and close) and Blinds (open, close, tilt) commands.

I have an original (not Pro) unit I'm not using if you want to borrow it and try it out.

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

Posted on
Sun Nov 12, 2023 2:09 pm
brianlloyd offline
User avatar
Posts: 226
Joined: May 26, 2013
Location: San Antonio, TX, USA

Re: Help converting serial string generator script.

Two things:

1. The updated mini-serial plugin works. It would work for others too. That gets us back on-topic for this thread.

2. Yes, I would be interested in trying out the Bond unit. I will contact you directly by email.

Thanks Joe!

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 2 guests