-
Notifications
You must be signed in to change notification settings - Fork 278
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add sub-ip-range to light scan. Move deprecate command line arguments ip-range, scan-on-host-ip, deconz, disable-online-discover, TZ to bridgeConfig and WebUI. Add check if a valid MAC address is provided. Make sensitive info privately. Move from create-react-app to vite. Add the option to remove the certificate. Update V1api scan for devices request. Add temporary log level change in WebUI. Add FPS counter to entertainment. Update light effects to effects_v2. Add effects to mqtt.
- Loading branch information
1 parent
d782696
commit 365c0a8
Showing
1,740 changed files
with
213 additions
and
125 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
from configManager import configInit | ||
from configManager.argumentHandler import parse_arguments | ||
from configManager.argumentHandler import parse_arguments, generate_certificate | ||
import os | ||
import pathlib | ||
import subprocess | ||
|
@@ -9,6 +9,7 @@ | |
import weakref | ||
from time import sleep | ||
from HueObjects import Light, Group, EntertainmentConfiguration, Scene, ApiUser, Rule, ResourceLink, Schedule, Sensor, BehaviorInstance, SmartScene, Device | ||
from copy import deepcopy | ||
try: | ||
from time import tzset | ||
except ImportError: | ||
|
@@ -31,7 +32,8 @@ def _write_yaml(path, contents): | |
|
||
class Config: | ||
yaml_config = None | ||
configDir = parse_arguments()["CONFIG_PATH"] | ||
argsDict = parse_arguments() | ||
configDir = argsDict["CONFIG_PATH"] | ||
runningDir = str(pathlib.Path(__file__)).replace("/configManager/configHandler.py","") | ||
|
||
def __init__(self): | ||
|
@@ -44,6 +46,9 @@ def load_config(self): | |
#load config | ||
if os.path.exists(self.configDir + "/config.yaml"): | ||
config = _open_yaml(self.configDir + "/config.yaml") | ||
if "timezone" not in config: | ||
logging.warn("No Time Zone in config, please set Time Zone in webui, default to Europe/London") | ||
config["timezone"] = "Europe/London" | ||
os.environ['TZ'] = config["timezone"] | ||
if tzset is not None: | ||
tzset() | ||
|
@@ -52,6 +57,16 @@ def load_config(self): | |
self.yaml_config["apiUsers"][user] = ApiUser.ApiUser(user, data["name"], data["client_key"], data["create_date"], data["last_use_date"]) | ||
del config["whitelist"] | ||
# updgrade config | ||
if "discovery" not in config: | ||
config["discovery"] = True | ||
if "IP_RANGE" not in config: | ||
config["IP_RANGE"] = { | ||
"IP_RANGE_START": 0, | ||
"IP_RANGE_END": 255, | ||
"SUB_IP_RANGE_START": int(self.argsDict["HOST_IP"].split('.')[2]), | ||
"SUB_IP_RANGE_END": int(self.argsDict["HOST_IP"].split('.')[2])} | ||
if "scanonhostip" not in config: | ||
config["scanonhostip"] = False | ||
if "homeassistant" not in config: | ||
config["homeassistant"] = {"enabled": False} | ||
if "yeelight" not in config: | ||
|
@@ -102,6 +117,7 @@ def load_config(self): | |
"Remote API enabled": False, | ||
"Hue Essentials key": str(uuid.uuid1()).replace('-', ''), | ||
"discovery": True, | ||
"scanonhostip": False, | ||
"mqtt":{"enabled":False}, | ||
"deconz":{"enabled":False}, | ||
"alarm":{"enabled": False,"lasttriggered": 0}, | ||
|
@@ -111,7 +127,7 @@ def load_config(self): | |
"name":"DiyHue Bridge", | ||
"netmask":"255.255.255.0", | ||
"swversion":"1965111030", | ||
"timezone":parse_arguments()["TZ"], | ||
"timezone": "Europe/London", | ||
"linkbutton":{"lastlinkbuttonpushed": 1599398980}, | ||
"users":{"[email protected]":{"password":"pbkdf2:sha256:150000$bqqXSOkI$199acdaf81c18f6ff2f29296872356f4eb78827784ce4b3f3b6262589c788742"}}, | ||
"hue": {}, | ||
|
@@ -139,7 +155,13 @@ def load_config(self): | |
"lastchange": "2020-12-13T10:30:15", | ||
"state": "noupdates", | ||
"install": False | ||
} | ||
}, | ||
"IP_RANGE": { | ||
"IP_RANGE_START": 0, | ||
"IP_RANGE_END": 255, | ||
"SUB_IP_RANGE_START": int(self.argsDict["HOST_IP"].split('.')[2]), | ||
"SUB_IP_RANGE_END": int(self.argsDict["HOST_IP"].split('.')[2]) | ||
} | ||
} | ||
# load lights | ||
if os.path.exists(self.configDir + "/lights.yaml"): | ||
|
@@ -323,6 +345,15 @@ def reset_config(self): | |
self.load_config() | ||
return backup | ||
|
||
def remove_cert(self): | ||
try: | ||
os.popen('mv ' + self.configDir + '/cert.pem ' + self.configDir + '/backup/') | ||
logging.info("Certificate removed") | ||
except: | ||
logging.exception("Something went wrong when deleting the certificate") | ||
generate_certificate(self.argsDict["MAC"], self.argsDict["CONFIG_PATH"]) | ||
return | ||
|
||
def restore_backup(self): | ||
try: | ||
os.popen('rm -r ' + self.configDir + '/*.yaml') | ||
|
@@ -344,18 +375,32 @@ def download_log(self): | |
return self.configDir + "/diyhue_log.tar" | ||
|
||
def download_debug(self): | ||
_write_yaml(self.configDir + "/config_debug.yaml", self.yaml_config["config"]) | ||
debug = _open_yaml(self.configDir + "/config_debug.yaml") | ||
#_write_yaml(self.configDir + "/config_debug.yaml", self.yaml_config["config"]) | ||
#debug = _open_yaml(self.configDir + "/config_debug.yaml") | ||
debug = deepcopy(self.yaml_config["config"]) | ||
debug["whitelist"] = "privately" | ||
debug["apiUsers"] = "privately" | ||
debug["Hue Essentials key"] = "privately" | ||
debug["users"] = "privately" | ||
if debug["mqtt"]["enabled"] or "mqttPassword" in debug["mqtt"]: | ||
debug["mqtt"]["mqttPassword"] = "privately" | ||
if debug["homeassistant"]["enabled"] or "homeAssistantToken" in debug["homeassistant"]: | ||
debug["homeassistant"]["homeAssistantToken"] = "privately" | ||
if debug["hue"]: | ||
debug["hue"]["hueUser"] = "privately" | ||
debug["hue"]["hueKey"] = "privately" | ||
if debug["tradfri"]: | ||
debug["tradfri"]["psk"] = "privately" | ||
if debug["alarm"]["enabled"]: | ||
debug["alarm"]["email"] = "privately" | ||
info = {} | ||
info["OS"] = os.uname().sysname | ||
info["Architecture"] = os.uname().machine | ||
info["os_version"] = os.uname().version | ||
info["os_release"] = os.uname().release | ||
info["Hue-Emulator Version"] = subprocess.run("stat -c %y HueEmulator3.py", shell=True, capture_output=True, text=True).stdout.replace("\n", "") | ||
info["WebUI Version"] = subprocess.run("stat -c %y flaskUI/templates/index.html", shell=True, capture_output=True, text=True).stdout.replace("\n", "") | ||
info["arguments"] = self.argsDict | ||
_write_yaml(self.configDir + "/config_debug.yaml", debug) | ||
_write_yaml(self.configDir + "/system_info.yaml", info) | ||
subprocess.run('tar --exclude=' + "'config.yaml'" + ' -cvf ' + self.configDir + '/config_debug.tar ' + | ||
|
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
Oops, something went wrong.