Added specific unique_id and fixed switch #75

This commit is contained in:
tomaae 2020-12-25 09:47:25 +01:00
parent d601a055fd
commit 744b338df4
2 changed files with 7 additions and 3 deletions

View file

@ -807,7 +807,6 @@ class MikrotikControllerData:
{"name": "dynamic", "value": True}, {"name": "dynamic", "value": True},
{"name": "action", "value": "jump"}, {"name": "action", "value": "jump"},
{"name": "protocol", "value": ""}, {"name": "protocol", "value": ""},
# {"name": "dst-port", "value": ""},
], ],
) )

View file

@ -411,6 +411,11 @@ class MikrotikControllerMangleSwitch(MikrotikControllerSwitch):
return f"{self._inst} Mangle {self._data['name']}" return f"{self._inst} Mangle {self._data['name']}"
@property
def unique_id(self) -> str:
"""Return a unique identifier for this mangle switch."""
return f"{self._inst.lower()}-enable_mangle-{self._data['name']}"
@property @property
def icon(self): def icon(self):
"""Return the icon.""" """Return the icon."""
@ -448,7 +453,7 @@ class MikrotikControllerMangleSwitch(MikrotikControllerSwitch):
for uid in self._ctrl.data["mangle"]: for uid in self._ctrl.data["mangle"]:
if ( if (
self._ctrl.data["mangle"][uid]["name"] self._ctrl.data["mangle"][uid]["name"]
== f"{self._data['chain']},{self._data['action']},{self._data['protocol']},{self._data['src-address']}:{self._data['src-port']}:{self._data['dst-address']}:{self._data['dst-port']}" == f"{self._data['chain']},{self._data['action']},{self._data['protocol']},{self._data['src-address']}:{self._data['src-port']}-{self._data['dst-address']}:{self._data['dst-port']}"
): ):
value = self._ctrl.data["mangle"][uid][".id"] value = self._ctrl.data["mangle"][uid][".id"]
@ -465,7 +470,7 @@ class MikrotikControllerMangleSwitch(MikrotikControllerSwitch):
for uid in self._ctrl.data["mangle"]: for uid in self._ctrl.data["mangle"]:
if ( if (
self._ctrl.data["mangle"][uid]["name"] self._ctrl.data["mangle"][uid]["name"]
== f"{self._data['chain']},{self._data['action']},{self._data['protocol']},{self._data['src-address']}:{self._data['src-port']}:{self._data['dst-address']}:{self._data['dst-port']}" == f"{self._data['chain']},{self._data['action']},{self._data['protocol']},{self._data['src-address']}:{self._data['src-port']}-{self._data['dst-address']}:{self._data['dst-port']}"
): ):
value = self._ctrl.data["mangle"][uid][".id"] value = self._ctrl.data["mangle"][uid][".id"]