Skip to content

Commit

Permalink
Updates and fixes. (#1029)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
hendriksen-mark authored Jul 27, 2024
1 parent 19c9f7b commit 4c7fe4c
Show file tree
Hide file tree
Showing 57 changed files with 253 additions and 29,112 deletions.
10 changes: 6 additions & 4 deletions .build/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,12 @@ COPY ./BridgeEmulator/githubInstall.sh /opt/hue-emulator/

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

## Copy correct (compiled) C file from previous image
COPY ./BridgeEmulator/genCert.sh ./BridgeEmulator/openssl.conf /opt/hue-emulator/
Expand Down
1 change: 0 additions & 1 deletion BridgeEmulator/HueEmulator3.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
from flaskUI.v2restapi import AuthV1, ClipV2, ClipV2Resource, ClipV2ResourceId
from flaskUI.espDevices import Switch
from flaskUI.Credits import Credits
from flaskUI.error_pages.handlers import error_pages
from werkzeug.serving import WSGIRequestHandler
from functions.daylightSensor import daylightSensor
from pprint import pprint
Expand Down
11 changes: 10 additions & 1 deletion BridgeEmulator/configManager/argumentHandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ def process_arguments(configDir, args):

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

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

args = ap.parse_args()

Expand Down Expand Up @@ -84,6 +86,13 @@ def parse_arguments():
bind_ip = get_environment_variable('BIND_IP')
argumentDict["BIND_IP"] = bind_ip

tz = "Europe/London"
if args.TZ:
tz = args.TZ
elif get_environment_variable('TZ'):
tz = get_environment_variable('TZ')
argumentDict["TZ"] = tz

if args.ip:
host_ip = args.ip
elif get_environment_variable('IP'):
Expand Down
16 changes: 9 additions & 7 deletions BridgeEmulator/configManager/configHandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from configManager.argumentHandler import parse_arguments
from datetime import datetime
import os
import pathlib
import subprocess
import json
import logManager
Expand Down Expand Up @@ -33,6 +34,7 @@ def _write_yaml(path, contents):
class Config:
yaml_config = None
configDir = parse_arguments()["CONFIG_PATH"]
runningDir = str(pathlib.Path(__file__)).replace("/configManager/configHandler.py","")

def __init__(self):
if not os.path.exists(self.configDir):
Expand Down Expand Up @@ -92,9 +94,9 @@ def load_config(self):
}

if int(config["swversion"]) < 1958077010:
config["swversion"] = "1962154010"
config["swversion"] = "1965111030"
if float(config["apiversion"][:3]) < 1.56:
config["apiversion"] = "1.62.0"
config["apiversion"] = "1.65.0"

self.yaml_config["config"] = config
else:
Expand All @@ -107,11 +109,11 @@ def load_config(self):
"alarm":{"enabled": False,"lasttriggered": 0},
"port":{"enabled": False,"ports": [80]},
"apiUsers":{},
"apiversion":"1.62.0",
"apiversion":"1.65.0",
"name":"DiyHue Bridge",
"netmask":"255.255.255.0",
"swversion":"1962154010",
"timezone":"Europe/London",
"swversion":"1965111030",
"timezone":parse_arguments()["TZ"],
"linkbutton":{"lastlinkbuttonpushed": 1599398980},
"users":{"[email protected]":{"password":"pbkdf2:sha256:150000$bqqXSOkI$199acdaf81c18f6ff2f29296872356f4eb78827784ce4b3f3b6262589c788742"}},
"hue": {},
Expand Down Expand Up @@ -293,7 +295,7 @@ def download_config(self):

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

Expand All @@ -314,7 +316,7 @@ def download_debug(self):
_write_yaml(self.configDir + "/system_info.yaml", info)
subprocess.run('tar --exclude=' + "'config.yaml'" + ' -cvf ' + self.configDir + '/config_debug.tar ' +
self.configDir + '/*.yaml ' +
self.configDir.replace('/config', '') + '/*.log* ',
self.runningDir + '/*.log* ',
shell=True, capture_output=True, text=True)
os.popen('rm -r ' + self.configDir + '/config_debug.yaml')
return self.configDir + "/config_debug.tar"
Expand Down
2 changes: 1 addition & 1 deletion BridgeEmulator/flaskUI/error_pages/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def error_404(error):
Error for pages not found.
'''
# Notice how we return a tuple!
return render_template('page-404.html'), 200
return render_template('page-404.html'), 404

@error_pages.app_errorhandler(500)
def error_500(error):
Expand Down
2 changes: 1 addition & 1 deletion BridgeEmulator/flaskUI/restful.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def buildConfig():
result = staticConfig()
config = bridgeConfig["config"]
result.update({"Hue Essentials key": config["Hue Essentials key"], "Remote API enabled": config["Remote API enabled"], "apiversion": config["apiversion"], "bridgeid": config["bridgeid"],
"ipaddress": config["ipaddress"], "netmask": config["netmask"], "gateway": config["gateway"], "mac": config["mac"], "name": config["name"], "swversion": config["swversion"], "swupdate2": config["swupdate2"], "timezone": config["timezone"]})
"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"]})
result["UTC"] = datetime.now(timezone.utc).strftime("%Y-%m-%dT%H:%M:%S")
result["localtime"] = datetime.now().strftime("%Y-%m-%dT%H:%M:%S")
result["whitelist"] = {}
Expand Down
Loading

0 comments on commit 4c7fe4c

Please sign in to comment.