r::Outlet::Common::IP::HTTP::JSON;
use strict;
use warnings;
use base qw{Power::Outlet::Common::IP::HTTP};
#use Data::Dumper qw{Dumper};
use JSON qw{encode_json decode_json};
our $VERSION = '0.50';
::HTTP::JSON - Power::Outlet base class for JSON power outlets
=head1 SYNOPSIS
use base qw{Power::Outlet::Common::IP::HTTP::JSON};
=head1 DESCRIPTION
Power::Outlet::Common::IP::HTTP::JSON is a p
d querying an JSON-based network attached power outlet.
=head1 USAGE
use base qw{Power::Outlet::Common::IP::HTTP::JSON};
=head1 PROPERTIES
=head1 METHODS
=head2 json_request
JSON HTTP request
ckage Power::Outlet::Kauf;
use strict;
use warnings;
use base qw{Power::Outlet::Common::IP::HTTP::JSON};
our $VERSION = '0.51';
=head1 NAME
Power::Outlet::Kauf - Control and query a Kauf Plug with
Floor
$ power-outlet Config ON section Kitchen
$ curl http://127.0.0.1/cgi-bin/power-outlet-json.cgi?name=Kitchen;action=ON
=head1 CONSTRUCTOR
=head2 new
my $outlet = Power::Outlet->new(typ
#get status/state
my $hash = $self->json_request($method, $url); #isa HASH
die('Error: Method _call failed to return expected JSON format') unless ref($hash) eq 'HASH';
return $
Node Red L<https://nodered.org/> can be accomplished with the included JSON web API power-outlet-json.cgi. The power-outlet-json.cgi script is a layer on top of L<Power::Outlet::Config> where the "na
s all of these devices use an http request node with a URL https://127.0.0.1/cgi-bin/power-outlet-json.cgi?name={{topic}};action={{payload}} then simply set the topic to the INI section and the action
#isa JSON Boolean
return $value ? 'ON' : 'OFF';
}
=head2 on
Sends a message to the API to turn the device relay ON
=cut
sub on {
my $self = shift;
my $state_boolean = \1; #JSON true
urn the device relay OFF
=cut
sub off {
my $self = shift;
my $state_boolean = \0; #JSON false
my $response = $self->_WebService_Tuya_IoT_API->device_command_code_value($self->dev
age Power::Outlet::Shelly;
use strict;
use warnings;
use base qw{Power::Outlet::Common::IP::HTTP::JSON};
our $VERSION = '0.50';
=head1 NAME
Power::Outlet::Shelly - Control and query a Shelly GIPO R
Floor
$ power-outlet Config ON section Kitchen
$ curl http://127.0.0.1/cgi-bin/power-outlet-json.cgi?name=Kitchen;action=ON
=head1 CONSTRUCTOR
=head2 new
my $outlet = Power::Outlet->new(typ
$url->query_form(%param);
my $hash = $self->json_request(GET => $url); #isa HASH
die('Error: Method _call failed to return expected JSON format') unless ref($hash) eq 'HASH';
return $has
e strict;
use warnings;
use Data::Dumper qw{Dumper};
use base qw{Power::Outlet::Common::IP::HTTP::JSON};
our $VERSION = '0.50';
=head1 NAME
Power::Outlet::Hue - Control and query a Philips Hue ligh
rl; #isa URI from Power::Outlet::Common::IP::HTTP
$url->path($self->_path);
my $res = $self->json_request(GET => $url); #isa perl structure
return $res->{"name"}; #isa string
}
=head1 METHODS
er::Outlet::Common::IP::HTTP
$url->path($self->_path);
#web request
my $res = $self->json_request(GET => $url); #isa perl structure
#Response is an ARRAY on error and a HASH on succe
ge Power::Outlet::Tasmota;
use strict;
use warnings;
use base qw{Power::Outlet::Common::IP::HTTP::JSON};
our $VERSION = '0.50';
=head1 NAME
Power::Outlet::Tasmota - Control and query a Tasmota GIPO
sh = $self->json_request(GET => $url); #isa HASH
#{"POWER1":"OFF"}
#{"Command":"Unknown"}
#{"WARNING":"Enter command cmnd="}
die("Error: Method _get failed to return expected JSON object") un
t::SonoffDiy;
use strict;
use warnings;
use base qw{Power::Outlet::Common::IP::HTTP::JSON};
use JSON qw{decode_json};
our $VERSION = '0.50';
=head1 NAME
Power::Outlet::SonoffDiy - Control and query
'The operation failed and the request was formatted incorrectly. The request body is not a valid JSON format.',
'401' => 'The operation failed and the request was unauthorized. D
Power::Outlet::Common::IP::HTTP
$url->path($path);
#print "$url\n";
my $hash = $self->json_request(POST => $url, $payload); #isa HASH
#{"seq":16,"error":0}
#{"seq":17,"error":0,"data":
=head1 NAME
power-outlet-json.cgi - Control Power::Outlet device with JSON web service (e.g. Node-Red)
=head1 DESCRIPTION
power-outlet-json.cgi is a CGI application to control a Power::Outlet devic
wer-outlet/power-outlet-json.cgi?name=Lamp;action=off
http://localhost/power-outlet/power-outlet-json.cgi?name=Lamp;action=on
http://localhost/power-outlet/power-outlet-json.cgi?name=Lamp;action=q
uery
http://localhost/power-outlet/power-outlet-json.cgi?name=Lamp;action=switch
Return is a JSON hash with keys status and state. status is OK if there are no errors, state is the state of the sw