Skip to content

Commit

Permalink
Temp & Power added
Browse files Browse the repository at this point in the history
  • Loading branch information
elueckel authored Sep 5, 2024
1 parent d6d0479 commit b6f2fe1
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions UniFi Device Monitor/module.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);


Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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"];
Expand Down

0 comments on commit b6f2fe1

Please sign in to comment.