From b6f2fe1b2fd28ef94ea008a3479fdf4a8f28c5f0 Mon Sep 17 00:00:00 2001 From: elueckel <30531515+elueckel@users.noreply.github.com> Date: Thu, 5 Sep 2024 20:42:51 +0200 Subject: [PATCH] Temp & Power added --- UniFi Device Monitor/module.php | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/UniFi Device Monitor/module.php b/UniFi Device Monitor/module.php index 94643a4..e6546f2 100644 --- a/UniFi Device Monitor/module.php +++ b/UniFi Device Monitor/module.php @@ -34,6 +34,8 @@ public function Create() $this->RegisterPropertyBoolean("DataPointBasic", 1); $this->RegisterPropertyBoolean("DataPointHardware", 0); + $this->RegisterPropertyBoolean("DataPointTemperature", 0); + $this->RegisterPropertyBoolean("DataPointPower", 0); $this->RegisterPropertyBoolean("DataPointSpecific", 0); @@ -67,6 +69,12 @@ public function ApplyChanges() $this->MaintainVariable("MemoryLoad", $this->Translate("Memory Load"), vtFloat, "", $vpos++, $this->ReadPropertyBoolean("DataPointHardware") == 1); $this->MaintainVariable("ConnectedDevices", $this->Translate("Connected Devices"), vtInteger, "", $vpos++, $this->ReadPropertyBoolean("DataPointHardware") == 1); + //Temperature Data + $vpos = 230; + $this->MaintainVariable("TotalUsedPower", $this->Translate("Total Used Power (POE)"), vtFloat, "", $vpos++, $this->ReadPropertyBoolean("DataPointPower") == 1); + $this->MaintainVariable("FanLevel", $this->Translate("Fan Level"), vtInteger, "", $vpos++, $this->ReadPropertyBoolean("DataPointTemperature") == 1); + $this->MaintainVariable("DeviceTemperature", $this->Translate("Device Temperature"), vtInteger, "", $vpos++, $this->ReadPropertyBoolean("DataPointTemperature") == 1); + //Device Specific Data Connection Data UDM/USG $vpos = 300; @@ -187,6 +195,30 @@ public function DeviceMonitor() $this->SetValue("ConnectedDevices", $ConnectedDevices); $this->SendDebug($this->Translate("Endpoint Monitor"), $this->Translate("Connected Devices ").$ConnectedDevices, 0); } + if ($this->ReadPropertyBoolean("DataPointHardware") == 1) + { + if (isset($JSONData["data"][0]["fan_level"])) + { + $FanLevel = $JSONData["data"][0]["fan_level"]; + $this->SetValue("FanLevel", $FanLevel); + $this->SendDebug($this->Translate("Device Monitor"), $this->Translate("Fan Level ").$FanLevel, 0); + } + if (isset($JSONData["data"][0]["general_temperature"])) + { + $DeviceTemp = $JSONData["data"][0]["general_temperature"]; + $this->SetValue("DeviceTemperature", $DeviceTemp); + $this->SendDebug($this->Translate("Device Monitor"), $this->Translate("Device Temperature ").$DeviceTemp, 0); + } + } + if ($this->ReadPropertyBoolean("DataPointPower") == 1) + { + if (isset($JSONData["data"][0]["total_used_power"])) + { + $POETotalPower = $JSONData["data"][0]["total_used_power"]; + $this->SetValue("TotalUsedPower", $POETotalPower); + $this->SendDebug($this->Translate("Device Monitor"), $this->Translate("Total used Power ").$POETotalPower, 0); + } + } if ($this->ReadPropertyBoolean("DataPointSpecific") == 1 && $this->ReadPropertyInteger("DeviceType") == 0 && $DeviceConfigError == false) { $WAN1IP = $JSONData["data"][0]["wan1"]["ip"];