| 1 | package App::np05bctl; | ||
| 2 | our $VERSION = "1.04"; | ||
| 3 | |||
| 4 | =head1 NAME | ||
| 5 | |||
| 6 | np05bctl -- Command line utility for accessing the Synaccess NP-05B networked power strip | ||
| 7 | |||
| 8 | =head1 SYNOPSIS | ||
| 9 | |||
| 10 | $ np05bctl --addr=10.1.2.3 --user=bob --pass=w00t login pset 3 1 | ||
| 11 | ["login", "OK"] | ||
| 12 | ["pstat", "OK", {"1": 0, "2": 0, "3": 1, "4": 0, "5": 0}] | ||
| 13 | |||
| 14 | $ np05bctl --addr=10.1.2.3 -p stat | ||
| 15 | [ | ||
| 16 | "stat", | ||
| 17 | "OK", | ||
| 18 | { | ||
| 19 | "eth": "on", | ||
| 20 | "gw": "192.168.1.1", | ||
| 21 | "ip": "10.1.2.3", | ||
| 22 | "mac": "00:90:c2:12:34:56", | ||
| 23 | "mask": "255.255.0.0", | ||
| 24 | "model": "NP-05B", | ||
| 25 | "port_http": "80", | ||
| 26 | "port_telnet": "23", | ||
| 27 | "power_hr": { | ||
| 28 | "1": 0, | ||
| 29 | "2": 0, | ||
| 30 | "3": 1, | ||
| 31 | "4": 0, | ||
| 32 | "5": 0 | ||
| 33 | }, | ||
| 34 | "s_gw": "192.168.1.1", | ||
| 35 | "s_ip": "10.1.2.3", | ||
| 36 | "s_mask": "255.255.0.0", | ||
| 37 | "source": "static", | ||
| 38 | "src_ip": "0.0.0.0" | ||
| 39 | } | ||
| 40 | ] | ||
| 41 | |||
| 42 | =head1 DESCRIPTION | ||
| 43 | |||
| 44 | C<np05bctl> is a light wrapper around L<Device::Power::Synaccess::NP05B>, providing its functionality as a command line utility. | ||
| 45 | |||
| 46 | Please see L<Device::Power::Synaccess::NP05B> for details. | ||
| 47 | |||
| 48 | =head1 OPTIONS | ||
| 49 | |||
| 50 | -p Pretty-format json output | ||
| 51 | -q Do not print results of command to stdout | ||
| 52 | --addr=<#> Dotted IP address of NP-05B (default: 192.168.1.100) | ||
| 53 | --user=<s> Username for logging into NP-05B (default: admin) | ||
| 54 | --pass=<s> Password for logging into NP-05B (default: admin) | ||
| 55 | |||
| 56 | =head1 COMMANDS | ||
| 57 | |||
| 58 | Command results are written to stdout as JSON of one of the two formats: | ||
| 59 | |||
| 60 | [<operation>, "OK", <optional JSON object>] | ||
| 61 | [<operation>, "ERROR", <error description>] | ||
| 62 | |||
| 63 | Commands may be stacked. For instance, to authenticate and then turn on ports 3 and 4: | ||
| 64 | |||
| 65 | np05bctl login pset 3 1 pset 4 1 | ||
| 66 | ["login", "OK"] | ||
| 67 | ["pstat", "OK", {"1": 0, "2": 0, "3": 1, "4": 0, "5": 0}] | ||
| 68 | ["pstat", "OK", {"1": 0, "2": 0, "3": 1, "4": 1, "5": 0}] | ||
| 69 | |||
| 70 | =over 4 | ||
| 71 | |||
| 72 | =item login | ||
| 73 | |||
| 74 | Authenticate with the C<NP-05B>. Depending on your configuration this might not be necessary. | ||
| 75 | |||
| 76 | =item pset X Y | ||
| 77 | |||
| 78 | Turn outlet I<X> on (I<Y>=1) or off (I<Y>=2). | ||
| 79 | |||
| 80 | For the author's five-port device, the valid range for I<X> is 1..5 | ||
| 81 | |||
| 82 | =item pstat | ||
| 83 | |||
| 84 | Show which outlets are on or off. | ||
| 85 | |||
| 86 | =item stat | ||
| 87 | |||
| 88 | Dump the NP-05B's system configuration. | ||
| 89 | |||
| 90 | =back | ||
| 91 | |||
| 92 | =head1 NO WARRANTY | ||
| 93 | |||
| 94 | This software is provided "as-is," without any express or implied | ||
| 95 | warranty. In no event shall the author be held liable for any damages | ||
| 96 | arising from the use of the software. | ||
| 97 | |||
| 98 | =head1 BUGS | ||
| 99 | |||
| 100 | At the time of this writing, following C<login> with C<stat> does not work correctly. If you have configured your C<NP-05B> to allow unauthenticated commands, C<stat> without C<login> works fine. This is a fairly heinous bug and the author will be fixing it. | ||
| 101 | |||
| 102 | =head1 TO DO | ||
| 103 | |||
| 104 | Support additional features as they become implemented in L<Device::Power::Synaccess::NP05B> (also developed by this author). | ||
| 105 | |||
| 106 | =head1 AUTHOR | ||
| 107 | |||
| 108 | TTK Ciar E<lt>ttk@ciar.orgE<gt> | ||
| 109 | |||
| 110 | =head1 COPYRIGHT | ||
| 111 | |||
| 112 | Copyright (C) 2017 TTK Ciar | ||
| 113 | |||
| 114 | =head1 LICENSE | ||
| 115 | |||
| 116 | You may use and distribute this program under the same terms as Perl itself. | ||
| 117 | |||
| 118 | =cut |