Skip to content

Commit

Permalink
this->setvalue & last uplink
Browse files Browse the repository at this point in the history
  • Loading branch information
elueckel committed Sep 1, 2024
1 parent 9d5bbaf commit 465dcc3
Show file tree
Hide file tree
Showing 13 changed files with 56 additions and 46 deletions.
Binary file modified .DS_Store
Binary file not shown.
5 changes: 3 additions & 2 deletions UniFi Device Monitor/README_en.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,5 +79,6 @@ Version 1.3 - 03-01-2022
Version 1.5 - 03-12-2023
* New - UI tidied up

Version 1.6 - 25-08-2024
* New - Number of connected devices are shown
Version 1.6 - 01-09-2024
* New - Number of connected devices are shown
* Change - SetValue replaced by $this->SetValue
30 changes: 15 additions & 15 deletions UniFi Device Monitor/module.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,62 +154,62 @@ 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"];
SetValue($this->GetIDForIdent("ConnectedDevices"), $ConnectedDevices);
$this->SetValue("ConnectedDevices", $ConnectedDevices);
$this->SendDebug($this->Translate("Endpoint Monitor"), $this->Translate("Connected Devices ").$ConnectedDevices, 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
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
36 changes: 18 additions & 18 deletions UniFi Endpoint Monitor/module.php
Original file line number Diff line number Diff line change
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
3 changes: 2 additions & 1 deletion UniFi Multi Endpoint Monitor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ Das Modul gibt diverse Informationen im Debug Bereich aus.
Version 1.5 - 02-12-2023
* Neu - Modul verfügbar

Version 1.6 - 25-08-2024 (Credit M70 - Danke)
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
Expand Down
1 change: 1 addition & 0 deletions UniFi Multi Endpoint Monitor/README_en.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ Version 1.6 - 02-12-2023
* Neu - Modul verfügbar

Version 1.6 - 25-08-2024 (Credit M70 - Danke)
* New - WLAN Devices report where they have been logged in last
* Fix - Connection was not set
* Fix - Satisfaction was not set
* Fix - IP was not set
Expand Down
1 change: 1 addition & 0 deletions UniFi Multi Endpoint Monitor/locale.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"Radio": "Funktechnologie",
"Noise": "Störung",
"Signal Strength": "Signal Stärke",
"Last Uplink Name": "Letzte Verbindung (Access Point)",
"TX Packets": "TX Pakete",
"RX Packets": "RX Pakete",
"Check site name": "Name der Site prüfen",
Expand Down
6 changes: 6 additions & 0 deletions UniFi Multi Endpoint Monitor/module.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ public function ApplyChanges()
$this->MaintainVariable($DeviceMac."RSSI", $DeviceName.$this->Translate(" RSSI"), vtInteger, "", $vpos++, $this->ReadPropertyBoolean("DataPointConnection") == 1 && $ConnectionType == 0);
$this->MaintainVariable($DeviceMac."Noise", $DeviceName.$this->Translate(" Noise"), vtInteger, "", $vpos++, $this->ReadPropertyBoolean("DataPointConnection") == 1 && $ConnectionType == 0);
$this->MaintainVariable($DeviceMac."SignalStrength", $DeviceName.$this->Translate(" Signal Strength"), vtInteger, "", $vpos++, $this->ReadPropertyBoolean("DataPointConnection") == 1 && $ConnectionType == 0);
$this->MaintainVariable($DeviceMac."LastUplinkName", $DeviceName.$this->Translate(" Last Uplink Name"), vtString, "", $vpos++, $this->ReadPropertyBoolean("DataPointConnection") == 1 && $ConnectionType == 0);

//Transfer Data
$vpos = 600;
Expand Down Expand Up @@ -295,6 +296,11 @@ public function EndpointMonitor()
$this->SetValue($DeviceMac."SignalStrength", $SignalStrength);
$this->SendDebug($this->Translate("Endpoint Monitor"), $this->Translate("Connection Data SignalStrength ").$SignalStrength, 0);
}
if(isset($DeviceFromController["last_uplink_name"])) {
$LastUplinkName = $DeviceFromController["last_uplink_name"];
$this->SetValue($DeviceMac."LastUplinkName", $LastUplinkName);
$this->SendDebug($this->Translate("Endpoint Monitor"), $this->Translate("Last Uplink Name ").$LastUplinkName, 0);
}
}
if ($this->ReadPropertyBoolean("DataPointTransfer") == 1 AND $ConnectionType == 0 AND $ConnectionConfigError == false)
{
Expand Down
4 changes: 2 additions & 2 deletions UniFi PoE Control/module.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public function ApplyChanges()
$this->RegisterVariableBoolean($DeviceMacClean . $i, $DeviceName . " Port: " . $i, "~Switch");
$DeviceMacCleanID = @IPS_GetObjectIDByIdent($DeviceMacClean .$i, $this->InstanceID);

SetValue($DeviceMacCleanID, false);
$this->SetValue($DeviceMacCleanID, false);
IPS_Sleep(1000);
$this->EnableAction($DeviceMacClean . $i);
$this->RegisterMessage($DeviceMacCleanID, VM_UPDATE);
Expand Down Expand Up @@ -218,7 +218,7 @@ public function AuthenticateAndProcessRequest(string $UnifiAPI = "")
if ($ControllerFeedbackOK == "ok")
{
// reset variable
SetValue($SenderID, false);
$this->SetValue($SenderID, false);
//WFC_SendPopup(12345, "Test", "Eine nette <br> Meldung");
}
elseif ($ControllerFeedbackOK == "error")
Expand Down
8 changes: 4 additions & 4 deletions UniFi Presence Manager/module.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,10 @@ public function CheckPresence()
{
if ($OldPresenceValue == 0)
{ //check if new value is different and only than trigger a replacement
SetValue($this->GetIDForIdent($DeviceMac), 1);
$this->SetValue($DeviceMac, 1);
if ($this->ReadPropertyBoolean("GeneralPresenceUpdatedVariable") == 1)
{
SetValue($this->GetIDForIdent("GeneralPresenceUpdatedVariable"), 1);
$this->SetValue("GeneralPresenceUpdatedVariable", 1);
}
$this->SendDebug($this->Translate("Presence Manager"), $this->Translate("Device ACTIVE with MAC: ".$DeviceMac), 0);
}
Expand All @@ -159,10 +159,10 @@ public function CheckPresence()
{
if ($OldPresenceValue == 1)
{
SetValue($this->GetIDForIdent($DeviceMac), 0);
$this->SetValue($DeviceMac, 0);
if ($this->ReadPropertyBoolean("GeneralPresenceUpdatedVariable") == 1)
{
SetValue($this->GetIDForIdent("GeneralPresenceUpdatedVariable"), 1);
$this->SetValue("GeneralPresenceUpdatedVariable", 1);
}
$this->SendDebug($this->Translate("Presence Manager"), $this->Translate("Device NOT active with MAC: ".$DeviceMac), 0);
}
Expand Down
Binary file modified tests/.DS_Store
Binary file not shown.

0 comments on commit 465dcc3

Please sign in to comment.