UNIFI, undiscoverables, docs work

This commit is contained in:
Jokob-sk
2023-09-02 13:30:19 +10:00
parent 854ef20826
commit 25b54d1f62
5 changed files with 128 additions and 152 deletions

View File

@@ -226,7 +226,7 @@
"mapped_to_column": "cur_MAC",
"css_classes": "col-sm-2",
"show": true,
"type": "device_mac",
"type": "label",
"default_value":"",
"options": [],
"localized": ["name"],
@@ -291,6 +291,23 @@
"language_code":"es_es",
"string" : "Cambiado"
}]
}
},
{
"column": "ForeignKey",
"css_classes": "col-sm-2",
"show": false,
"type": "device_mac",
"default_value":"",
"options": [],
"localized": ["name"],
"name":[{
"language_code":"en_us",
"string" : "MAC"
},
{
"language_code":"es_es",
"string" : "MAC"
}]
}
]
}

View File

@@ -5,6 +5,7 @@ import os
import pathlib
import argparse
import sys
import hashlib
sys.path.append("/home/pi/pialert/front/plugins")
sys.path.append('/home/pi/pialert/pialert')
@@ -31,6 +32,9 @@ def main():
if values.devices:
for fake_dev in values.devices.split('=')[1].split(','):
fake_mac = string_to_mac_hash(fake_dev)
plugin_objects.add_object(
primaryId=fake_dev, # MAC (Device Name)
secondaryId="0.0.0.0", # IP Address (always 0.0.0.0)
@@ -39,12 +43,21 @@ def main():
watched3="",
watched4="",
extra="",
foreignKey="")
foreignKey=fake_mac)
plugin_objects.write_result_file()
return 0
def string_to_mac_hash(input_string):
# Calculate a hash using SHA-256
sha256_hash = hashlib.sha256(input_string.encode()).hexdigest()
# Take the first 12 characters of the hash and format as a MAC address
mac_hash = ':'.join(sha256_hash[i:i+2] for i in range(0, 12, 2))
return mac_hash
#===============================================================================
# BEGIN
#===============================================================================