What is Tasmota
Tasmota is an open-source firmware for ESP devices, providing total local control with quick setup and updates. Controllable using MQTT, Web UI, HTTP or serial!
You can find their documentation for power monitoring here
Why does this matter
In this day and age, more and more companies are developing a closed ecosystem for controlling devices. And for the devices that still support local control it doesn't take much for a company to change their mind and turn off the tap. As such, it's becoming more and more popular for automaters to take matters into their own hands!
Accessing Power Monitoring Data
Via a Hub
Arguably, one of the easiest ways to monitor the power usage of a plug is via a home automation hub
like Home Assistant.
Such hubs will allow you to view control various parameters, and sensor data from your home automation devices.
Via MQTT
MQTT[^1] is the standard protocol for messaging and data exchange for the Internet of Things. It allows devices to publish messages to topics, which can then be read by subscribers.
Pro-tip - Create a consistent naming scheme for your Tasmota topics devices to prevent collisions
Eg:<room>-<device>
(livingroom-lamp
,bedroom-multisensor
)
Tasmota allows you to configure a topic that will be used for
publishing various data. For our example, the Living Room Lamp (above) has the topic of livingroom-lamp
.
This tells Tasmota to publish sensor information to the topic tele/livingroom-lamp/SENSOR
We can use a number of tools (Eg: MQTT Explorer) to see the following message being published:
{
"Time": "2022-01-11T21:57:38",
"ENERGY": {
"TotalStartTime": "2020-10-21T22:15:00",
"Total": 3.705,
"Yesterday": 0.028,
"Today": 0.026,
"Period": 1,
"Power": 5,
"ApparentPower": 5,
"ReactivePower": 0,
"Factor": 1.00,
"Voltage": 233,
"Current": 0.021
}
}
All the relevant data can be found within that JSON payload!
Via HTTP
Tasmota also exposes a basic HTTP API that can be accessed
through a simple url: http://<ip>/cm?cmnd=<command>
.
Eg:
http://<ip>/cm?cmnd=Power+Toggle
http://<ip>/cm?cmnd=FanSpeed+2
http://<ip>/cm?cmnd=Status+10
We can use that last example to retrieve the following JSON body:
{
"StatusSNS": {
"Time": "2022-01-11T22:12:32",
"ENERGY": {
"TotalStartTime": "2020-10-21T22:15:00",
"Total": 3.705,
"Yesterday": 0.028,
"Today": 0.026,
"Period": 1,
"Power": 5,
"ApparentPower": 5,
"ReactivePower": 0,
"Factor": 1.00,
"Voltage": 233,
"Current": 0.021
}
}
}
Note: The content of
StatusSNS
is identical to that plublished on the full topictele/livingroom-lamp/SENSOR