Page 2 of 3

Re: Help with JSon Somfy Command

PostPosted: Wed Jun 13, 2018 5:20 pm
by norcoscia
Thanks Jay - I know you mentioned the Control C might not be necessary I was just confirming that in case anyone else in Indigo land was going to give this a try.

I would like to capture the returned text (with the read you mentioned) but I have no idea where it will go - can I somehow vector the return string(s) into variable(s) within indigo (what happens in and behind the script execution window is 100% magic to me)...

Re: Help with JSon Somfy Command

PostPosted: Wed Jun 13, 2018 6:24 pm
by jay (support)
norcoscia wrote:
Thanks Jay - I know you mentioned the Control C might not be necessary I was just confirming that in case anyone else in Indigo land was going to give this a try.

I would like to capture the returned text (with the read you mentioned) but I have no idea where it will go - can I somehow vector the return string(s) into variable(s) within indigo (what happens in and behind the script execution window is 100% magic to me)...


I think this might be close - I'm not positive what triggers the remote side to do something. Insert the ID of a variable you want to catch the reply JSON and it'll insert it. The script could also parse the JSON and just pull out the stuff you'd be interested in, but I don't know what all the various return values could be.

Code: Select all
import telnetlib
payload = '{ "id":1, "method": "mylink.move.down", "params": { "auth": "YourSystemID", "targetID" : "AABBCC.1"} }'
tn = telnetlib.Telnet ("192.168.1.55", "44100")
# Write the JSON payload
tn.write(payload)
reply = tn.read_all()
indigo.variable.updateValue(IDOFVARIABLEHERE, value=reply)
# Close the connection
tn.close()

Re: Help with JSon Somfy Command

PostPosted: Wed Jun 13, 2018 6:30 pm
by FlyingDiver
If you're going to do a read_all(), you need to specify a timeout on the initial connection:

Code: Select all
import telnetlib
payload = '{ "id":1, "method": "mylink.move.down", "params": { "auth": "YourSystemID", "targetID" : "AABBCC.1"} }'
tn = telnetlib.Telnet ("192.168.1.55", "44100", 2)
# Write the JSON payload
tn.write(payload)
reply = tn.read_all()
indigo.variable.updateValue(IDOFVARIABLEHERE, value=reply)
# Close the connection
tn.close()


2 Seconds for the timeout is arbitrary, but will probably work fine.

https://stackoverflow.com/questions/262 ... rkinghangs

Re: Help with JSon Somfy Command

PostPosted: Thu Jun 14, 2018 6:56 am
by norcoscia
Thanks Guys - this will be very helpful with a ton of status and position messages (if I can get it to work). The up and down commands will only return the message ID number and True if it works - could be tons of other stuff if it does not.

Lots of other cool stuff in the Somfy API and JSon guide - this would make a great plug-in for indigo - wish I could code like you guys.....

Wife is still sleeping so I must type quietly :-)

Re: Help with JSon Somfy Command

PostPosted: Fri Jun 15, 2018 10:37 am
by howartp
Narcoscia, I’m following the thread and your emails and hoping to create a plugin from it.

Peter


Sent from my iPhone using Tapatalk Pro

Re: Help with JSon Somfy Command

PostPosted: Sat Jun 16, 2018 4:42 am
by norcoscia
Great, let me know if you need anything Peter, BTW the example in the API has a bracket in the wrong place - took me a while but got it working once I moved the authentication info inside the parameter.

Re: Help with JSon Somfy Command

PostPosted: Sat Jun 16, 2018 4:47 am
by howartp
See your PM’s!


Sent from my iPhone using Tapatalk Pro

Re: Help with JSon Somfy Command

PostPosted: Sat Jun 16, 2018 4:54 am
by norcoscia
Sorry I did not see the PMs - ~3:40 AM here so when my wife gets up I'll try it - thanks....

Re: Help with JSon Somfy Command

PostPosted: Sat Jun 16, 2018 7:27 am
by norcoscia
Beta plug in worked fine - up is really retract - so move.down would be extend.

There are 3 buttons on the Somfy remote - I did not see a favorite position in the API so I think sending the move.stop will send it to my stored favorite position if the shade is not moving. If it is moving sending it will stop the shade.

so for the plug-in the three to try would be

move.up (this one already works and should be called retract in the trigger to avoid confusion)
move.down (this would be extend)
move.stop (this would be the same as the my button (favorite button) on the remote.

I did not see any return values in the log and I had debug enabled - I did see all the commands in the log and at the end it said
Somfy Manager BETA Debug Read_All() timed out
Are you trying to save the return from the Mylink bridge - if so I have a variable named "SomfyReturnWord" if you want to see if it can be captured.

Thanks Peter - looking and working great so far.....

Re: Help with JSon Somfy Command

PostPosted: Sat Jun 16, 2018 3:19 pm
by howartp
Norm, try 1.0.1 on same link.

Supports up/down/stop, plus logs any responses to the log.

Can you paste me whatever responses you get so I can see how Indigo sees them.

Peter

Re: Help with JSon Somfy Command

PostPosted: Sat Jun 16, 2018 3:58 pm
by norcoscia
No longer working - I deleted the old device and trigger - created new device for mylink but could not tie it to a trigger

Created new device for the motor and that allowed me to tie a trigger to it but now when I fire the trigger the device ID is not correct in the payload -- it is putting in the IP and the extra .1 which I think is supposed to represent the channel.

Not sure what else to try...

Code: Select all
   Reloading plugin "Somfy Manager BETA 1.0.1"
   Stopping plugin "Somfy Manager BETA 1.0.1" (pid 21628)
   Stopped plugin "Somfy Manager BETA 1.0.1"
   Starting plugin "Somfy Manager BETA 1.0.1" (pid 21632)
   Started plugin "Somfy Manager BETA 1.0.1"

Jun 16, 2018, 2:47:23 PM
   SQL Logger                      creating table device_history_1203112972 for "new device"
   Somfy Manager BETA              Connecting to MyLink:  192.168.1.55
   Somfy Manager BETA Debug        <telnetlib.Telnet instance at 0x10a92bf38>

Jun 16, 2018, 2:49:00 PM
   Trigger                         Test Somfy Mylink Plug in
   Somfy Manager BETA Debug        myLinkCmdSingle action called:
   Somfy Manager BETA Debug        Target device: 192.168.1.55.1
   Somfy Manager BETA              Sending payload:  { "id":1, "method": "mylink.move.down", "params": { "auth": "XXXX", "targetID" : "192.168.1.55.1"} }
   Somfy Manager BETA Debug        Reply: {"method":"mylink.status.keepalive"}{"method":"mylink.status.keepalive"}

Re: Help with JSon Somfy Command

PostPosted: Sat Jun 16, 2018 4:07 pm
by howartp
What have you put in Somfy Motor?

AABBCC or 192.168.1.55?


Sent from my iPhone using Tapatalk Pro

Re: Help with JSon Somfy Command

PostPosted: Sat Jun 16, 2018 4:40 pm
by norcoscia
Yes, my bad - retract, extend and my favorite position working - see below for returned values? Working fantastic :-)

Code: Select all
   Somfy Manager BETA Debug        myLinkCmdSingle action called:
   Somfy Manager BETA Debug        Target device: AABBCC.1
   Somfy Manager BETA              Sending payload:  { "id":1, "method": "mylink.move.down", "params": { "auth": "XXXX", "targetID" : "AABBCC.1"} }
   Somfy Manager BETA Debug        Reply: {"method":"mylink.status.keepalive"}{"method":"mylink.status.keepalive"}

Jun 16, 2018, 3:34:35 PM
   Trigger                         Somfy Retract
   Somfy Manager BETA Debug        myLinkCmdSingle action called:
   Somfy Manager BETA Debug        Target device: AABBCC.1
   Somfy Manager BETA              Sending payload:  { "id":1, "method": "mylink.move.up", "params": { "auth": "XXXX", "targetID" : "AABBCC.1"} }
   Somfy Manager BETA Debug        Reply: {"jsonrpc":"2.0","result":true,"id":1}

Jun 16, 2018, 3:35:24 PM
   Trigger                         Somfy My postiion
   Somfy Manager BETA Debug        myLinkCmdSingle action called:
   Somfy Manager BETA Debug        Target device: AABBCC.1
   Somfy Manager BETA              Sending payload:  { "id":1, "method": "mylink.move.stop", "params": { "auth": "XXXX", "targetID" : "AABBCC.1"} }
   Somfy Manager BETA Debug        Reply: {"jsonrpc":"2.0","result":true,"id":1}{"method":"mylink.status.keepalive"}

Re: Help with JSon Somfy Command

PostPosted: Sat Jun 16, 2018 4:42 pm
by norcoscia
Tried a read - not sure what it is supposed to do - see below for log

Code: Select all
Jun 16, 2018, 3:41:34 PM
   Trigger                         Somfy Read
   Somfy Manager BETA Debug        myLinkRead action called:
   Somfy Manager BETA Debug        Reply: {"jsonrpc":"2.0","result":true,"id":1}{"method":"mylink.status.keepalive"}

Re: Help with JSon Somfy Command

PostPosted: Sat Jun 16, 2018 4:56 pm
by howartp
Great.

Read is to help me test; I’m sending Somfy commands to my 8-Port POE network switch but it’s refusing to open my curtains for me :( :)

It’s the only telnet device I have off top of my head.


Sent from my iPhone using Tapatalk Pro