Skip to content

Commit fc81560

Browse files
Allow for name and icon change
1 parent 4c7fe4c commit fc81560

File tree

3 files changed

+19
-4
lines changed

3 files changed

+19
-4
lines changed

BridgeEmulator/HueObjects/__init__.py

+13-1
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,13 @@ def setV1State(self, state, advertise=True):
396396
for key, value in state.items():
397397
if key in self.state:
398398
self.state[key] = value
399+
if key in self.config:
400+
if key == "archetype":
401+
self.config[key] = value.replace("_","")
402+
else:
403+
self.config[key] = value
404+
if key == "name":
405+
self.name = value
399406
if "bri" in state:
400407
if "min_bri" in self.protocol_cfg and self.protocol_cfg["min_bri"] > state["bri"]:
401408
state["bri"] = self.protocol_cfg["min_bri"]
@@ -422,6 +429,11 @@ def setV2State(self, state):
422429
self.effect = v1State["effect"]
423430
if "dynamics" in state and "speed" in state["dynamics"]:
424431
self.dynamics["speed"] = state["dynamics"]["speed"]
432+
if "metadata" in state:
433+
if "archetype" in state["metadata"]:
434+
v1State["archetype"] = state["metadata"]["archetype"]
435+
if "name" in state["metadata"]:
436+
v1State["name"] = state["metadata"]["name"]
425437
self.setV1State(v1State, advertise=False)
426438
self.genStreamEvent(state)
427439

@@ -443,7 +455,7 @@ def getDevice(self):
443455
result["id_v1"] = "/lights/" + self.id_v1
444456
result["identify"] = {}
445457
result["metadata"] = {
446-
"archetype": lightTypes[self.modelid]["device"]["product_archetype"],
458+
"archetype": archetype[self.config["archetype"]],
447459
"name": self.name
448460
}
449461
result["product_data"] = lightTypes[self.modelid]["device"]

BridgeEmulator/flaskUI/templates/login.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ <h1>DIYHUE LOGIN</h1>
3838
<div class="input-group-prepend">
3939
<div class="input-group-text"><i class="fas fa-user"></i></div>
4040
</div>
41-
<input class="form-control" id="inlineFormInputUsername" name="email" placeholder="[email protected]" required type="text" value="">
41+
<input class="form-control" id="inlineFormInputUsername" name="email" placeholder="[email protected]" required type="text" value="" autocomplete="username">
4242
</div>
4343

4444

@@ -47,7 +47,7 @@ <h1>DIYHUE LOGIN</h1>
4747
<div class="input-group-prepend">
4848
<div class="input-group-text"><i class="fas fa-key"></i></div>
4949
</div>
50-
<input class="form-control" id="inlineFormInputPassword" name="password" placeholder="changeme" required type="password" value="">
50+
<input class="form-control" id="inlineFormInputPassword" name="password" placeholder="changeme" required type="password" value="" autocomplete="current-password">
5151
</div>
5252

5353
<div class="btn-group">

BridgeEmulator/flaskUI/v2restapi.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -602,7 +602,10 @@ def put(self, resource, resourceid):
602602
object.setV1State({"alert": "select"})
603603
if "metadata" in putDict:
604604
if "name" in putDict["metadata"]:
605-
bridgeConfig["config"]["name"] = putDict["metadata"]["name"]
605+
if object:
606+
object.name = putDict["metadata"]["name"]
607+
elif resourceid == v2BridgeDevice()["id"]:
608+
bridgeConfig["config"]["name"] = putDict["metadata"]["name"]
606609
configManager.bridgeConfig.save_config(backup=False, resource="config")
607610
elif resource == "motion":
608611
if "enabled" in putDict:

0 commit comments

Comments
 (0)