Jump to content

[PLUGIN] Tasmota Power Monitor


Recommended Posts

  • 5 weeks later...
  • 1 month later...
  • 3 weeks later...
  • 2 weeks later...
47 minutes ago, maTTi said:

What total field refers to? It is from the start of the plugin or monthly? 

The reading come from tasmota device. It is accumulated energy usage from last reset, you can reset it under device web console anytime.

Edited by Vr2Io
  • Thanks 1
Link to comment
  • 1 month later...
  • 1 month later...
On 3/23/2021 at 12:04 AM, Flippo said:

Hi guys,

 

I want to introduce you to my Tasmota Power Monitor.

 

With this UnRaid plugin you can turn a Tasmota device into an energy monitor for your server.

I got the idea from corsairpsu-unraid, but since I don't have a suitable Corsair PSU, I found an alternative in a Tasmota Power Plug.

 

It shows the most common measured values and offers the option of costing for electricity consumption.

 

Dashboard:

grafik.png.c93a5b683b5f81032d83b20382f26aac.png

 

Settings:

grafik.png.a3170d5d1f22a5012fa7d8781cbb7ee2.png

The password is saved in plain text.

 

Introduction

Before you start, be sure that you protect your Tasmota device against incorrect operation. So that you don't accidentally turn off your server. I solved this for myself with the command: PowerOnState 4 This sets the on / off switch in the WebUI and on the device to always on. Therefore, check what would be best for your device before using it. Have a look at the Tasmota Documentation. Use the plugin and device at your own risk. I will not be responsible for any damage.

 

I use an Aisirer Power Monitoring Plug (AWP07L) with Tasmota firmware 8.5.1 and this template. {"NAME":"AWP07L","GPIO":[56,255,255,255,255,134,255,255,131,17,132,21,255],"FLAG":0,"BASE":18}

 

 

Created and tested with Unraid 6.9.1.

 

Installation as usual...

https://raw.githubusercontent.com/Flippo24/tasmotapm-unraid/main/tasmotapm.plg

 

Thank you for this nice plugin @Flippo.

I saw that you have also created a plugin for espurna.

I use home assistant and my energy meter plug is flashed with esphome.

 

Would be great I you could also write an unraid plugin for esphome 😃

Edited by ElVit
Link to comment

I have no experience with unraid plugin development.

But I think the file "status.php" should look something like this for EspHome:

 

<?php
$esphomepm_cfg = parse_ini_file( "/boot/config/plugins/esphomepm/esphomepm.cfg" );
$esphomepm_device_ip = isset($esphomepm_cfg['DEVICE_IP']) ? $esphomepm_cfg['DEVICE_IP'] : "";
$esphomepm_device_user = isset($esphomepm_cfg['DEVICE_USER']) ? $esphomepm_cfg['DEVICE_USER'] : "";
$esphomepm_device_pass = isset($esphomepm_cfg['DEVICE_PASS']) ? $esphomepm_cfg['DEVICE_PASS'] : "";
$esphomepm_costs_price = isset($esphomepm_cfg['COSTS_PRICE']) ? $esphomepm_cfg['COSTS_PRICE'] : "0.0";
$esphomepm_costs_unit = isset($esphomepm_cfg['COSTS_UNIT']) ? $esphomepm_cfg['COSTS_UNIT'] : "USD";

if ($esphomepm_device_ip == "") {
	die("esphome Device IP missing!");
}
if ($esphomepm_device_user == "") {
	die("esphome username missing!");
}
if ($esphomepm_device_pass == "") {
	die("esphome password missing!");
}

$json = array(
	'Power' => getvalue($esphomepm_device_ip,"power",$esphomepm_device_user, $esphomepm_device_pass),
	'Voltage' => getvalue($esphomepm_device_ip,"voltage",$esphomepm_device_user, $esphomepm_device_pass),
	'Current' => getvalue($esphomepm_device_ip,"current",$esphomepm_device_user, $esphomepm_device_pass),
	'Factor' => getvalue($esphomepm_device_ip,"factor",$esphomepm_device_user, $esphomepm_device_pass),
	'Energy' => getvalue($esphomepm_device_ip,"energy",$esphomepm_device_user, $esphomepm_device_pass),
	'ApparentPower' => getvalue($esphomepm_device_ip,"apparent",$esphomepm_device_user, $esphomepm_device_pass),
	'ReactivePower' => getvalue($esphomepm_device_ip,"reactive",$esphomepm_device_user, $esphomepm_device_pass),
	'Costs_Price' => $esphomepm_costs_price,
	'Costs_Unit' => $esphomepm_costs_unit
);

//header('Content-Type: application/json');
echo json_encode($json);

function getvalue($ip, $param, $username, $password) {
	$Url = "http://" . $ip . "/sensor/" . $param;
	$curl = curl_init($Url);
	curl_setopt($curl, CURLOPT_FAILONERROR, true);
	curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
	curl_setopt($curl, CURLOPT_HTTPGET, true);
	curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
	curl_setopt($curl, CURLOPT_USERPWD, $username . ":" . $password);
	curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
	$resultJson = curl_exec($curl);
	curl_close($curl);

	$resultObj = json_decode($resultJson, true);
	$value = $resultObj->{'value'};
	$value = isset($value) ? $value : "0";
	return $value;
}

?>

 

Link to comment
  • 3 weeks later...

Has anyone had any luck using this plugin with a plug flashed with OpenBK? After a bit of tweaking I've managed to pull live power usage from the plug, but I can't get Unraid to pull energy history even though it's reported via the plug GUI:

 

Screenshot2024-07-18at11_48_54.png.0374a13f85b00dcbe17677f083c2c353.png

(the 1.5W is probably accurate - the plug is currently not supplying my server, there's just a USB thingy plugged into it)

 

Screenshot2024-07-18at11_45_55.png.e43904e2e8d8233465957eafcb404800.png

 

Just to clarify: I have no idea what I'm doing here. Tasmota and its forks seem to be a massive and technical black hole.

 

Edited by Fozzuk
Link to comment
On 7/18/2024 at 12:56 PM, Fozzuk said:

Has anyone had any luck using this plugin with a plug flashed with OpenBK? After a bit of tweaking I've managed to pull live power usage from the plug, but I can't get Unraid to pull energy history even though it's reported via the plug GUI:

 

Screenshot2024-07-18at11_48_54.png.0374a13f85b00dcbe17677f083c2c353.png

(the 1.5W is probably accurate - the plug is currently not supplying my server, there's just a USB thingy plugged into it)

 

Screenshot2024-07-18at11_45_55.png.e43904e2e8d8233465957eafcb404800.png

 

Just to clarify: I have no idea what I'm doing here. Tasmota and its forks seem to be a massive and technical black hole.

 

 

I have 2 Smart Plugs lying around here, 1 Tasmota and 1 OpenBeken flashed on.

Here are the outputs if put

http://IP_OF_YOUR_DEVICE/cm?cmnd=Status%208

in the browser:

 

OpenBeken:
{
  "StatusSNS": {
    "Time": "2024-07-19T14:33:13",
    "ENERGY": {
      "Power": 12.699999,
      "ApparentPower": 12607.089843,
      "ReactivePower": 12607.083984,
      "Factor": 0.001007,
      "Voltage": 233.464630,
      "Current": 54.000000,
      "ConsumptionTotal": 483.106109,
      "Yesterday": 482.320281,
      "ConsumptionLastHour": 0.004588
    }
  }
}

Tasmota:
{
  "StatusSNS": {
    "Time": "2024-07-19T15:32:08",
    "ENERGY": {
      "TotalStartTime": "2024-07-19T14:34:49",
      "Total": 0.001,
      "Yesterday": 0.000,
      "Today": 0.001,
      "Power": 13,
      "ApparentPower": 13,
      "ReactivePower": 0,
      "Factor": 1.00,
      "Voltage": 233,
      "Current": 0.054
    }
  }
}

 

As you can see some values are not matching.

For me the OpenBeken Plug does not work at all with this Unraid Plugin...

 

grafik.png.be20372222bafc17cab05fa2d70792de.png

 

But the Tasmota Plug is working 😃

Edited by ElVit
Link to comment
  • 2 weeks later...
  • 2 weeks later...

Hi,

 

I have not read the whole thread and also find nothing to this in the internet.

 

Can I change the description of the block in the dashboard and could I display a second device/box there?

For example instead of "Tasmota Power Monitor" , "Starlink" or network.

And can I translate the measurements description to German anywhere?

Screenshot_20240811-184347.png

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...