NAME
Power::Outlet::Shelly - Control and query a Shelly GIPO Relay with HTTP REST API
SYNOPSIS
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";
DESCRIPTION
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
USAGE
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
CONSTRUCTOR
new
my $outlet = Power::Outlet->new(type=>"Shelly", host=>"shelly", index=>0);
my $outlet = Power::Outlet::Shelly->new(host=>"shelly", index=>0);
PROPERTIES
style
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
index
Shelly hardware supports zero or more relay indexes starting at 0.
Default: 0
host
Sets and returns the hostname or IP address.
Default: shelly
port
Sets and returns the port number.
Default: 80
METHODS
name
query
Sends an HTTP message to the device to query the current state
on
Sends a message to the device to Turn Power ON
off
Sends a message to the device to Turn Power OFF
switch
Sends a message to the device to toggle the power
cycle
Sends messages to the device to Cycle Power (ON-OFF-ON or OFF-ON-OFF).
cycle_duration
Default; 10 seconds (floating point number)
BUGS
Please log on RT and send an email to the author.
SUPPORT
DavisNetworks.com supports all Perl applications including this package.
AUTHOR
Michael R. Davis
CPAN ID: MRDVT
DavisNetworks.com
COPYRIGHT
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.