NAME
Power::Outlet::Tasmota - Control and query a Tasmota GIPO configured as a Relay (Switch or Button)
SYNOPSIS
my $outlet = Power::Outlet::Tasmota->new(host => "tasmota", relay => "POWER1");
print $outlet->query, "\n";
print $outlet->on, "\n";
print $outlet->off, "\n";
DESCRIPTION
Power::Outlet::Tasmota is a package for controlling and querying a relay on Tasmota ESP8266 hardware.
From: https://tasmota.github.io/docs/#/Commands
Commands can be executed via web (HTTP) requests, for example:
http://<ip>/cm?cmnd=Power%20TOGGLE
http://<ip>/cm?cmnd=Power%20On
http://<ip>/cm?cmnd=Power%20off
http://<ip>/cm?user=admin&password=joker&cmnd=Power%20Toggle
Examples:
Query default relay
$ curl http://tasmota/cm?cmnd=POWER1
{"POWER1":"ON"}
Toggle (Switch) relay 4
$ curl http://tasmota/cm?user=foo;password=bar;cmnd=POWER4+TOGGLE
{"POWER4":"OFF"}
Turn ON relay 2
$ curl http://tasmota/cm?user=foo;password=bar;cmnd=POWER2+ON
{"POWER2":"ON"}
USAGE
use Power::Outlet::Tasmota;
my $relay = Power::Outlet::Tasmota->new(host=>"tasmota", relay=>"POWER2");
print $relay->on, "\n";
CONSTRUCTOR
new
my $outlet = Power::Outlet->new(type=>"Tasmota", host=>"tasmota", relay=>"POWER2");
my $outlet = Power::Outlet::Tasmota->new(host=>"tasmota", relay=>"POWER2");
PROPERTIES
relay
Tasmota version 8.1.0 supports up to 8 relays. These 8 relays map to the relay tokens "POWER1", "POWER2", ... "POWER8". With "POWER" being the default relay name for the first relay defined in the configuration.
Default: POWER1
host
Sets and returns the hostname or IP address.
Default: tasmota
port
Sets and returns the port number.
Default: 80
http_path
Sets and returns the http_path.
Default: /cm
user
Sets and returns the user used for authentication with the Tasmota hardware
my $outlet = Power::Outlet::Tasmota->new(host=>"tasmota", relay=>"POWER1", user=>"mylogin", password=>"mypassword");
print $outlet->query, "\n";
Default: undef() #which is only passed on the url when defined
password
Sets and returns the password used for authentication with the Tasmota hardware
Default: "" #which is only passed on the url when user property is defined
METHODS
name
Returns the FriendlyName from the Tasmota hardware.
Note: The FriendlyName is cached for the life of the object.
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).
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.