Skip to content

Commit 4c7fe4c

Browse files
Updates and fixes. (diyhue#1029)
* remove old ui * update page-404 * Update updateManager.py * Update configHandler.py * Update handlers.py * duplicate import * clean up hue-emulator dir * clean up update process * Update updater * Update docker-release.yml * Update docker-release.yml * Update docker-release.yml * Update docker-release.yml * Update docker-release.yml * Update docker-release.yml * Update docker-release.yml * Update docker-release.yml * Update docker-release.yml * Update docker-release.yml * Update docker-release.yml * Update docker-release.yml * Allow name change v2api * add line number to logger * Add try for no connection to internet * save config after name change * Add time zone arg to config init * Update restful.py * Update configHandler.py * Update configHandler.py * Update configHandler.py * Update install.sh * add more time zones * sw update * remove ui download sh
1 parent 19c9f7b commit 4c7fe4c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+253
-29112
lines changed

.build/Dockerfile

+6-4
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,12 @@ COPY ./BridgeEmulator/githubInstall.sh /opt/hue-emulator/
3737

3838
## Install the web interface
3939
RUN curl -sL https://github.com/diyhue/diyHueUI/releases/latest/download/DiyHueUI-release.zip -o diyHueUI.zip \
40-
&& unzip -qo diyHueUI.zip \
41-
&& mv index.html flaskUI/templates/ \
42-
&& cp -r static flaskUI/ \
43-
&& rm -r static
40+
&& mkdir diyhueUI \
41+
&& unzip -qo diyHueUI.zip -d diyhueUI \
42+
&& rm diyHueUI.zip \
43+
&& mv diyhueUI/index.html flaskUI/templates/ \
44+
&& cp -r diyhueUI/static flaskUI/ \
45+
&& rm -r diyhueUI
4446

4547
## Copy correct (compiled) C file from previous image
4648
COPY ./BridgeEmulator/genCert.sh ./BridgeEmulator/openssl.conf /opt/hue-emulator/

BridgeEmulator/HueEmulator3.py

-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
from flaskUI.v2restapi import AuthV1, ClipV2, ClipV2Resource, ClipV2ResourceId
1414
from flaskUI.espDevices import Switch
1515
from flaskUI.Credits import Credits
16-
from flaskUI.error_pages.handlers import error_pages
1716
from werkzeug.serving import WSGIRequestHandler
1817
from functions.daylightSensor import daylightSensor
1918
from pprint import pprint

BridgeEmulator/configManager/argumentHandler.py

+10-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ def process_arguments(configDir, args):
3535

3636
def parse_arguments():
3737
argumentDict = {"BIND_IP": '', "HOST_IP": '', "HTTP_PORT": '', "HTTPS_PORT": '', "FULLMAC": '', "MAC": '', "DEBUG": False, "DOCKER": False,
38-
"IP_RANGE_START": '', "IP_RANGE_END": '', "DECONZ": '', "scanOnHostIP": False, "disableOnlineDiscover": '', "noLinkButton": False, "noServeHttps": False}
38+
"IP_RANGE_START": '', "IP_RANGE_END": '', "DECONZ": '', "scanOnHostIP": False, "disableOnlineDiscover": '', "noLinkButton": False,
39+
"noServeHttps": False, "TZ": ''}
3940
ap = argparse.ArgumentParser()
4041

4142
# Arguements can also be passed as Environment Variables.
@@ -55,6 +56,7 @@ def parse_arguments():
5556
ap.add_argument("--no-link-button", action='store_true',
5657
help="DANGEROUS! Don't require the link button to be pressed to pair the Hue app, just allow any app to connect")
5758
ap.add_argument("--disable-online-discover", help="Disable Online and Remote API functions")
59+
ap.add_argument("--TZ", help="Set time zone", type=str)
5860

5961
args = ap.parse_args()
6062

@@ -84,6 +86,13 @@ def parse_arguments():
8486
bind_ip = get_environment_variable('BIND_IP')
8587
argumentDict["BIND_IP"] = bind_ip
8688

89+
tz = "Europe/London"
90+
if args.TZ:
91+
tz = args.TZ
92+
elif get_environment_variable('TZ'):
93+
tz = get_environment_variable('TZ')
94+
argumentDict["TZ"] = tz
95+
8796
if args.ip:
8897
host_ip = args.ip
8998
elif get_environment_variable('IP'):

BridgeEmulator/configManager/configHandler.py

+9-7
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from configManager.argumentHandler import parse_arguments
33
from datetime import datetime
44
import os
5+
import pathlib
56
import subprocess
67
import json
78
import logManager
@@ -33,6 +34,7 @@ def _write_yaml(path, contents):
3334
class Config:
3435
yaml_config = None
3536
configDir = parse_arguments()["CONFIG_PATH"]
37+
runningDir = str(pathlib.Path(__file__)).replace("/configManager/configHandler.py","")
3638

3739
def __init__(self):
3840
if not os.path.exists(self.configDir):
@@ -92,9 +94,9 @@ def load_config(self):
9294
}
9395

9496
if int(config["swversion"]) < 1958077010:
95-
config["swversion"] = "1962154010"
97+
config["swversion"] = "1965111030"
9698
if float(config["apiversion"][:3]) < 1.56:
97-
config["apiversion"] = "1.62.0"
99+
config["apiversion"] = "1.65.0"
98100

99101
self.yaml_config["config"] = config
100102
else:
@@ -107,11 +109,11 @@ def load_config(self):
107109
"alarm":{"enabled": False,"lasttriggered": 0},
108110
"port":{"enabled": False,"ports": [80]},
109111
"apiUsers":{},
110-
"apiversion":"1.62.0",
112+
"apiversion":"1.65.0",
111113
"name":"DiyHue Bridge",
112114
"netmask":"255.255.255.0",
113-
"swversion":"1962154010",
114-
"timezone":"Europe/London",
115+
"swversion":"1965111030",
116+
"timezone":parse_arguments()["TZ"],
115117
"linkbutton":{"lastlinkbuttonpushed": 1599398980},
116118
"users":{"[email protected]":{"password":"pbkdf2:sha256:150000$bqqXSOkI$199acdaf81c18f6ff2f29296872356f4eb78827784ce4b3f3b6262589c788742"}},
117119
"hue": {},
@@ -293,7 +295,7 @@ def download_config(self):
293295

294296
def download_log(self):
295297
subprocess.run('tar -cvf ' + self.configDir + '/diyhue_log.tar ' +
296-
self.configDir.replace('/config', '') + '/*.log* ',
298+
self.runningDir + '/*.log* ',
297299
shell=True, capture_output=True, text=True)
298300
return self.configDir + "/diyhue_log.tar"
299301

@@ -314,7 +316,7 @@ def download_debug(self):
314316
_write_yaml(self.configDir + "/system_info.yaml", info)
315317
subprocess.run('tar --exclude=' + "'config.yaml'" + ' -cvf ' + self.configDir + '/config_debug.tar ' +
316318
self.configDir + '/*.yaml ' +
317-
self.configDir.replace('/config', '') + '/*.log* ',
319+
self.runningDir + '/*.log* ',
318320
shell=True, capture_output=True, text=True)
319321
os.popen('rm -r ' + self.configDir + '/config_debug.yaml')
320322
return self.configDir + "/config_debug.tar"

BridgeEmulator/flaskUI/error_pages/handlers.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ def error_404(error):
88
Error for pages not found.
99
'''
1010
# Notice how we return a tuple!
11-
return render_template('page-404.html'), 200
11+
return render_template('page-404.html'), 404
1212

1313
@error_pages.app_errorhandler(500)
1414
def error_500(error):

BridgeEmulator/flaskUI/restful.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def buildConfig():
5959
result = staticConfig()
6060
config = bridgeConfig["config"]
6161
result.update({"Hue Essentials key": config["Hue Essentials key"], "Remote API enabled": config["Remote API enabled"], "apiversion": config["apiversion"], "bridgeid": config["bridgeid"],
62-
"ipaddress": config["ipaddress"], "netmask": config["netmask"], "gateway": config["gateway"], "mac": config["mac"], "name": config["name"], "swversion": config["swversion"], "swupdate2": config["swupdate2"], "timezone": config["timezone"]})
62+
"ipaddress": config["ipaddress"], "netmask": config["netmask"], "gateway": config["gateway"], "mac": config["mac"], "name": config["name"], "swversion": config["swversion"], "swupdate2": config["swupdate2"], "timezone": config["timezone"], "discovery": config["discovery"]})
6363
result["UTC"] = datetime.now(timezone.utc).strftime("%Y-%m-%dT%H:%M:%S")
6464
result["localtime"] = datetime.now().strftime("%Y-%m-%dT%H:%M:%S")
6565
result["whitelist"] = {}

0 commit comments

Comments
 (0)