mirror of
https://github.com/tomaae/homeassistant-mikrotik_router.git
synced 2025-06-25 10:18:43 +02:00
Added support for DNS comments #86
Remove everything after hash in comments for device tracking #86
This commit is contained in:
parent
f6cb4c4706
commit
27f1b14ec4
1 changed files with 10 additions and 5 deletions
|
@ -1436,7 +1436,7 @@ class MikrotikControllerData:
|
|||
data=self.data["dns"],
|
||||
source=self.api.path("/ip/dns/static"),
|
||||
key="name",
|
||||
vals=[{"name": "name"}, {"name": "address"}],
|
||||
vals=[{"name": "name"}, {"name": "address"}, {"name": "comment"}],
|
||||
)
|
||||
|
||||
# ---------------------------
|
||||
|
@ -1719,6 +1719,11 @@ class MikrotikControllerData:
|
|||
if vals["address"] != "unknown":
|
||||
for dns_uid, dns_vals in self.data["dns"].items():
|
||||
if dns_vals["address"] == vals["address"]:
|
||||
if dns_vals["comment"] != "":
|
||||
self.data["host"][uid]["host-name"] = dns_vals[
|
||||
"comment"
|
||||
].split("#", 1)[0]
|
||||
else:
|
||||
self.data["host"][uid]["host-name"] = dns_vals[
|
||||
"name"
|
||||
].split(".")[0]
|
||||
|
@ -1731,7 +1736,7 @@ class MikrotikControllerData:
|
|||
):
|
||||
self.data["host"][uid]["host-name"] = self.data["dhcp"][uid][
|
||||
"comment"
|
||||
]
|
||||
].split("#", 1)[0]
|
||||
# Resolve hostname from DHCP hostname
|
||||
elif (
|
||||
self.data["host"][uid]["host-name"] == "unknown"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue