⚙ NAME_CLEANUP_REGEX test
This commit is contained in:
@@ -372,7 +372,7 @@ if ($ENABLED_DARKMODE === True) {
|
|||||||
</a>
|
</a>
|
||||||
<ul class="treeview-menu " style="display: <?php if (in_array (basename($_SERVER['SCRIPT_NAME']), array('plugins.php', 'workflows.php' ) ) ){ echo 'block'; } else {echo 'none';} ?>;">
|
<ul class="treeview-menu " style="display: <?php if (in_array (basename($_SERVER['SCRIPT_NAME']), array('plugins.php', 'workflows.php' ) ) ){ echo 'block'; } else {echo 'none';} ?>;">
|
||||||
<li>
|
<li>
|
||||||
<div class="info-icon-nav work-in-progress"> </div>
|
<div class="info-icon-nav"> </div>
|
||||||
<a href="workflows.php"><?= lang('Navigation_Workflows');?></a>
|
<a href="workflows.php"><?= lang('Navigation_Workflows');?></a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
|
|||||||
@@ -685,7 +685,7 @@
|
|||||||
"name": [
|
"name": [
|
||||||
{
|
{
|
||||||
"language_code": "en_us",
|
"language_code": "en_us",
|
||||||
"string": "Device SQL"
|
"string": "Devices SQL"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"description": [
|
"description": [
|
||||||
|
|||||||
@@ -646,9 +646,12 @@ import dns.resolver
|
|||||||
|
|
||||||
def cleanDeviceName(str, match_IP):
|
def cleanDeviceName(str, match_IP):
|
||||||
|
|
||||||
|
mylog('debug', ["[cleanDeviceName] input: " + str])
|
||||||
|
|
||||||
# add matching info
|
# add matching info
|
||||||
if match_IP:
|
if match_IP:
|
||||||
str = str + " (IP match)"
|
str = str + " (IP match)"
|
||||||
|
|
||||||
|
|
||||||
if get_setting_value('NEWDEV_LESS_NAME_CLEANUP'):
|
if get_setting_value('NEWDEV_LESS_NAME_CLEANUP'):
|
||||||
mylog('debug', ["[Name cleanup] Using new cleanDeviceName(" + str + ")"])
|
mylog('debug', ["[Name cleanup] Using new cleanDeviceName(" + str + ")"])
|
||||||
@@ -688,22 +691,32 @@ def cleanDeviceName(str, match_IP):
|
|||||||
# OLD cleanDeviceName
|
# OLD cleanDeviceName
|
||||||
mylog('debug', ["[Name cleanup] Using old cleanDeviceName(" + str + ")"])
|
mylog('debug', ["[Name cleanup] Using old cleanDeviceName(" + str + ")"])
|
||||||
|
|
||||||
# alternative str.split('.')[0]
|
# # alternative str.split('.')[0]
|
||||||
str = str.replace("._airplay", "")
|
# str = str.replace("._airplay", "")
|
||||||
str = str.replace("._tcp", "")
|
# str = str.replace("._tcp", "")
|
||||||
str = str.replace(".localdomain", "")
|
# str = str.replace(".localdomain", "")
|
||||||
str = str.replace(".local", "")
|
# str = str.replace(".local", "")
|
||||||
str = str.replace("._esphomelib", "")
|
# str = str.replace("._esphomelib", "")
|
||||||
str = str.replace("._googlecast", "")
|
# str = str.replace("._googlecast", "")
|
||||||
str = str.replace(".lan", "")
|
# str = str.replace(".lan", "")
|
||||||
str = str.replace(".home", "")
|
# str = str.replace(".home", "")
|
||||||
str = re.sub(r'-[a-fA-F0-9]{32}', '', str) # removing last part of e.g. Nest-Audio-ff77ff77ff77ff77ff77ff77ff77ff77
|
# str = re.sub(r'-[a-fA-F0-9]{32}', '', str) # removing last part of e.g. Nest-Audio-ff77ff77ff77ff77ff77ff77ff77ff77
|
||||||
str = re.sub(r'#.*', '', str) # Remove everything after '#' including the '#'
|
# str = re.sub(r'#.*', '', str) # Remove everything after '#' including the '#'
|
||||||
# remove trailing dots
|
# # remove trailing dots
|
||||||
if str.endswith('.'):
|
# if str.endswith('.'):
|
||||||
str = str[:-1]
|
# str = str[:-1]
|
||||||
|
|
||||||
mylog('debug', ["cleanDeviceName = " + str])
|
regexes = get_setting_value('NEWDEV_NAME_CLEANUP_REGEX')
|
||||||
|
|
||||||
|
for rgx in regexes:
|
||||||
|
mylog('debug', ["[cleanDeviceName] applying regex : " + rgx])
|
||||||
|
mylog('debug', ["[cleanDeviceName] name before regex : " + str])
|
||||||
|
|
||||||
|
str = re.sub(rgx, "", str)
|
||||||
|
mylog('debug', ["[cleanDeviceName] name after regex : " + str])
|
||||||
|
|
||||||
|
mylog('debug', ["[cleanDeviceName] output: " + str])
|
||||||
|
|
||||||
return str
|
return str
|
||||||
|
|
||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
|
|||||||
Reference in New Issue
Block a user