elueckel / Unifi-Toolbox

Modul for Symcon integrating UniFi Network devices
2 stars 2 forks source link

Device Blocker: Only last Device in list can be blocked #20

Closed Brovning closed 2 years ago

Brovning commented 2 years ago

Sender | 49694 Authentication | Cookie Provided is: 200 Authentication | Login Successful Authentication | Cookie Provided is: TOKEN=** Device Blocker | Device to be managed: Amazon Echo Dot - Lisa Device Blocker | TOKEN=** Device Blocker | Module is authenticated and will try to manage device Device Blocker | Module will try to block device **** with MAC adress Device Blocker | Feedback from UniFi Controller: {"meta":{"rc":"ok"},"data":[{"_id":"61cc11284768320529af5608","site_id":"61163692790afe068c992458","mac":"","blocked":true}]} / HTTP Message 200 Device Blocker | Was operation executed: ok Sender | 50223 Authentication | Cookie Provided is: 200 Authentication | Login Successful Authentication | Cookie Provided is: TOKEN=** Device Blocker | Device to be managed: Amazon Echo Dot - Rafael Device Blocker | TOKEN=** Device Blocker | Module is authenticated and will try to manage device Device Blocker | Module will try to block device *** with MAC adress 68:37:e9:14:: Device Blocker | Feedback from UniFi Controller: {"meta":{"rc":"ok"},"data":[{"_id":"611636c0790afe068c9924b8","mac":"68:37:e9:14::","site_id":"61163692790afe068c992458","oui":"AmazonTe","is_guest":false,"first_seen":1628845758,"last_seen":1640849257,"is_wired":false,"usergroup_id":"","fingerprint_source":5,"dev_cat":51,"dev_family":18,"os_name":1,"dev_vendor":244,"dev_id":2749,"confidence":76,"fingerprint_engine_version":"0.0.0","hostname":"amazon-180a89283","name":"Amazon Echo Dot (KZ Rafael)","note":"","noted":true,"disconnect_timestamp":1640849286,"blocked":true}]} / HTTP Message 200 Device Blocker | Was operation executed: ok

Root cause:

                    foreach ($DevicesJSON as $Device) {
                        $DeviceMacClean = str_replace(array(":"," "), "", $Device["varDeviceMAC"]);
                        if ($SenderObjectIdent == $DeviceMacClean) {
                            $DeviceMacAdress = $Device["varDeviceMAC"];
                            $this->SendDebug($this->Translate("Device Blocker"),$this->Translate("Device to be managed: ").$Device["varDeviceName"],0);
                        }
                        else {
                            $DeviceMacAdress = "";
                        }
                    }

Even if DeviceMac has been found, the DeviceMacAdress is overwritten in next foreach loop. --> $DeviceMacAdress = "";

Brovning commented 2 years ago

solved

elueckel commented 2 years ago

@Brovning Super - ich fange gerade noch die Anmelde Fehler ab. Dann gibt es direkt eine Rückmeldung im Client. Auch sind die Variablen jetzt "mehr2 Integer.