Skip to content

Commit

Permalink
remove wled scan in load lights
Browse files Browse the repository at this point in the history
add new protocol_cfg to discovery.
rescan lights if error during entertainment `Entertainment Service was syncing and has timed out, stopping server and clearing state'segment_start'`
  • Loading branch information
hendriksen-mark committed Dec 1, 2024
1 parent 14008aa commit bd11e1c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 14 deletions.
14 changes: 0 additions & 14 deletions BridgeEmulator/configManager/configHandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import weakref
from copy import deepcopy
from HueObjects import Light, Group, EntertainmentConfiguration, Scene, ApiUser, Rule, ResourceLink, Schedule, Sensor, BehaviorInstance, SmartScene
from lights.protocols import wled
try:
from time import tzset
except ImportError:
Expand All @@ -29,17 +28,6 @@ def _write_yaml(path, contents):
with open(path, 'w', encoding="utf-8") as fp:
yaml.dump(contents, fp , Dumper=NoAliasDumper, allow_unicode=True, sort_keys=False )

def reAddWled(old_light):
detectedLights = []
wled.discover(detectedLights, old_light["protocol_cfg"]["ip"])
for light in detectedLights:
if light["name"] == old_light["name"] and light["protocol_cfg"]["ip"] == old_light["protocol_cfg"]["ip"] and light["protocol_cfg"]["segmentId"] == old_light["protocol_cfg"]["segmentId"]:
logging.info("Update Wled " + light["name"])
old_light["protocol_cfg"]["ledCount"] = light["protocol_cfg"]["ledCount"]
old_light["protocol_cfg"]["segment_start"] = light["protocol_cfg"]["segment_start"]
old_light["protocol_cfg"]["udp_port"] = light["protocol_cfg"]["udp_port"]
return old_light

class Config:
yaml_config = None
argsDict = parse_arguments()
Expand Down Expand Up @@ -179,8 +167,6 @@ def load_config(self):
if os.path.exists(self.configDir + "/lights.yaml"):
lights = _open_yaml(self.configDir + "/lights.yaml")
for light, data in lights.items():
if data["protocol"] == "wled" and "segment_start" not in data["protocol_cfg"]:
data = reAddWled(data)
data["id_v1"] = light
self.yaml_config["lights"][light] = Light.Light(data)
#self.yaml_config["groups"]["0"].add_light(self.yaml_config["lights"][light])
Expand Down
3 changes: 3 additions & 0 deletions BridgeEmulator/lights/discover.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,9 @@ def scanForLights(): # scan for ESP8266 lights and strips
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"]
lightObj.protocol_cfg["ledCount"] = light["protocol_cfg"]["ledCount"]
lightObj.protocol_cfg["segment_start"] = light["protocol_cfg"]["segment_start"]
lightObj.protocol_cfg["udp_port"] = light["protocol_cfg"]["udp_port"]
lightIsNew = False
elif light["protocol"] == "homeassistant_ws":
# Check based on entity_id and modelid
Expand Down

0 comments on commit bd11e1c

Please sign in to comment.