Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add extended unifi device monitor to beta #79

Merged
merged 5 commits into from
Sep 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions UniFi Device Monitor/form.json
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,16 @@
"name": "DataPointHardware",
"caption": "Hardware Data"
},
{
"type": "CheckBox",
"name": "DataPointTemperature",
"caption": "Temperature Data"
},
{
"type": "CheckBox",
"name": "DataPointPower",
"caption": "Power Data"
},
{
"type": "CheckBox",
"name": "DataPointSpecific",
Expand Down
3 changes: 2 additions & 1 deletion UniFi Device Monitor/locale.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
"Wired": "Kabel",
"Basic Data": "Basisdaten",
"Hardware Data": "Hardwaredaten",
"Temperature Data": "Temperatur Daten",
"Power Data": "PoE Energie",
"Device Type": "Geräte Typ",
"Config error - device monitored is a wired device. Please select wired in the module configuration.": "Konfigurationsfehler - das überwachte Gerät ist verkabelt. Bitte dies in der Modulkonfiguration einstellen.",
"Network Data": "Netzwerkdaten",
Expand All @@ -38,7 +40,6 @@
"CPU Load": "CPU Auslastung",
"Connected Devices": "Verbundene Geräte",
"Memory Load": "Speicher Auslastung",
"Connected Devices": "Verbunde Geräte",
"WAN 1 TX Packets": "WAN 1 TX Pakete",
"WAN 1 RX Packets": "WAN 1 RX Pakete",
"WAN 1 TX Errors": "WAN 1 TX Fehler",
Expand Down
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
Loading