Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
Fix grouped_light missing owner,
Fix previously made changes,
Fix missing update time,
Update readme
  • Loading branch information
hendriksen-mark committed Aug 10, 2024
1 parent 7c757d9 commit 4837baa
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 10 deletions.
16 changes: 11 additions & 5 deletions BridgeEmulator/HueObjects/Group.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ def __init__(self, data):
self.id_v2 = data["id_v2"] if "id_v2" in data else genV2Uuid()
if "owner" in data:
self.owner = data["owner"]
else:
self.owner = {"rid": str(uuid.uuid5(uuid.NAMESPACE_URL, self.id_v2 + 'device')), "rtype": "device"}
self.icon_class = data["class"] if "class" in data else "Other"
self.lights = []
self.action = {"on": False, "bri": 100, "hue": 0, "sat": 254, "effect": "none", "xy": [
Expand Down Expand Up @@ -178,6 +176,8 @@ def genStreamEvent(self, v2State):
def getV1Api(self):
result = {}
result["name"] = self.name
if hasattr(self, "owner"):
result["owner"] = self.owner.username
lights = []
for light in self.lights:
if light():
Expand All @@ -197,7 +197,7 @@ def getV1Api(self):
result["lightlevel"] = {"state": {"dark": None, "dark_all": None, "daylight": None, "daylight_any": None,
"lightlevel": None, "lightlevel_min": None, "lightlevel_max": None, "lastupdated": "none"}}
else:
result["class"] = self.icon_class
result["class"] = self.icon_class.capitalize()
result["action"] = self.action
return result

Expand Down Expand Up @@ -287,15 +287,21 @@ def getV2GroupedLight(self):
result["id_v1"] = "/groups/" + self.id_v1
result["on"] = {"on": self.update_state()["any_on"]}
result["type"] = "grouped_light"
result["owner"] = self.owner
if hasattr(self, "owner"):
result["owner"] = {"rid": self.owner.username, "rtype": "device"}
else:
result["owner"] = {"rid": self.id_v2, "rtype": "device"}

return result

def getObjectPath(self):
return {"resource": "groups", "id": self.id_v1}

def save(self):
result = {"id_v2": self.id_v2, "name": self.name, "class": self.icon_class,
"lights": [], "action": self.action, "type": self.type, "owner": self.owner}
"lights": [], "action": self.action, "type": self.type}
if hasattr(self, "owner"):
result["owner"] = self.owner.username
for light in self.lights:
if light():
result["lights"].append(light().id_v1)
Expand Down
4 changes: 4 additions & 0 deletions BridgeEmulator/configManager/configHandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,10 @@ def load_config(self):
lightObj = self.yaml_config["lights"][light]
self.yaml_config["groups"][group].locations[lightObj] = location
else:
if "owner" in data and isinstance(data["owner"], dict):
data["owner"] = self.yaml_config["apiUsers"][list(self.yaml_config["apiUsers"])[0]]
elif "owner" not in data:
data["owner"] = self.yaml_config["apiUsers"][list(self.yaml_config["apiUsers"])[0]]
self.yaml_config["groups"][group] = Group.Group(data)
for light in data["lights"]:
self.yaml_config["groups"][group].add_light(self.yaml_config["lights"][light])
Expand Down
7 changes: 4 additions & 3 deletions BridgeEmulator/flaskUI/v2restapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -457,11 +457,12 @@ def post(self, resource):
new_object_id = nextFreeId(bridgeConfig, "groups")
objCreation = {
"id_v1": new_object_id,
"name": postDict["metadata"]["name"]
"name": postDict["metadata"]["name"],
"owner": bridgeConfig["apiUsers"][request.headers["hue-application-key"]],
}
objCreation["type"] = "Room" if resource == "room" else "Zone"
if "archetype" in postDict["metadata"]:
objCreation["icon_class"] = postDict["metadata"]["archetype"].replace("_", " ")
objCreation["icon_class"] = postDict["metadata"]["archetype"].replace("_", " ").capitalize()
objCreation.update(postDict)
newObject = Group.Group(objCreation)
if "children" in postDict:
Expand Down Expand Up @@ -578,7 +579,7 @@ def put(self, resource, resourceid):
if "name" in putDict["metadata"]:
v1Api["name"] = putDict["metadata"]["name"]
if "archetype" in putDict["metadata"]:
v1Api["icon_class"] = putDict["metadata"]["archetype"].replace("_", " ")
v1Api["icon_class"] = putDict["metadata"]["archetype"].replace("_", " ").capitalize()
if "children" in putDict:
for children in putDict["children"]:
obj = getObject(
Expand Down
2 changes: 2 additions & 0 deletions BridgeEmulator/services/scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ def runScheduler():
except Exception as e:
logging.info("Exception while processing the schedule " + obj.name + " | " + str(e))

if ("updatetime" not in bridgeConfig["config"]["swupdate2"]["autoinstall"]):
bridgeConfig["config"]["swupdate2"]["autoinstall"]["updatetime"] = "T14:00:00"
if (datetime.now().strftime("T%H:%M:%S") == bridgeConfig["config"]["swupdate2"]["autoinstall"]["updatetime"]): #check for updates every day at updatetime
updateManager.versionCheck()
updateManager.githubCheck()
Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# diyHue - A Hue Bridge Emulator
[![Discourse](https://img.shields.io/discourse/users?server=https%3A%2F%2Fdiyhue.discourse.group)](https://diyhue.discourse.group) [![JoinSlack](https://img.shields.io/badge/Join%20us-on%20Slack-green.svg)](https://join.slack.com/t/diyhue/shared_invite/enQtNzAwNDE1NDY2MzQxLTljNGMwZmE0OWRhNDIwM2FjOGM1ZTcxNjNmYjc5ZmE3MjZlNmNjMmUzYmRkZjhhOGNjOTc4NzA0MGVkYzE2NWM) [![Build Status](https://github.com/diyhue/diyHue/workflows/diyHue%20CI%20Build/badge.svg)](https://github.com/diyhue/diyHue/actions)
[![Discourse](https://img.shields.io/discourse/users?server=https%3A%2F%2Fdiyhue.discourse.group)](https://diyhue.discourse.group) [![JoinSlack](https://img.shields.io/badge/Join%20us-on%20Slack-green.svg)](https://diyhue.slack.com/) [![Build Status](https://github.com/diyhue/diyHue/workflows/diyHue%20CI%20Build/badge.svg)](https://github.com/diyhue/diyHue/actions)



Expand Down Expand Up @@ -149,7 +149,9 @@ All documentation and instructions can be found over at [diyhue.readthedocs.io](

If you need help with diyHue you can get support from other users, aswell as the maintainer.

### Slack [![JoinSlack](https://img.shields.io/badge/Join%20us-on%20Slack-green.svg)](https://join.slack.com/t/diyhue/shared_invite/enQtNzAwNDE1NDY2MzQxLTljNGMwZmE0OWRhNDIwM2FjOGM1ZTcxNjNmYjc5ZmE3MjZlNmNjMmUzYmRkZjhhOGNjOTc4NzA0MGVkYzE2NWM) [![SlackStatus](https://slackinvite.squishedmooo.com/badge.svg?colorB=8ebc06)](https://slackinvite.squishedmooo.com/)
Please use GitHub, Slack or Discourse, other platforms are not checked by the maintainers.

### Slack [![JoinSlack](https://img.shields.io/badge/Join%20us-on%20Slack-green.svg)](https://diyhue.slack.com/) [![SlackStatus](https://slackinvite.squishedmooo.com/badge.svg?colorB=8ebc06)](https://slackinvite.squishedmooo.com/)
Use Slack for a general chat or fast live support.

However: Since Slack is faster at providing live Support but not as good when it comes to save and show known Issues, we kindly ask you to open a Topic at our Discourse group. This will provide Help for others in the future.
Expand Down

0 comments on commit 4837baa

Please sign in to comment.