mirror of
https://github.com/tomaae/homeassistant-mikrotik_router.git
synced 2025-07-21 11:14:28 +02:00
Added specific unique_id and fixed switch #75
This commit is contained in:
parent
d601a055fd
commit
744b338df4
2 changed files with 7 additions and 3 deletions
|
@ -807,7 +807,6 @@ class MikrotikControllerData:
|
|||
{"name": "dynamic", "value": True},
|
||||
{"name": "action", "value": "jump"},
|
||||
{"name": "protocol", "value": ""},
|
||||
# {"name": "dst-port", "value": ""},
|
||||
],
|
||||
)
|
||||
|
||||
|
|
|
@ -411,6 +411,11 @@ class MikrotikControllerMangleSwitch(MikrotikControllerSwitch):
|
|||
|
||||
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
|
||||
def icon(self):
|
||||
"""Return the icon."""
|
||||
|
@ -448,7 +453,7 @@ class MikrotikControllerMangleSwitch(MikrotikControllerSwitch):
|
|||
for uid in self._ctrl.data["mangle"]:
|
||||
if (
|
||||
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"]
|
||||
|
||||
|
@ -465,7 +470,7 @@ class MikrotikControllerMangleSwitch(MikrotikControllerSwitch):
|
|||
for uid in self._ctrl.data["mangle"]:
|
||||
if (
|
||||
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"]
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue