Skip to content

Commit

Permalink
Update discover.py (#982)
Browse files Browse the repository at this point in the history
* Update discover.py

* Update configHandler.py

* end wake up

* Update v2restapi.py

Add behavior instance to clip/v2/resource, to solve problem as in issue 873, now the app shows the automations

* wrong response

* add all buttons to response

* Update discover.py

Fix issue where lights with the same mac address but different modelid get the same ip address
  • Loading branch information
hendriksen-mark authored Jan 7, 2024
1 parent bbbec9b commit dbddc13
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions BridgeEmulator/lights/discover.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,39 +159,43 @@ def scanForLights(): # scan for ESP8266 lights and strips
for key, lightObj in bridgeConfig["lights"].items():
if lightObj.protocol == light["protocol"]:
if light["protocol"] == "native_multi":
if lightObj.protocol_cfg["mac"] == light["protocol_cfg"]["mac"] and lightObj.protocol_cfg["light_nr"] == light["protocol_cfg"]["light_nr"]:
# check based on mac address and modelid
if lightObj.protocol_cfg["mac"] == light["protocol_cfg"]["mac"] and lightObj.protocol_cfg["light_nr"] == light["protocol_cfg"]["light_nr"] and lightObj.modelid == light["modelid"]:
logging.info("Update IP for light " + light["name"])
lightObj.protocol_cfg["ip"] = light["protocol_cfg"]["ip"]
lightIsNew = False
break
elif light["protocol"] in ["yeelight", "tasmota", "tradfri", "hyperion", "tpkasa"]:
if lightObj.protocol_cfg["id"] == light["protocol_cfg"]["id"]:
# check based on id and modelid
if lightObj.protocol_cfg["id"] == light["protocol_cfg"]["id"] and lightObj.modelid == light["modelid"]:
logging.info("Update IP for light " + light["name"])
lightObj.protocol_cfg["ip"] = light["protocol_cfg"]["ip"]
lightIsNew = False
elif light["protocol"] in ["shelly", "native", "native_single", "esphome"]:
# check based on mac address
if lightObj.protocol_cfg["mac"] == light["protocol_cfg"]["mac"]:
# check based on mac address and modelid
if lightObj.protocol_cfg["mac"] == light["protocol_cfg"]["mac"] and lightObj.modelid == light["modelid"]:
logging.info("Update IP for light " + light["name"])
lightObj.protocol_cfg["ip"] = light["protocol_cfg"]["ip"]
lightIsNew = False
elif light["protocol"] in ["hue", "deconz"]:
# check based on light uniqueid
if lightObj.protocol_cfg["uniqueid"] == light["protocol_cfg"]["uniqueid"]:
# check based on light uniqueid and modelid
if lightObj.protocol_cfg["uniqueid"] == light["protocol_cfg"]["uniqueid"] and lightObj.modelid == light["modelid"]:
logging.info("Update IP for light " + light["name"])
lightObj.protocol_cfg["ip"] = light["protocol_cfg"]["ip"]
lightIsNew = False
elif light["protocol"] in ["wled"]:
# Check mac and segment
if lightObj.protocol_cfg["mac"] == light["protocol_cfg"]["mac"] and lightObj.protocol_cfg["segmentId"] == light["protocol_cfg"]["segmentId"]:
# Check based on mac and segment and modelid
if lightObj.protocol_cfg["mac"] == light["protocol_cfg"]["mac"] and lightObj.protocol_cfg["segmentId"] == light["protocol_cfg"]["segmentId"] and lightObj.modelid == light["modelid"]:
logging.info("Update IP for light " + light["name"])
lightObj.protocol_cfg["ip"] = light["protocol_cfg"]["ip"]
lightIsNew = False
elif light["protocol"] == "homeassistant_ws":
if lightObj.protocol_cfg["entity_id"] == light["protocol_cfg"]["entity_id"]:
# Check based on entity_id and modelid
if lightObj.protocol_cfg["entity_id"] == light["protocol_cfg"]["entity_id"] and lightObj.modelid == light["modelid"]:
lightIsNew = False
elif light["protocol"] == "elgato":
if lightObj.protocol_cfg['mac'] == light["protocol_cfg"]['mac']:
# check based on mac address and modelid
if lightObj.protocol_cfg['mac'] == light["protocol_cfg"]['mac'] and lightObj.modelid == light["modelid"]:
lightIsNew = False
if lightIsNew:
logging.info("Add new light " + light["name"])
Expand Down

0 comments on commit dbddc13

Please sign in to comment.