Skip to content

Commit b6f2fe1

Browse files
authored
Temp & Power added
1 parent d6d0479 commit b6f2fe1

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

UniFi Device Monitor/module.php

+32
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ public function Create()
3434

3535
$this->RegisterPropertyBoolean("DataPointBasic", 1);
3636
$this->RegisterPropertyBoolean("DataPointHardware", 0);
37+
$this->RegisterPropertyBoolean("DataPointTemperature", 0);
38+
$this->RegisterPropertyBoolean("DataPointPower", 0);
3739
$this->RegisterPropertyBoolean("DataPointSpecific", 0);
3840

3941

@@ -67,6 +69,12 @@ public function ApplyChanges()
6769
$this->MaintainVariable("MemoryLoad", $this->Translate("Memory Load"), vtFloat, "", $vpos++, $this->ReadPropertyBoolean("DataPointHardware") == 1);
6870
$this->MaintainVariable("ConnectedDevices", $this->Translate("Connected Devices"), vtInteger, "", $vpos++, $this->ReadPropertyBoolean("DataPointHardware") == 1);
6971

72+
//Temperature Data
73+
$vpos = 230;
74+
$this->MaintainVariable("TotalUsedPower", $this->Translate("Total Used Power (POE)"), vtFloat, "", $vpos++, $this->ReadPropertyBoolean("DataPointPower") == 1);
75+
$this->MaintainVariable("FanLevel", $this->Translate("Fan Level"), vtInteger, "", $vpos++, $this->ReadPropertyBoolean("DataPointTemperature") == 1);
76+
$this->MaintainVariable("DeviceTemperature", $this->Translate("Device Temperature"), vtInteger, "", $vpos++, $this->ReadPropertyBoolean("DataPointTemperature") == 1);
77+
7078

7179
//Device Specific Data Connection Data UDM/USG
7280
$vpos = 300;
@@ -187,6 +195,30 @@ public function DeviceMonitor()
187195
$this->SetValue("ConnectedDevices", $ConnectedDevices);
188196
$this->SendDebug($this->Translate("Endpoint Monitor"), $this->Translate("Connected Devices ").$ConnectedDevices, 0);
189197
}
198+
if ($this->ReadPropertyBoolean("DataPointHardware") == 1)
199+
{
200+
if (isset($JSONData["data"][0]["fan_level"]))
201+
{
202+
$FanLevel = $JSONData["data"][0]["fan_level"];
203+
$this->SetValue("FanLevel", $FanLevel);
204+
$this->SendDebug($this->Translate("Device Monitor"), $this->Translate("Fan Level ").$FanLevel, 0);
205+
}
206+
if (isset($JSONData["data"][0]["general_temperature"]))
207+
{
208+
$DeviceTemp = $JSONData["data"][0]["general_temperature"];
209+
$this->SetValue("DeviceTemperature", $DeviceTemp);
210+
$this->SendDebug($this->Translate("Device Monitor"), $this->Translate("Device Temperature ").$DeviceTemp, 0);
211+
}
212+
}
213+
if ($this->ReadPropertyBoolean("DataPointPower") == 1)
214+
{
215+
if (isset($JSONData["data"][0]["total_used_power"]))
216+
{
217+
$POETotalPower = $JSONData["data"][0]["total_used_power"];
218+
$this->SetValue("TotalUsedPower", $POETotalPower);
219+
$this->SendDebug($this->Translate("Device Monitor"), $this->Translate("Total used Power ").$POETotalPower, 0);
220+
}
221+
}
190222
if ($this->ReadPropertyBoolean("DataPointSpecific") == 1 && $this->ReadPropertyInteger("DeviceType") == 0 && $DeviceConfigError == false)
191223
{
192224
$WAN1IP = $JSONData["data"][0]["wan1"]["ip"];

0 commit comments

Comments
 (0)