Skip to content

Commit

Permalink
Merge pull request #80 from elueckel/beta
Browse files Browse the repository at this point in the history
Merge Beta to Main
  • Loading branch information
elueckel authored Sep 8, 2024
2 parents c2a1bdf + aa4f9d8 commit f27f27a
Show file tree
Hide file tree
Showing 19 changed files with 202 additions and 92 deletions.
Binary file modified .DS_Store
Binary file not shown.
5 changes: 4 additions & 1 deletion UniFi Device Monitor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,4 +95,7 @@ Version 1.3 - 03-01-2022
* Neu - Unifi API Zugriff in eigene Funktion ausgelagert (bessere Wartbarkeit)

Version 1.5 - 03-12-2023
* Neu - UI Aufgeräumt
* Neu - UI Aufgeräumt

Version 1.6 - 25-08-2024
* Neu - Anzahl der verbundenen Geräte wird angezeigt
6 changes: 5 additions & 1 deletion UniFi Device Monitor/README_en.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,8 @@ Version 1.3 - 03-01-2022
* New - Unifi API access moved to its own function (better maintainability)

Version 1.5 - 03-12-2023
* New - UI tidied up
* New - UI tidied up

Version 1.6 - 01-09-2024
* New - Number of connected devices are shown
* Change - SetValue replaced by $this->SetValue
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: 3 additions & 0 deletions 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 @@ -36,6 +38,7 @@
"Device Model": "Geräte Typ",
"Device Name": "Geräte Name",
"CPU Load": "CPU Auslastung",
"Connected Devices": "Verbundene Geräte",
"Memory Load": "Speicher Auslastung",
"WAN 1 TX Packets": "WAN 1 TX Pakete",
"WAN 1 RX Packets": "WAN 1 RX Pakete",
Expand Down
64 changes: 50 additions & 14 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 @@ -65,6 +67,13 @@ public function ApplyChanges()
$vpos = 200;
$this->MaintainVariable("CPULoad", $this->Translate("CPU Load"), vtFloat, "", $vpos++, $this->ReadPropertyBoolean("DataPointHardware") == 1);
$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
Expand Down Expand Up @@ -153,59 +162,86 @@ public function DeviceMonitor()
if ($this->ReadPropertyBoolean("DataPointBasic") == 1)
{
$DeviceModel = $JSONData["data"][0]["model"];
SetValue($this->GetIDForIdent("DeviceModel"), $DeviceModel);
$this->SetValue("DeviceModel", $DeviceModel);
$this->SendDebug($this->Translate("Device Monitor"), $this->Translate("Device Model ").$DeviceModel, 0);
$SoftwareVersion = $JSONData["data"][0]["version"];
SetValue($this->GetIDForIdent("SoftwareVersion"), $SoftwareVersion);
$this->SetValue("SoftwareVersion", $SoftwareVersion);
$this->SendDebug($this->Translate("Device Monitor"), $this->Translate("Software Version ").$SoftwareVersion, 0);
//$Satisfaction = $JSONData["data"][0]["satisfaction"];
//SetValue($this->GetIDForIdent("Satisfaction"),$Satisfaction);
//$this->SendDebug($this->Translate("Device Monitor"),$this->Translate("Device Satisfaction ").$Satisfaction,0);
$SLastSeen = $JSONData["data"][0]["last_seen"];
SetValue($this->GetIDForIdent("LastSeen"), gmdate("Y-m-d H:i:s", $SLastSeen));
$this->SetValue("LastSeen", gmdate("Y-m-d H:i:s", $SLastSeen));
$this->SendDebug($this->Translate("Device Monitor"), $this->Translate("Connection Data Last Seen ").gmdate("Y-m-d H:i:s", $SLastSeen), 0);
$Uptime = $JSONData["data"][0]["uptime"];
SetValue($this->GetIDForIdent("Uptime"), round($Uptime / 3600, 0));
$this->SetValue("Uptime", round($Uptime / 3600, 0));
$this->SendDebug($this->Translate("Device Monitor"), $this->Translate("Connection Data Uptime in hours ").round($Uptime / 3600, 0), 0);
if (isset($JSONData["data"][0]["name"]))
{
$Name = $JSONData["data"][0]["name"];
SetValue($this->GetIDForIdent("Name"), $Name);
$this->SetValue("Name", $Name);
$this->SendDebug($this->Translate("Device Monitor"), $this->Translate("Devicename ").$Name, 0);
}
}
if ($this->ReadPropertyBoolean("DataPointHardware") == 1)
{
$CPULoad = $JSONData["data"][0]["system-stats"]["cpu"];
SetValue($this->GetIDForIdent("CPULoad"), $CPULoad);
$this->SetValue("CPULoad", $CPULoad);
$this->SendDebug($this->Translate("Device Monitor"), $this->Translate("CPU Load ").$CPULoad, 0);
$MemoryLoad = $JSONData["data"][0]["system-stats"]["mem"];
SetValue($this->GetIDForIdent("MemoryLoad"), $MemoryLoad);
$this->SetValue("MemoryLoad", $MemoryLoad);
$this->SendDebug($this->Translate("Device Monitor"), $this->Translate("Memory Load ").$MemoryLoad, 0);
$ConnectedDevices = $JSONData["data"][0]["num_sta"];
$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"];
SetValue($this->GetIDForIdent("WAN1IP"), $WAN1IP);
$this->SetValue("WAN1IP", $WAN1IP);
$this->SendDebug($this->Translate("Device Monitor"), $this->Translate("Connection Data WAN 1 IP ").$WAN1IP, 0);

$WAN1TXBytes = $JSONData["data"][0]["wan1"]["tx_bytes"];
SetValue($this->GetIDForIdent("WAN1TXBytes"), $WAN1TXBytes / 1000000);
$this->SetValue("WAN1TXBytes", $WAN1TXBytes / 1000000);
$this->SendDebug($this->Translate("Device Monitor"), $this->Translate("Transfer Data WAN 1 TX Bytes ").$WAN1TXBytes, 0);
$WAN1RXBytes = $JSONData["data"][0]["wan1"]["rx_bytes"];
SetValue($this->GetIDForIdent("WAN1RXBytes"), $WAN1RXBytes / 1000000);
$this->SetValue("WAN1RXBytes", $WAN1RXBytes / 1000000);
$this->SendDebug($this->Translate("Endpoint Monitor"), $this->Translate("Transfer Data WAN 1 RX Bytes ").$WAN1RXBytes, 0);
$WAN1TXPackets = $JSONData["data"][0]["wan1"]["tx_packets"];
SetValue($this->GetIDForIdent("WAN1TXPackets"), $WAN1TXPackets);
$this->SetValue("WAN1TXPackets", $WAN1TXPackets);
$this->SendDebug($this->Translate("Device Monitor"), $this->Translate("Transfer Data WAN 1 TX Packets ").$WAN1TXPackets, 0);
$WAN1RXPackets = $JSONData["data"][0]["wan1"]["tx_packets"];
SetValue($this->GetIDForIdent("WAN1RXPackets"), $WAN1RXPackets);
$this->SetValue("WAN1RXPackets", $WAN1RXPackets);
$this->SendDebug($this->Translate("Device Monitor"), $this->Translate("Transfer Data WAN 1 RXPackets ").$WAN1RXPackets, 0);
$WAN1TXErrors = $JSONData["data"][0]["wan1"]["tx_errors"];
SetValue($this->GetIDForIdent("WAN1TXErrors"), $WAN1TXErrors);
$this->SetValue("WAN1TXErrors", $WAN1TXErrors);
$this->SendDebug($this->Translate("Device Monitor"), $this->Translate("Transfer Data WAN 1 TX Errors ").$WAN1TXErrors, 0);
$WAN1RXErrors = $JSONData["data"][0]["wan1"]["rx_errors"];
SetValue($this->GetIDForIdent("WAN1RXErrors"), $WAN1RXErrors);
$this->SetValue("WAN1RXErrors", $WAN1RXErrors);
$this->SendDebug($this->Translate("Device Monitor"), $this->Translate("Transfer Data WAN 1 RX Errors ").$WAN1RXErrors, 0);
}
}
Expand Down
3 changes: 3 additions & 0 deletions UniFi Endpoint Blocker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,6 @@ Version 1.3 - 03-01-2022

Version 1.5 - 03-12-2023
* Neu - UI Aufgeräumt

Version 1.6 - 25-08-2024
* Keine Änderungen
5 changes: 4 additions & 1 deletion UniFi Endpoint Blocker/README_en.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,4 +109,7 @@ Version 1.3 - 03-01-2022
* New - Device Blocker is now called Endpoint Blocker

Version 1.5 - 03-12-2023
* New - UI tidied up
* New - UI tidied up

Version 1.6 - 25-08-2024
* No changes
2 changes: 1 addition & 1 deletion UniFi Endpoint Blocker/module.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public function ApplyChanges()
$this->RegisterVariableBoolean($DeviceMacClean, $DeviceName, "~Switch");
$DeviceMacCleanID = @IPS_GetObjectIDByIdent($DeviceMacClean, $this->InstanceID);

SetValue($DeviceMacCleanID, true);
$this->SetValue($DeviceMacCleanID, true);
IPS_Sleep(1000);
$this->EnableAction($DeviceMacClean);
$this->RegisterMessage($DeviceMacCleanID, VM_UPDATE);
Expand Down
38 changes: 19 additions & 19 deletions UniFi Endpoint Monitor/module.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public function ApplyChanges()
$this->MaintainVariable("RSSI", $this->Translate("RSSI"), vtInteger, "", $vpos++, $this->ReadPropertyBoolean("DataPointConnection") == 1 && $this->ReadPropertyInteger("ConnectionType") == 0);
$this->MaintainVariable("Noise", $this->Translate("Noise"), vtInteger, "", $vpos++, $this->ReadPropertyBoolean("DataPointConnection") == 1 && $this->ReadPropertyInteger("ConnectionType") == 0);
$this->MaintainVariable("SignalStrength", $this->Translate("Signal Strength"), vtInteger, "", $vpos++, $this->ReadPropertyBoolean("DataPointConnection") == 1 && $this->ReadPropertyInteger("ConnectionType") == 0);

//Transfer Data
$vpos = 300;
$this->MaintainVariable("TXBytes", $this->Translate("TX Megabytes"), vtInteger, "", $vpos++, $this->ReadPropertyBoolean("DataPointTransfer") == 1 && $this->ReadPropertyInteger("ConnectionType") == 0);
Expand Down Expand Up @@ -175,7 +175,7 @@ public function EndpointMonitor()
//after a device gets reconnected, wait until the controller has rebuilt the data set
$this->SendDebug($this->Translate("Endpoint Monitor"), $this->Translate("Device was disconnected and is now connected again. Module waits for Controller to collect data."), 0);
IPS_Sleep(10000);
SetValue($this->GetIDForIdent("Connected"), true);
$this->SetValue("Connected", true);
$RawData = $this->getRawData($Cookie, $ServerAddress, $ServerPort, $UnifiAPI, $ControllerType);
$JSONData = json_decode($RawData, true);
}
Expand All @@ -195,7 +195,7 @@ public function EndpointMonitor()
if ($this->ReadPropertyBoolean("DataPointNetwork") == 1)
{
$IPAddress = $JSONData["data"][0]["ip"];
SetValue($this->GetIDForIdent("IPAddress"), $IPAddress);
$this->SetValue("IPAddress", $IPAddress);
$this->SendDebug($this->Translate("Endpoint Monitor"), $this->Translate("Network Data IP ").$IPAddress, 0);

if ("" != $JSONData["data"][0]["hostname"])
Expand All @@ -210,7 +210,7 @@ public function EndpointMonitor()
{
$Hostname = "";
}
SetValue($this->GetIDForIdent("Hostname"), $Hostname);
$this->SetValue("Hostname", $Hostname);
$this->SendDebug($this->Translate("Endpoint Monitor"), $this->Translate("Network Data Hostname ").$Hostname, 0);
//$Name = $JSONData["data"][0]["name"];
//SetValue($this->GetIDForIdent("Name"),$Name);
Expand All @@ -220,60 +220,60 @@ public function EndpointMonitor()
{
if (isset($JSONData["data"][0]["satisfaction"])) {
$Satisfaction = isset($JSONData["data"][0]["satisfaction"]);
SetValue($this->GetIDForIdent("Satisfaction"), $Satisfaction);
$this->SetValue("Satisfaction", $Satisfaction);
}
$this->SendDebug($this->Translate("Endpoint Monitor"), $this->Translate("Connection Data Satisfaction ").$Satisfaction, 0);
$SLastSeen = $JSONData["data"][0]["last_seen"];
SetValue($this->GetIDForIdent("LastSeen"), gmdate("Y-m-d H:i:s", $SLastSeen));
$this->SetValue("LastSeen", gmdate("Y-m-d H:i:s", $SLastSeen));
$this->SendDebug($this->Translate("Endpoint Monitor"), $this->Translate("Connection Data Last Seen ").gmdate("Y-m-d H:i:s", $SLastSeen), 0);
$Uptime = $JSONData["data"][0]["uptime"];
SetValue($this->GetIDForIdent("Uptime"), round($Uptime / 3600, 0));
$this->SetValue("Uptime", round($Uptime / 3600, 0));
$this->SendDebug($this->Translate("Endpoint Monitor"), $this->Translate("Connection Data Uptime in hours ").round($Uptime / 3600, 0), 0);
}
if ($this->ReadPropertyBoolean("DataPointConnection") == 1 && $this->ReadPropertyInteger("ConnectionType") == 0 && $ConnectionConfigError == false)
{
$Accesspoint = $JSONData["data"][0]["ap_mac"];
SetValue($this->GetIDForIdent("Accesspoint"), $Accesspoint);
$this->SetValue("Accesspoint", $Accesspoint);
$this->SendDebug($this->Translate("Endpoint Monitor"), $this->Translate("Connection Data Accesspoint ").$Accesspoint, 0);
$Channel = $JSONData["data"][0]["channel"];
SetValue($this->GetIDForIdent("Channel"), $Channel);
$this->SetValue("Channel", $Channel);
$this->SendDebug($this->Translate("Endpoint Monitor"), $this->Translate("Connection Data Channel ").$Channel, 0);
$Radio = $JSONData["data"][0]["radio"];
SetValue($this->GetIDForIdent("Radio"), $Radio);
$this->SetValue("Radio", $Radio);
$this->SendDebug($this->Translate("Endpoint Monitor"), $this->Translate("Connection Data Radio ").$Radio, 0);
$ESSID = $JSONData["data"][0]["essid"];
SetValue($this->GetIDForIdent("ESSID"), $ESSID);
$this->SetValue("ESSID", $ESSID);
$this->SendDebug($this->Translate("Endpoint Monitor"), $this->Translate("Connection Data ESSID ").$ESSID, 0);
$RSSI = $JSONData["data"][0]["rssi"];
SetValue($this->GetIDForIdent("RSSI"), $RSSI);
$this->SetValue("RSSI", $RSSI);
$this->SendDebug($this->Translate("Endpoint Monitor"), $this->Translate("Connection Data RSSI ").$RSSI, 0);
$Noise = $JSONData["data"][0]["noise"];
SetValue($this->GetIDForIdent("Noise"), $Noise);
$this->SetValue("Noise", $Noise);
$this->SendDebug($this->Translate("Endpoint Monitor"), $this->Translate("Connection Data Noise ").$Noise, 0);
$SignalStrength = $JSONData["data"][0]["signal"];
SetValue($this->GetIDForIdent("SignalStrength"), $SignalStrength);
$this->SetValue("SignalStrength", $SignalStrength);
$this->SendDebug($this->Translate("Endpoint Monitor"), $this->Translate("Connection Data SignalStrength ").$SignalStrength, 0);
}
if ($this->ReadPropertyBoolean("DataPointTransfer") == 1 && $this->ReadPropertyInteger("ConnectionType") == 0 && $ConnectionConfigError == false)
{
$TXBytes = $JSONData["data"][0]["tx_bytes"];
SetValue($this->GetIDForIdent("TXBytes"), $TXBytes / 1000000);
$this->SetValue("TXBytes", $TXBytes / 1000000);
$this->SendDebug($this->Translate("Endpoint Monitor"), $this->Translate("Transfer Data TXBytes ").$TXBytes / 1000000, 0);
$RXBytes = $JSONData["data"][0]["rx_bytes"];
SetValue($this->GetIDForIdent("RXBytes"), $RXBytes / 1000000);
$this->SetValue("RXBytes", $RXBytes / 1000000);
$this->SendDebug($this->Translate("Endpoint Monitor"), $this->Translate("Transfer Data RXBytes ").$RXBytes / 1000000, 0);
$TXPackets = $JSONData["data"][0]["tx_packets"];
SetValue($this->GetIDForIdent("TXPackets"), $TXPackets);
$this->SetValue("TXPackets", $TXPackets);
$this->SendDebug($this->Translate("Endpoint Monitor"), $this->Translate("Transfer Data TXPackets ").$TXPackets, 0);
$RXPackets = $JSONData["data"][0]["rx_packets"];
SetValue($this->GetIDForIdent("RXPackets"), $RXPackets);
$this->SetValue("RXPackets", $RXPackets);
$this->SendDebug($this->Translate("Endpoint Monitor"), $this->Translate("Transfer Data RXPackets ").$RXPackets, 0);
}
}
elseif ($DeviceAvailable == "error")
{
$this->SendDebug($this->Translate("Endpoint Monitor"), $this->Translate("Device to be monitored is not available / Disconnected"), 0);
SetValue($this->GetIDForIdent("Connected"), false);
$this->SetValue("Connected", false);
}
}
else
Expand Down
6 changes: 3 additions & 3 deletions UniFi Internet Controller/module.php
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ public function GetInternetData()
if ($value != GetValue($this->GetIDForIdent($variable['ident'])))
{
$this->SendDebug($this->Translate($variable['localeName']), $this->Translate("updated to ").$value, 0);
SetValue($this->GetIDForIdent($variable['ident']), $value);
$this->SetValue($variable['ident'], $value);
}
else
{
Expand Down Expand Up @@ -243,7 +243,7 @@ public function GetInternetData()
if ($value != GetValue($this->GetIDForIdent($variable['ident'])))
{
$this->SendDebug($this->Translate($variable['localeName']), $this->Translate("updated to ").$value, 0);
SetValue($this->GetIDForIdent($variable['ident']), $value);
$this->SetValue($variable['ident'], $value);
}
else
{
Expand Down Expand Up @@ -322,7 +322,7 @@ public function GetInternetData()
if ($value != GetValue($this->GetIDForIdent($variable['ident'])))
{
$this->SendDebug($this->Translate($variable['localeName']), $this->Translate("updated to ").$value, 0);
SetValue($this->GetIDForIdent($variable['ident']), $value);
$this->SetValue($variable['ident'], $value);
}
else
{
Expand Down
11 changes: 10 additions & 1 deletion UniFi Multi Endpoint Monitor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,13 @@ Das Modul gibt diverse Informationen im Debug Bereich aus.
## 5. Versionsinformation

Version 1.5 - 02-12-2023
* Neu - Modul verfügbar
* Neu - Modul verfügbar

Version 1.6 - 01-09-2024 (Credit M70 - Danke)
* Neu - WLAN Geräte melden wo sie zuletzt angemeldet waren
* Fix - Connection wurde nicht gesetzt
* Fix - Satisfaction wurde nicht aktualisiert
* Fix - IP wurde nicht gesetzt
* Fix - LastSeen wird auf Zeit von Symcon korrigiert
* Fix - Modul zieht jetzt nicht mehr die Werte für WLAN Geräte bei LAN Komponenten
* Change - SetValue durch $this->SetValue ersetzt
Loading

0 comments on commit f27f27a

Please sign in to comment.