NAME
Power::Outlet::Kauf - Control and query a Kauf Plug with HTTP REST API
SYNOPSIS
my $outlet = Power::Outlet::Kauf->new(host=>"my_kauf_plug");
print $outlet->query, "\n";
print $outlet->on, "\n";
print $outlet->off, "\n";
print $outlet->switch, "\n";
print $outlet->cycle, "\n";
DESCRIPTION
Power::Outlet::Kauf is a package for controlling and querying a Kauf Plug.
From: https://github.com/KaufHA/common/ and https://github.com/hightowe/control_outdoor_lighting-pl
Commands can be executed via web (HTTP) requests, for example:
POST http://10.10.10.39/switch/kauf_plug/turn_off => status 200
POST http://10.10.10.39/switch/kauf_plug/turn_on => status 200
GET http://10.10.10.39/switch/kauf_plug => {"id":"plug name","value":true,"state":"ON"}
USAGE
use Power::Outlet::Kauf;
my $outlet = Power::Outlet::Kauf->new(host=>"sw-kitchen");
print $outlet->on, "\n";
Command Line
$ power-outlet Kauf ON host sw-kitchen
Command Line (from settings)
$ cat /etc/power-outlet.ini
[Kitchen]
type=Kauf
name=Kitchen
host=sw-kitchen
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=>"Kauf", host=>"my_kauf_plug");
my $outlet = Power::Outlet::Kauf->new(host=>"my_kauf_plug");
PROPERTIES
host
Sets and returns the hostname or IP address.
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)
COPYRIGHT & LICENSE
Copyright (c) 2025 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.