Power::Outlet::Shelly - Control and query a Shelly GIPO Relay with HTTP REST API
my $outlet = Power::Outlet::Shelly->new(host=>"shelly", index=>0); print $outlet->query, "\n"; print $outlet->on, "\n"; print $outlet->off, "\n"; print $outlet->switch, "\n"; print $outlet->cycle, "\n";
Power::Outlet::Shelly is a package for controlling and querying a relay index on Shelly hardware.
From: https://shelly-api-docs.shelly.cloud/
Commands can be executed via web (HTTP) requests, for example:
http://<ip>/relay/0?turn=on http://<ip>/relay/0?turn=off http://<ip>/relay/0?turn=toggle http://<ip>/relay/0?timer=5
use Power::Outlet::Shelly; my $outlet = Power::Outlet::Shelly->new(host=>"sw-kitchen", style=>"relay", index=>0); print $outlet->on, "\n";
Command Line
$ power-outlet Shelly ON host sw-kitchen style relay index 0
Command Line (from settings)
$ cat /etc/power-outlet.ini [Kitchen] type=Shelly name=Kitchen host=sw-kitchen style=relay index=0 groups=Inside Lights groups=Main Floor $ power-outlet Config ON section Kitchen $ curl http://127.0.0.1/cgi-bin/power-outlet-json.cgi?name=Kitchen;action=ON
my $outlet = Power::Outlet->new(type=>"Shelly", host=>"shelly", index=>0); my $outlet = Power::Outlet::Shelly->new(host=>"shelly", index=>0);
Set the style to support "relay" (1, 1L, 2.5, 4, Plug, Uni, EM, 3EM), "light" (Dimmer, Bulb, Vintage, Duo), "color" (RGB Color), or "white" (RGB White)
my $style = $outlet->style; my $style = $outlet->style('light');
default: relay
Shelly hardware supports zero or more relay indexes starting at 0.
Default: 0
Sets and returns the hostname or IP address.
Default: shelly
Sets and returns the port number.
Default: 80
Sends an HTTP message to the device to query the current state
Sends a message to the device to Turn Power ON
Sends a message to the device to Turn Power OFF
Sends a message to the device to toggle the power
Sends messages to the device to Cycle Power (ON-OFF-ON or OFF-ON-OFF).
Default; 10 seconds (floating point number)
Please log on RT and send an email to the author.
DavisNetworks.com supports all Perl applications including this package.
Michael R. Davis CPAN ID: MRDVT DavisNetworks.com
Copyright (c) 2020 Michael R. Davis
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
The full text of the license can be found in the LICENSE file included with this module.
https://shelly-api-docs.shelly.cloud/
To install Power::Outlet, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Power::Outlet
CPAN shell
perl -MCPAN -e shell install Power::Outlet
For more information on module installation, please visit the detailed CPAN module installation guide.