-
Notifications
You must be signed in to change notification settings - Fork 279
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 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 * update wake-up fix error "Exception while processing the schedule X | 'turn_lights_off_after'" if "turn_lights_off_after" is not specified * fix add light in hue app * Update requirements.txt * Update requirements.txt * Update Dockerfile * Update Dockerfile * Update Dockerfile * Update requirements.txt * Update requirements.txt * Update Dockerfile * Update requirements.txt * Update Dockerfile * revert to old working * Update Dockerfile * Add identify request, non standard gateway, update version and api * add easter egg * Update Credits.py * fixes, adds fix typo and add update process * Create updates_test.txt * Delete updates_test.txt * add version update * Update Dockerfile * Update restful.py * Create update_test.txt * Delete update_test.txt * Create githubresponse.json * Update githubresponse.json * Update githubresponse.json * Update updateManager.py * Update updateManager.py * add update * Update updateManager.py * Update githubInstall.sh * Update updateManager.py * combine code * Update updateManager.py * fix * Update githubInstall.sh * Update githubInstall.sh * Update githubInstall.sh * u * Update githubInstall.sh * Update scheduler.py * Update updateManager.py
- Loading branch information
1 parent
571a0e3
commit e72c095
Showing
11 changed files
with
208 additions
and
2 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
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,4 +1,5 @@ | ||
import requests | ||
from time import sleep | ||
|
||
def sendRequest(url, method, data, timeout=3, delay=0): | ||
if delay != 0: | ||
|
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 |
---|---|---|
@@ -0,0 +1,47 @@ | ||
curl -s localhost/save | ||
cd / | ||
[ ! -d diyhue ] && mkdir diyhue | ||
curl -s -J -L -o $diyhue.tar.gz "https://github.com/diyhue/diyHue/archive/refs/heads/master.tar.gz" | ||
tar xzf $diyhue.tar.gz --strip-components=1 -C diyhue | ||
#cd diyhue | ||
[ -d /opt/hue-emulator/flaskUI ] && rm -r /opt/hue-emulator/flaskUI | ||
mv diyhue/BridgeEmulator/flaskUI /opt/hue-emulator/ | ||
|
||
[ -d /opt/hue-emulator/functions ] && rm -r /opt/hue-emulator/functions | ||
mv diyhue/BridgeEmulator/functions /opt/hue-emulator/ | ||
|
||
[ -d /opt/hue-emulator/lights ] && rm -r /opt/hue-emulator/lights | ||
mv diyhue/BridgeEmulator/lights /opt/hue-emulator/ | ||
|
||
[ -d /opt/hue-emulator/sensors ] && rm -r /opt/hue-emulator/sensors | ||
mv diyhue/BridgeEmulator/sensors /opt/hue-emulator/ | ||
|
||
[ -d /opt/hue-emulator/HueObjects ] && rm -r /opt/hue-emulator/HueObjects | ||
mv diyhue/BridgeEmulator/HueObjects /opt/hue-emulator/ | ||
|
||
[ -d /opt/hue-emulator/services ] && rm -r /opt/hue-emulator/services | ||
mv diyhue/BridgeEmulator/services /opt/hue-emulator | ||
|
||
[ -d /opt/hue-emulator/configManager ] && rm -r /opt/hue-emulator/configManager | ||
mv diyhue/BridgeEmulator/configManager /opt/hue-emulator/ | ||
|
||
[ -d /opt/hue-emulator/logManager ] && rm -r /opt/hue-emulator/logManager | ||
mv diyhue/BridgeEmulator/logManager /opt/hue-emulator/ | ||
|
||
mv diyhue/BridgeEmulator/HueEmulator3.py /opt/hue-emulator/ | ||
mv diyhue/BridgeEmulator/githubInstall.sh /opt/hue-emulator/ | ||
mv diyhue/BridgeEmulator/githubUIInstall.sh /opt/hue-emulator/ | ||
mv diyhue/BridgeEmulator/genCert.sh /opt/hue-emulator/ | ||
mv diyhue/BridgeEmulator/openssl.conf /opt/hue-emulator/ | ||
chmod +x /opt/hue-emulator/genCert.sh | ||
|
||
#cd / | ||
[ ! -d /diyhueUI ] && mkdir diyhueUI | ||
curl -sL https://github.com/diyhue/diyHueUI/releases/latest/download/DiyHueUI-release.zip -o diyHueUI.zip | ||
unzip -qo diyHueUI.zip -d diyhueUI | ||
#cd diyhueUI | ||
mv diyhueUI/index.html /opt/hue-emulator/flaskUI/templates/ | ||
[ -d /opt/hue-emulator/flaskUI/static ] && rm -r /opt/hue-emulator/flaskUI/static | ||
mv diyhueUI/static /opt/hue-emulator/flaskUI/ | ||
|
||
curl -s "localhost.lan/reboot" |
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
curl -s localhost/save | ||
cd / | ||
[ ! -d /diyhueUI ] && mkdir diyhueUI | ||
curl -sL https://github.com/diyhue/diyHueUI/releases/latest/download/DiyHueUI-release.zip -o diyHueUI.zip | ||
unzip -qo diyHueUI.zip -d diyhueUI | ||
cd diyhueUI | ||
mv index.html /opt/hue-emulator/flaskUI/templates/ | ||
[ -d /opt/hue-emulator/flaskUI/static ] && rm -r /opt/hue-emulator/flaskUI/static | ||
mv static /opt/hue-emulator/flaskUI/ | ||
|
||
curl -s localhost/reboot |
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 |
---|---|---|
@@ -0,0 +1,98 @@ | ||
import requests | ||
import configManager | ||
import logManager | ||
import json | ||
from datetime import datetime, timezone | ||
import subprocess | ||
|
||
bridgeConfig = configManager.bridgeConfig.yaml_config | ||
logging = logManager.logger.get_logger(__name__) | ||
|
||
def versionCheck(): | ||
swversion = bridgeConfig["config"]["swversion"] | ||
url = "https://firmware.meethue.com/v1/checkupdate/?deviceTypeId=BSB002&version=" + swversion | ||
response = requests.get(url) | ||
if response.status_code == 200: | ||
device_data = json.loads(response.text) | ||
if len(device_data["updates"]) != 0: | ||
new_version = str(device_data["updates"][len(device_data["updates"])-1]["version"]) | ||
new_versionName = str(device_data["updates"][len(device_data["updates"])-1]["versionName"]) | ||
if new_version > swversion: | ||
logging.info("swversion number update from Philips, old: " + swversion + " new:" + new_version) | ||
bridgeConfig["config"]["swversion"] = new_version | ||
bridgeConfig["config"]["apiversion"] = new_versionName | ||
bridgeConfig["config"]["swupdate2"]["lastchange"] = datetime.utcnow().strftime("%Y-%m-%dT%H:%M:%S") | ||
bridgeConfig["config"]["swupdate2"]["bridge"]["lastinstall"] = datetime.utcnow().strftime("%Y-%m-%dT%H:%M:%S") | ||
else: | ||
logging.info("swversion higher than Philips") | ||
else: | ||
logging.info("no swversion number update from Philips") | ||
|
||
def githubCheck(): | ||
#creation_time = "2024-02-18 19:50:15.000000000 +0100\n" | ||
creation_time = subprocess.run("stat -c %y HueEmulator3.py", shell=True, capture_output=True, text=True)#2024-02-18 19:50:15.000000000 +0100\n | ||
creation_time_arg1 = creation_time.stdout.replace(".", " ").split(" ")#2024-02-18, 19:50:15, 000000000, +0100\n | ||
creation_time = creation_time_arg1[0] + " " + creation_time_arg1[1] + " " + creation_time_arg1[3].replace("\n", "")#2024-02-18 19:50:15 +0100 | ||
creation_time = datetime.strptime(creation_time, "%Y-%m-%d %H:%M:%S %z").astimezone(timezone.utc).strftime("%Y-%m-%d %H")#2024-02-18 18 | ||
|
||
url = "https://api.github.com/repos/diyhue/diyhue/branches/master" | ||
#url = "https://api.github.com/repos/hendriksen-mark/diyhue/branches/master" | ||
response = requests.get(url) | ||
if response.status_code == 200: | ||
device_data = json.loads(response.text) | ||
publish_time = datetime.strptime(device_data["commit"]["commit"]["author"]["date"], "%Y-%m-%dT%H:%M:%SZ").strftime("%Y-%m-%d %H") | ||
|
||
logging.info("creation_time diyHue : " + str(creation_time)) | ||
logging.info("publish_time diyHue : " + str(publish_time)) | ||
|
||
if publish_time > creation_time: | ||
logging.info("update on github") | ||
bridgeConfig["config"]["swupdate2"]["state"] = "allreadytoinstall" | ||
bridgeConfig["config"]["swupdate2"]["bridge"]["state"] = "allreadytoinstall" | ||
elif githubUICheck() == True: | ||
logging.info("UI update on github") | ||
bridgeConfig["config"]["swupdate2"]["state"] = "anyreadytoinstall" | ||
bridgeConfig["config"]["swupdate2"]["bridge"]["state"] = "anyreadytoinstall" | ||
else: | ||
logging.info("no update for diyHue or UI on github") | ||
bridgeConfig["config"]["swupdate2"]["state"] = "noupdates" | ||
bridgeConfig["config"]["swupdate2"]["bridge"]["state"] = "noupdates" | ||
|
||
bridgeConfig["config"]["swupdate2"]["checkforupdate"] = False | ||
|
||
def githubUICheck(): | ||
#creation_time = "2024-02-18 19:50:15.000000000 +0100\n" | ||
creation_time = subprocess.run("stat -c %y flaskUI/templates/index.html", shell=True, capture_output=True, text=True)#2024-02-18 19:50:15.000000000 +0100\n | ||
creation_time_arg1 = creation_time.stdout.replace(".", " ").split(" ")#2024-02-18, 19:50:15, 000000000, +0100\n | ||
creation_time = creation_time_arg1[0] + " " + creation_time_arg1[1] + " " + creation_time_arg1[3].replace("\n", "")#2024-02-18 19:50:15 +0100 | ||
creation_time = datetime.strptime(creation_time, "%Y-%m-%d %H:%M:%S %z").astimezone(timezone.utc).strftime("%Y-%m-%d %H")#2024-02-18 18 | ||
|
||
url = "https://api.github.com/repos/diyhue/diyhueUI/branches/master" | ||
#url = "https://api.github.com/repos/hendriksen-mark/diyhueUI/branches/master" | ||
response = requests.get(url) | ||
if response.status_code == 200: | ||
device_data = json.loads(response.text) | ||
publish_time = datetime.strptime(device_data["commit"]["commit"]["author"]["date"], "%Y-%m-%dT%H:%M:%SZ").strftime("%Y-%m-%d %H") | ||
|
||
logging.info("creation_time UI : " + str(creation_time)) | ||
logging.info("publish_time UI : " + str(publish_time)) | ||
|
||
if publish_time > creation_time: | ||
return True | ||
else: | ||
return False | ||
|
||
|
||
def githubInstall_test(): | ||
if bridgeConfig["config"]["swupdate2"]["state"] == "anyreadytoinstall":#ui update | ||
bridgeConfig["config"]["swupdate2"]["state"] = "installing" | ||
bridgeConfig["config"]["swupdate2"]["bridge"]["state"] = "installing" | ||
subprocess.Popen("sh githubUIInstall.sh",shell=True, close_fds=True) | ||
if bridgeConfig["config"]["swupdate2"]["state"] == "allreadytoinstall":#diyhue + ui update | ||
bridgeConfig["config"]["swupdate2"]["state"] = "installing" | ||
bridgeConfig["config"]["swupdate2"]["bridge"]["state"] = "installing" | ||
subprocess.Popen("sh githubInstall.sh",shell=True, close_fds=True) | ||
|
||
def githubInstall(): | ||
logging.info("work in progress") | ||
bridgeConfig["config"]["swupdate2"]["install"] = False |