I have pretty much the same setup.. and I have amazon alexa on main "controller" hub
to remove the "xxx on controller hub" suffix... I did the following steps..
(1) temporarily removed the hub password
(2) copy pasted the entire device list table from the "[hub-ip]/device/list" into a Excel sheet.
(3) created an excel macro to go to each of the device id page link and programatically removed the "on HUB-ABCD" from the device label and saved the devices ( I filtered this list based on whether it is "Linked" or not...
(4) run the macro.. and couple of minutes later.. all the device labels were without the "on hub-controller" etc..
I have tested it on 2.2.8.. things do change between versions.. so cant say for sure if it will work in the future.. or on older versions.
take a backup before running the full script just to be sure..
here is the macro.. if you would like to copy paste it to excel and run it after changing the appropriate strings.
the pasted data should look something like this
. on Hub-Controller |
Virtual Button |
Linked |
73455667-8888-8888-9999-112233445566-1234 |
2-15 7:34pm |
(. on Hub-Controller) |
|
|
|
|
where cells in column 2-5 are merged vertically, and column 1 has 2 separate cells.
Sub update_names()
Set objHTTP = CreateObject("MSXML2.ServerXMLHTTP")
hub_ip = "IP ADDRESS OF THE HUB WITH LINKED DEVICES"
CHANGE THE COMMENT CODE TO DO ALL, AFTER TESTING that 1 RENAMING WORKS PROPERLY
For dev_num = 1 To 1
' For dev_num = 1 To ActiveSheet.UsedRange.Rows.Count
If Cells(dev_num, 3) = "Linked" And Left(Cells(dev_num, 1), 1) <> "(" Then
Get_URL = Cells(dev_num, 1).Hyperlinks(1).Address
objHTTP.Open "GET", Get_URL, False
objHTTP.setRequestHeader "User-Agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)"
objHTTP.send ("")
res1 = objHTTP.responseText
'find_states_text1 = "var currentStates = "
find_states_text1 = "}},"
find_states_text2 = ";"
st1 = InStr(1, res1, find_states_text1, vbTextCompare)
st2 = InStr(st1 + 1, res1, find_states_text2, vbTextCompare)
json_val = Mid(res1, st1 + Len(find_states_text1), st2 - st1 - Len(find_states_text1))
json_val = Replace(json_val, Chr(34) & Chr(34), Chr(34), , 1000)
json_val = Replace(json_val, Chr(34), Chr(39), , 1000)
id_st = "'id':"
ed_en = ","
st1 = InStr(1, json_val, id_st, vbTextCompare)
st2 = InStr(st1 + 1, json_val, ed_en, vbTextCompare)
my_deviceTypeId = Mid(json_val, st1 + Len(id_st), st2 - st1 - Len(id_st))
id_st = "'version':"
ed_en = ",'"
st1 = InStr(1, json_val, id_st, vbTextCompare)
st2 = InStr(st1 + 1, json_val, ed_en, vbTextCompare)
my_version = Mid(json_val, st1 + Len(id_st), st2 - st1 - Len(id_st))
id_st = "'deviceNetworkId':"
ed_en = ",'"
st1 = InStr(1, json_val, id_st, vbTextCompare)
st2 = InStr(st1 + 1, json_val, ed_en, vbTextCompare)
my_deviceNetworkId = Mid(json_val, st1 + Len(id_st), st2 - st1 - Len(id_st))
id_st = "'name':"
ed_en = ",'"
st1 = InStr(1, json_val, id_st, vbTextCompare)
st2 = InStr(st1 + 1, json_val, ed_en, vbTextCompare)
my_name = Mid(json_val, st1 + Len(id_st), st2 - st1 - Len(id_st))
id_st = "'label':"
ed_en = ",'"
st1 = InStr(1, json_val, id_st, vbTextCompare)
st2 = InStr(st1 + 1, json_val, ed_en, vbTextCompare)
my_label = Mid(json_val, st1 + Len(id_st), st2 - st1 - Len(id_st))
my_label = Replace(my_label, "'", "")
CHANGE THE FOLLOWING BASED ON YOUR HUB NAMES THAT YOU WANT TO REMOVE
new_label = Replace(my_name, " on Hub-MAIN-LEVEL", "")
new_label = Replace(new_label, " on Hub-UPPER-LEVEL", "")
new_label = Replace(new_label, " on Hub-CONTROLLER", "")
new_label = Replace(new_label, "'", "")
If my_label <> new_label Then
Post_URL = "http://" & hub_ip & "/device/update"
Post_URL_Suffix = "id=" & my_deviceTypeId & "&version=" & my_version & "&controllerType=LNK&label=" & new_label & "&deviceNetworkId=" & my_deviceNetworkId & "&meshFullSync=on&locationId=1&hubId=1&groupId=&_action_update=Save+Device"
objHTTP.Open "POST", Post_URL & "?" & Post_URL_Suffix, False
objHTTP.setRequestHeader "User-Agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)"
objHTTP.send (Post_URL_Suffix)
res1 = objHTTP.responseText
End if
End If
Next dev_num
End Sub