how to switch ports on a Synaccess Netbooter on and off

Posted on
Thu Oct 10, 2013 9:33 pm
kw123 offline
User avatar
Posts: 8366
Joined: May 12, 2013
Location: Dallas, TX

how to switch ports on a Synaccess Netbooter on and off

How to set ports on Synaccess netbooter (NB) switch on / off using indigo & applescript

--- for more details on the codes see: http://www.synaccess-net.com/downloadDo ... rtup-B.pdf

NB is a device that is programmable to switch 1…4 .. 8 power outlets on and off.
it can ping devices and depending on repsonse can reboot modems etc.
in addition it has a telnet and http interface that can accept commands.

This script example shows how to switch off and on individual ports using applescript issuing curl commands

Could be used in an action in a trigger that checks ping responses of internet devices

Karl

Code: Select all
-- Karl Wachs
-- 10/10/13
-- v1.0
-- applescript:

set theUserid to "xxxxx" -- your NB userID here
set thePassword to "yyyyy" -- your NB password
set IPnumber to "192.168.1.zzz" -- the NB ip number here

-- example:  switch port 1 off and then back on again, get status after every step

set ret1 to do shell script "curl -u '" & theUserid & ":" & thePassword & "' 'http://" & IPnumber & "/cmd.cgi?$A1%20" & theUserid & "%20" & thePassword & "'" -- login,  must do once
set ret2 to do shell script "curl -u '" & theUserid & ":" & thePassword & "' 'http://" & IPnumber & "/cmd.cgi?$A3%201%200'" --         --set port 1 off
set ret3 to do shell script "curl -u '" & theUserid & ":" & thePassword & "' 'http://" & IPnumber & "/cmd.cgi?$A5'" --                         -- get status
set ret4 to do shell script "curl -u '" & theUserid & ":" & thePassword & "' 'http://" & IPnumber & "/cmd.cgi?$A3%201%201'" --         --set port 1 on
set ret5 to do shell script "curl -u '" & theUserid & ":" & thePassword & "' 'http://" & IPnumber & "/cmd.cgi?$A5'" --                        --get status

-- just to do something with the return codes
display dialog ret1 & "  " & ret2 & "  " & ret3 & "  " & ret4 & "  " & ret5


--  explanation: --------------  rest are comments  -----------------
-- the first command will translate to the following shell command:
-- curl -u 'xxxxx:yyyyy' 'http://192.168.1.zzz/cmd.cgi?$A1%20xxxx%20yyyyy'

--  command should look like: $A3 Outlet on/off: 
--      switch 1  off: $A3 1 0  ==> $A3%201%200
--      switch 1  on: $A3 1 1  ==> $A3%201%201
--     replaced space (" ")  with %20
--
--
-- other commands:
-- $A1 userid password  to login, eg $A1%20UserID%20PassWord
-- $A2                        to logout,  eg $A2
-- $A3 1/2/3/4  0/1    to switch ports (1..4) on or off  ( eg "1 0"  to switch port 1 off and "2 1" to switch port 2 on)
-- $A4                        to reboot the NB
-- $A5                        to get status   just 2 digits for 2 ports either 0 or 1 for each = off or on  (00 or 01 or 10 or 11)
-- $A7 0/1                  to switch all ports off(0) or on (1)
--
-- return codes:
-- $A0 = command ok,  accepted
-- $AF = unknow command or wrong command
-- after $A3:    11 = outlet 1 and outlet 2 on
--                  10 = outlet 1 on, outlet 2 off


Page 1 of 1

Who is online

Users browsing this forum: No registered users and 22 guests