Power::Outlet::Tasmota - Control and query a Tasmota GIPO configured as a Relay (Switch or Button)
my $outlet = Power::Outlet::Tasmota->new(host => "tasmota", relay => "POWER1"); print $outlet->query, "\n"; print $outlet->on, "\n"; print $outlet->off, "\n";
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"}
use Power::Outlet::Tasmota; my $relay = Power::Outlet::Tasmota->new(host=>"tasmota", relay=>"POWER2"); print $relay->on, "\n";
my $outlet = Power::Outlet->new(type=>"Tasmota", host=>"tasmota", relay=>"POWER2"); my $outlet = Power::Outlet::Tasmota->new(host=>"tasmota", relay=>"POWER2");
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
Sets and returns the hostname or IP address.
Default: tasmota
Sets and returns the port number.
Default: 80
Sets and returns the http_path.
Default: /cm
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
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
Returns the FriendlyName from the Tasmota hardware.
Note: The FriendlyName is cached for the life of the object.
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).
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://tasmota.github.io/docs/#/Commands
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.