From 14617ebaa4cfb59d5521db2e82c2931de4c49755 Mon Sep 17 00:00:00 2001 From: DewGew Date: Fri, 15 May 2020 12:15:23 +0200 Subject: [PATCH 01/84] Update FUNDING.yml --- .github/FUNDING.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml index d3c04ceb..cf3aae64 100644 --- a/.github/FUNDING.yml +++ b/.github/FUNDING.yml @@ -10,4 +10,4 @@ community_bridge: # Replace with a single Community Bridge project-name e.g., cl liberapay: # Replace with a single Liberapay username issuehunt: # Replace with a single IssueHunt username otechie: # Replace with a single Otechie username -custom: https://paypal.me/dzg +custom: https://paypal.me/dzga From 9dbe0444fdb7eea075a5e89a960107415e3225b2 Mon Sep 17 00:00:00 2001 From: DewGew Date: Wed, 10 Jun 2020 09:37:03 +0200 Subject: [PATCH 02/84] Create config.yml --- .github/ISSUE_TEMPLATE/config.yml | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/config.yml diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 00000000..205945b4 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1,5 @@ +blank_issues_enabled: false +contact_links: + - name: DZGA Discord Community + url: https://discordapp.com/AmJV6AC + about: Join the Official DZGA Discord community. From 7cc691c95de90a9613e338914ff6e01d13c133db Mon Sep 17 00:00:00 2001 From: DewGew Date: Wed, 10 Jun 2020 09:49:46 +0200 Subject: [PATCH 03/84] Update config.yml --- .github/ISSUE_TEMPLATE/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml index 205945b4..0038be92 100644 --- a/.github/ISSUE_TEMPLATE/config.yml +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -1,5 +1,5 @@ blank_issues_enabled: false contact_links: - name: DZGA Discord Community - url: https://discordapp.com/AmJV6AC + url: https://discordapp.com/invite/AmJV6AC about: Join the Official DZGA Discord community. From 23423b0c2262df5f7288d96595fdefcc151a0a0f Mon Sep 17 00:00:00 2001 From: DewGew Date: Thu, 25 Jun 2020 15:05:03 +0200 Subject: [PATCH 04/84] Update config.yml --- .github/ISSUE_TEMPLATE/config.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml index 0038be92..0d6f094b 100644 --- a/.github/ISSUE_TEMPLATE/config.yml +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -1,5 +1,8 @@ blank_issues_enabled: false contact_links: + - name: Domoticz Forum + url: https://domoticz.com/forum/ + about: Join the Domoticz community. - name: DZGA Discord Community url: https://discordapp.com/invite/AmJV6AC about: Join the Official DZGA Discord community. From 2defc482abba512f02ca6b3583fed409aff845da Mon Sep 17 00:00:00 2001 From: DewGew Date: Thu, 25 Jun 2020 15:06:13 +0200 Subject: [PATCH 05/84] Update config.yml --- .github/ISSUE_TEMPLATE/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml index 0d6f094b..5752d302 100644 --- a/.github/ISSUE_TEMPLATE/config.yml +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -1,7 +1,7 @@ blank_issues_enabled: false contact_links: - name: Domoticz Forum - url: https://domoticz.com/forum/ + url: https://domoticz.com/forum/viewtopic.php?f=69&t=31869 about: Join the Domoticz community. - name: DZGA Discord Community url: https://discordapp.com/invite/AmJV6AC From 9e884ed619c41646feef46e782f31082434b9599 Mon Sep 17 00:00:00 2001 From: DewGew Date: Thu, 25 Jun 2020 15:07:34 +0200 Subject: [PATCH 06/84] [skip travis] --- .github/ISSUE_TEMPLATE/config.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml index 5752d302..170ae2a2 100644 --- a/.github/ISSUE_TEMPLATE/config.yml +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -2,7 +2,7 @@ blank_issues_enabled: false contact_links: - name: Domoticz Forum url: https://domoticz.com/forum/viewtopic.php?f=69&t=31869 - about: Join the Domoticz community. + about: Join the DzGA thread in Domoticz community. - name: DZGA Discord Community url: https://discordapp.com/invite/AmJV6AC - about: Join the Official DZGA Discord community. + about: Join the Official DzGA Discord community. From 245d1961178cf462f5db93ca35a0fd2abba0acda Mon Sep 17 00:00:00 2001 From: DewGew Date: Thu, 5 Nov 2020 17:30:10 +0100 Subject: [PATCH 07/84] New Version --- const.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/const.py b/const.py index d251ae67..2beffd4c 100644 --- a/const.py +++ b/const.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- """Constants for Google Assistant.""" -VERSION = '1.8.13' +VERSION = '1.9.0' PUBLIC_URL = 'https://[your public url]' CONFIGFILE = 'config/config.yaml' LOGFILE = 'dzga.log' From 5857a5c5c5af55ae63145fb269c5a61d823d440b Mon Sep 17 00:00:00 2001 From: DewGew Date: Thu, 5 Nov 2020 17:35:24 +0100 Subject: [PATCH 08/84] Add jinja2 --- requirements/pip-requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements/pip-requirements.txt b/requirements/pip-requirements.txt index bfabdae6..51a96421 100644 --- a/requirements/pip-requirements.txt +++ b/requirements/pip-requirements.txt @@ -9,3 +9,4 @@ urllib3>=1.25.7 GitPython>=3.0.5 google-auth>=1.8.1 wheel>=0.34.2 +Jinja2==2.11.2 From f8028bc91298b7ca79a0bef72bb6690463529ae5 Mon Sep 17 00:00:00 2001 From: DewGew Date: Thu, 5 Nov 2020 17:41:57 +0100 Subject: [PATCH 09/84] Add Jinja2 functions Upgrade to jinja2 UI Improvements on report_state() --- smarthome.py | 143 ++++++++++++++++++++++++++------------------------- 1 file changed, 74 insertions(+), 69 deletions(-) diff --git a/smarthome.py b/smarthome.py index ffee1388..c67f4124 100644 --- a/smarthome.py +++ b/smarthome.py @@ -9,6 +9,7 @@ from collections.abc import Mapping from itertools import product from pid import PidFile +from jinja2 import Environment, FileSystemLoader import requests @@ -25,6 +26,12 @@ DOMOTICZ_URL = configuration['Domoticz']['ip'] + ':' + configuration['Domoticz']['port'] CREDITS = (configuration['Domoticz']['username'], configuration['Domoticz']['password']) +file_loader = FileSystemLoader(FILE_DIR + '/templates') +env = Environment( + loader=file_loader + + ) + if 'PidFile' in configuration: pidfile = PidFile(pidname=configuration['PidFile']) else: @@ -58,8 +65,6 @@ def checkupdate(): response = r.text if VERSION not in response: update = 1 - logger.info("========") - logger.info(" New version is availible on Github!") else: update = 0 return update @@ -70,6 +75,8 @@ def checkupdate(): return 0 update = checkupdate() +if update: + logger.info("New version is availible on Github!") # some way to convert a domain type: Domoticz to google def AogGetDomain(device): @@ -194,24 +201,28 @@ def getAog(device): aog.temp = device.get("Temp") aog.humidity = device.get("Humidity") aog.setpoint = device.get("SetPoint") - aog.color = device.get("Color") + if aog.domain is "Color": + aog.color = device.get("Color") aog.protected = device.get("Protected") - aog.maxdimlevel = device.get("MaxDimLevel") - aog.seccode = settings.get("SecPassword") - aog.secondelay = settings.get("SecOnDelay") - aog.tempunit = settings.get("TempUnit") + aog.maxdimlevel = device.get("MaxDimLevel") aog.battery = device.get("BatteryLevel") aog.hardware = device.get("HardwareName") aog.selectorLevelName = device.get("LevelNames") - aog.language = settings.get("Language") aog.lastupdate = device.get("LastUpdate") + + aog.language = settings.get("Language") + aog.tempunit = settings.get("TempUnit") + if aog.domain is "Security": + aog.seccode = settings.get("SecPassword") + aog.secondelay = settings.get("SecOnDelay") + # Try to get device specific voice control configuration from Domoticz # Read it from the configuration file if not in Domoticz (for backward compatibility) desc = getDeviceConfig(device.get("Description")) if desc is not None: - logger.info(' tags found for idx %s in domoticz description.', aog.id) - logger.info('Device_Config for idx %s will be ignored in config.yaml!', aog.id) + logger.debug(' tags found for idx %s in domoticz description.', aog.id) + logger.debug('Device_Config for idx %s will be ignored in config.yaml!', aog.id) if desc is None: desc = getDesc(aog) @@ -252,7 +263,7 @@ def getAog(device): aog.state = str(aogDevs[domains['temperature'] + at_idx].temp) aogDevs[domains['temperature'] + at_idx].domain = domains['merged'] + aog.id + ')' except: - logger.debug('Merge Error, Cant find temperature device with idx %s', at_idx) + logger.error('Merge Error, Cant find temperature device with idx %s', at_idx) modes_idx = desc.get('selector_modes_idx', None) if modes_idx is not None: aog.modes_idx = modes_idx @@ -333,7 +344,9 @@ def getDevices(devices="all", idx="0"): continue aogDevs[aog.entity_id] = aog + if 'loglevel' in configuration and (configuration['loglevel']).lower() == 'debug': + save_json(aogDevs) req = {aog.name: {}} req[aog.name]['idx'] = int(aog.id) req[aog.name]['type'] = aog.domain @@ -635,7 +648,7 @@ def smarthome_post(self, s): self._request_id = message.get('requestId') - logger.debug("Request " + json.dumps(message, indent=2, sort_keys=True, ensure_ascii=False)) + logger.info("Request " + json.dumps(message, indent=2, sort_keys=True, ensure_ascii=False)) response = self.smarthome_process(message, token) try: @@ -683,31 +696,42 @@ def restartServer(self, s): s.send_message(200, 'Restart request sent, status_code: True') restartServer() + + def log(self, s): + user = self.getSessionUser() + if user is None or user.get('uid', '') == '': + s.redirect('login?redirect_uri={0}'.format('log')) + return + + s.send_message(200, readFile(os.path.join(logfilepath, LOGFILE))) + + def test(self, s): + s.send_message(200, templatepage.render()) + def settings(self, s): user = self.getSessionUser() if user is None or user.get('uid', '') == '': s.redirect('login?redirect_uri={0}'.format('settings')) return + update = checkupdate() confJSON = json.dumps(configuration) public_url = getTunnelUrl() message = '' meta = '' code = readFile(os.path.join(FILE_DIR, CONFIGFILE)) - logs = readFile(os.path.join(logfilepath, LOGFILE)) - template = TEMPLATE.format(message=message, uptime=uptime(), list=deviceList, meta=meta, code=code, - conf=confJSON, public_url=public_url, logs=logs, update=update, - branch=branch, dzversion=settings['dzversion']) - s.send_message(200, template) - + templatepage = env.get_template('home.html') + s.send_message(200, templatepage.render(message=message, uptime=uptime(), list=deviceList, meta=meta, code=code, + conf=confJSON, public_url=public_url, update=update, + branch=branch, dzversion=settings['dzversion'], dzgaversion=VERSION)) + def settings_post(self, s): enableReport = ReportState.enable_report_state() update = checkupdate() confJSON = json.dumps(configuration) public_url = getTunnelUrl() - logs = readFile(os.path.join(logfilepath, LOGFILE)) code = readFile(os.path.join(FILE_DIR, CONFIGFILE)) meta = '' @@ -718,36 +742,30 @@ def settings_post(self, s): message = 'Config saved' logger.info(message) logs = readFile(os.path.join(logfilepath, LOGFILE)) - code = readFile(os.path.join(FILE_DIR, CONFIGFILE)) - template = TEMPLATE.format(message=message, uptime=uptime(), list=deviceList, meta=meta, code=code, - conf=confJSON, public_url=public_url, logs=logs, update=update, - branch=branch, dzversion=settings['dzversion']) - - s.send_message(200, template) + templatepage = env.get_template('home.html') + s.send_message(200, templatepage.render(message=message, uptime=uptime(), list=deviceList, meta=meta, code=code, + conf=confJSON, public_url=public_url, update=update, + branch=branch, dzversion=settings['dzversion'], dzgaversion=VERSION)) if s.form.get("backup"): codeToSave = readFile(os.path.join(FILE_DIR, CONFIGFILE)) saveFile('config/config.yaml.bak', codeToSave) message = 'Backup saved' logger.info(message) - logs = readFile(os.path.join(logfilepath, LOGFILE)) - template = TEMPLATE.format(message=message, uptime=uptime(), list=deviceList, meta=meta, code=code, - conf=confJSON, public_url=public_url, logs=logs, update=update, - branch=branch, dzversion=settings['dzversion']) - - s.send_message(200, template) + templatepage = env.get_template('home.html') + s.send_message(200, templatepage.render(message=message, uptime=uptime(), list=deviceList, meta=meta, code=code, + conf=confJSON, public_url=public_url, update=update, + branch=branch, dzversion=settings['dzversion'], dzgaversion=VERSION)) if s.form.get("restart"): message = 'Restart Server, please wait a minute!' meta = '' code = '' - logs = '' - - template = TEMPLATE.format(message=message, uptime=uptime(), list=deviceList, meta=meta, code=code, - conf=confJSON, public_url=public_url, logs=logs, update=update, - branch=branch, dzversion=settings['dzversion']) - s.send_message(200, template) + templatepage = env.get_template('home.html') + s.send_message(200, templatepage.render(message=message, uptime=uptime(), list=deviceList, meta=meta, code=code, + conf=confJSON, public_url=public_url, update=update, + branch=branch, dzversion=settings['dzversion'], dzgaversion=VERSION)) restartServer() if s.form.get("sync"): @@ -760,19 +778,18 @@ def settings_post(self, s): message = 'Homegraph api key not valid!' else: message = 'Add Homegraph api key or a Homegraph Service Account json file to sync devices in the UI! You can still sync by voice eg. "Hey Google, Sync my devices".' - logs = readFile(os.path.join(logfilepath, LOGFILE)) - template = TEMPLATE.format(message=message, uptime=uptime(), list=deviceList, meta=meta, code=code, - conf=confJSON, public_url=public_url, logs=logs, update=update, - branch=branch, dzversion=settings['dzversion']) - s.send_message(200, template) + templatepage = env.get_template('home.html') + s.send_message(200, templatepage.render(message=message, uptime=uptime(), list=deviceList, meta=meta, code=code, + conf=confJSON, public_url=public_url, update=update, + branch=branch, dzversion=settings['dzversion'], dzgaversion=VERSION)) if s.form.get("reload"): message = '' - template = TEMPLATE.format(message=message, uptime=uptime(), list=deviceList, meta=meta, code=code, - conf=confJSON, public_url=public_url, logs=logs, update=update, - branch=branch, dzversion=settings['dzversion']) - s.send_message(200, template) + templatepage = env.get_template('home.html') + s.send_message(200, templatepage.render(message=message, uptime=uptime(), list=deviceList, meta=meta, code=code, + conf=confJSON, public_url=public_url, update=update, + branch=branch, dzversion=settings['dzversion'], dzgaversion=VERSION)) if s.form.get("deletelogs"): logfile = os.path.join(logfilepath, LOGFILE) @@ -781,11 +798,10 @@ def settings_post(self, s): f.close() logger.info('Logs removed by user') message = 'Logs removed' - logs = readFile(os.path.join(logfilepath, LOGFILE)) - template = TEMPLATE.format(message=message, uptime=uptime(), list=deviceList, meta=meta, code=code, - conf=confJSON, public_url=public_url, logs=logs, update=update, - branch=branch, dzversion=settings['dzversion']) - s.send_message(200, template) + templatepage = env.get_template('home.html') + s.send_message(200, templatepage.render(message=message, uptime=uptime(), list=deviceList, meta=meta, code=code, + conf=confJSON, public_url=public_url, update=update, + branch=branch, dzversion=settings['dzversion'], dzgaversion=VERSION)) if s.form.get("update"): repo.git.reset('--hard') @@ -793,24 +809,20 @@ def settings_post(self, s): message = 'Updating to latest ' + branch + ', please wait a minute!' meta = '' - template = TEMPLATE.format(message=message, uptime=uptime(), list=deviceList, meta=meta, code=code, - conf=confJSON, public_url=public_url, logs=logs, update=update, - branch=branch, dzversion=settings['dzversion']) - s.send_message(200, template) + templatepage = env.get_template('home.html') + s.send_message(200, templatepage.render(message=message, uptime=uptime(), list=deviceList, meta=meta, code=code, + conf=confJSON, public_url=public_url, update=update, + branch=branch, dzversion=settings['dzversion'], dzgaversion=VERSION)) subprocess.call(['pip', 'install','-r', os.path.join(FILE_DIR, 'requirements/pip-requirements.txt')]) restartServer() - def delay_report_state(self, states, token): - time.sleep(3) - self.report_state(states, token) def smarthome_sync(self, payload, token): """Handle action.devices.SYNC request. https://developers.google.com/actions/smarthome/create-app#actiondevicessync """ devices = [] - states = {} aogDevs.clear() getDevices() # sync all devices getSettings() @@ -826,14 +838,6 @@ def smarthome_sync(self, payload, token): continue devices.append(serialized) - if state.report_state: - try: - states[entity.entity_id] = entity.query_serialize() - except: - continue - - if enableReport: - t = threading.Thread(target=self.delay_report_state, args=(states, token)).start() response = {'agentUserId': agent_user_id, 'devices': devices} @@ -861,7 +865,7 @@ def smarthome_query(self, payload, token): devices[devid] = e.query_serialize() response = {'devices': devices} - logger.debug("Response " + json.dumps(response, indent=2, sort_keys=True, ensure_ascii=False)) + logger.info("Response " + json.dumps(response, indent=2, sort_keys=True, ensure_ascii=False)) if state.report_state == True and enableReport == True: self.report_state(devices, token) @@ -913,7 +917,7 @@ def smarthome_exec(self, payload, token): continue entity.async_update() final_results.append({'ids': [entity.entity_id], 'status': 'SUCCESS', 'states': entity.query_serialize()}) - + return {'commands': final_results} def smarthome_disconnect(self, payload, token): @@ -926,6 +930,7 @@ def smarthome_disconnect(self, payload, token): smarthomeGetMappings = {"/smarthome": SmartHomeReqHandler.smarthome, "/sync": SmartHomeReqHandler.syncDevices, "/settings": SmartHomeReqHandler.settings, + "/log": SmartHomeReqHandler.log, "/restart": SmartHomeReqHandler.restartServer} smarthomePostMappings = {"/smarthome": SmartHomeReqHandler.smarthome_post, From 7274785a45ad3e5266c68acaa9c42ec839ae3602 Mon Sep 17 00:00:00 2001 From: DewGew Date: Thu, 5 Nov 2020 17:43:22 +0100 Subject: [PATCH 10/84] Added path for css, js and jpg --- server.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/server.py b/server.py index 7ccd8db1..4ca951c9 100644 --- a/server.py +++ b/server.py @@ -3,6 +3,7 @@ import http.server import urllib.parse from urllib.parse import urlparse +from helpers import FILE_DIR from smarthome import * # import cgi @@ -54,6 +55,30 @@ def do_POST(self): self.send_message(404, "Page not found!: %s" % error) def send_message(self, code, msg, headers=None, b=False): + if self.path.endswith(".jpg"): + f = open(FILE_DIR + self.path, 'rb') + self.send_response(200) + self.send_header('Content-type', 'image/jpg') + self.end_headers() + self.wfile.write(f.read()) + f.close() + return + elif self.path.endswith(".js"): + f = open(FILE_DIR + self.path, 'rb') + self.send_response(200) + self.send_header('Content-type', 'text/javascript') + self.end_headers() + self.wfile.write(f.read()) + f.close() + return + elif self.path.endswith(".css"): + f = open(FILE_DIR + self.path, 'rb') + self.send_response(200) + self.send_header('Content-type', 'text/css') + self.end_headers() + self.wfile.write(f.read()) + f.close() + return self.send_response(code) self.send_header('Content-type', 'text/html; charset=utf-8') if headers is not None: From 1a6e1379a4c4da1c84427e2db49330ce362c9e54 Mon Sep 17 00:00:00 2001 From: DewGew Date: Thu, 5 Nov 2020 17:45:36 +0100 Subject: [PATCH 11/84] Add gueryOnlyOnOff for sensors --- trait.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/trait.py b/trait.py index bb520f72..17109783 100644 --- a/trait.py +++ b/trait.py @@ -151,7 +151,12 @@ def supported(domain, features): def sync_attributes(self): """Return OnOff attributes for a sync request.""" - return {} + domain = self.state.domain + response = {} + if domain in [domains['sensor'], domains['smokedetector']]: + response['queryOnlyOnOff'] = True + + return response def query_attributes(self): """Return OnOff query attributes.""" @@ -328,7 +333,6 @@ def supported(domain, features): def sync_attributes(self): """Return OpenClose attributes for a sync request.""" - # Neither supported domain can support sceneReversible return {} def query_attributes(self): From 1b0e6c4479c875cc85421c00b34aaff996614432 Mon Sep 17 00:00:00 2001 From: DewGew Date: Thu, 5 Nov 2020 17:47:41 +0100 Subject: [PATCH 12/84] Remove old UI template --- const.py | 371 ------------------------------------------------------- 1 file changed, 371 deletions(-) diff --git a/const.py b/const.py index 2beffd4c..8800086e 100644 --- a/const.py +++ b/const.py @@ -173,374 +173,3 @@ domains['waterheater']: TYPE_WATERHEATER, domains['window']: TYPE_WINDOW, } - -TEMPLATE = """ - - - - Domoticz Google Assistant v""" + VERSION + """ - - - {meta} - - - - - - - - - - - - - - -
-
- -
-
-
-


This project is based on Pawcio's script at domoticz forum
-

Before you can use dzga. Setup Action on Google and configure settings in configuration.

-

Domoticz-Google-Assistant delivers:
-

    -
  • The oauth authorization and smarthome endpoint for the google assistant
  • -
  • Two-factor authentication pin for domoticz protected devices (limited language support)
  • -
  • Acknowledgement with Yes or No. (limited language support)
  • -
  • Arm Disarm Securitypanel (limited language support)
  • -
  • Supports Ngrok and SSL
  • -
  • Function to change device type, icon and some behavior depending on the device.
  • -
-

Please feel free to modify, extend and improve it!

-

- - GitHub issues - - - Discord - -

-
-
-

-

- - -
- - Quick start
- Visit the Actions on Google console at http://console.actions.google.com.
Under Develop section, replace the fulfillment URL in Actions with:
- {public_url}/smarthome

- In Account linking, set the Authorization URL to:
- {public_url}/oauth

- Then set the Token URL to:
- {public_url}/token

- Finally press SAVE and then TEST button
-
-
-
-
-
- timelapse DZGA Uptime:
{uptime}
-
-
- DZGA Version:
""" + VERSION + """ {branch}
- Domoticz Version:
{dzversion}


- -
-
-
-
- -
-
-
-
- - - - -
-
- - - - - - - - - - - - - -""" From 88b1275e99b50ffe30b3832a5b86e1b097af1551 Mon Sep 17 00:00:00 2001 From: DewGew Date: Thu, 5 Nov 2020 17:49:55 +0100 Subject: [PATCH 13/84] Remove old UI template --- smarthome.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/smarthome.py b/smarthome.py index c67f4124..b1814b21 100644 --- a/smarthome.py +++ b/smarthome.py @@ -16,7 +16,7 @@ import trait from auth import * from const import (DOMOTICZ_TO_GOOGLE_TYPES, ERR_FUNCTION_NOT_SUPPORTED, ERR_PROTOCOL_ERROR, ERR_DEVICE_OFFLINE, - TEMPLATE, ERR_UNKNOWN_ERROR, ERR_CHALLENGE_NEEDED, DOMOTICZ_GET_ALL_DEVICES_URL, domains, + ERR_UNKNOWN_ERROR, ERR_CHALLENGE_NEEDED, DOMOTICZ_GET_ALL_DEVICES_URL, domains, DOMOTICZ_GET_SETTINGS_URL, DOMOTICZ_GET_ONE_DEVICE_URL, DOMOTICZ_GET_SCENES_URL, CONFIGFILE, LOGFILE, REQUEST_SYNC_BASE_URL, REPORT_STATE_BASE_URL, ATTRS_BRIGHTNESS, ATTRS_FANSPEED, ATTRS_VACUUM_MODES, ATTRS_THERMSTATSETPOINT, ATTRS_COLOR_TEMP, ATTRS_PERCENTAGE, VERSION, DOMOTICZ_GET_VERSION) From 8a998658ce9c4dfcc438fef431a46f186a300955 Mon Sep 17 00:00:00 2001 From: DewGew Date: Thu, 5 Nov 2020 17:54:57 +0100 Subject: [PATCH 14/84] Create README.md --- templates/js/README.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 templates/js/README.md diff --git a/templates/js/README.md b/templates/js/README.md new file mode 100644 index 00000000..bcc3aa52 --- /dev/null +++ b/templates/js/README.md @@ -0,0 +1 @@ +Custom js files From 13cf0cba90f35ee208e0744c7a3425513446b9b5 Mon Sep 17 00:00:00 2001 From: DewGew Date: Thu, 5 Nov 2020 17:55:27 +0100 Subject: [PATCH 15/84] Add files via upload --- templates/base.html | 121 +++++++++++++++++++++++++++++++++++++++++ templates/config.html | 23 ++++++++ templates/devices.html | 30 ++++++++++ templates/footer.html | 30 ++++++++++ templates/help.html | 20 +++++++ templates/home.html | 98 +++++++++++++++++++++++++++++++++ templates/logs.html | 26 +++++++++ templates/navbar.html | 61 +++++++++++++++++++++ templates/sidebar.html | 70 ++++++++++++++++++++++++ 9 files changed, 479 insertions(+) create mode 100644 templates/base.html create mode 100644 templates/config.html create mode 100644 templates/devices.html create mode 100644 templates/footer.html create mode 100644 templates/help.html create mode 100644 templates/home.html create mode 100644 templates/logs.html create mode 100644 templates/navbar.html create mode 100644 templates/sidebar.html diff --git a/templates/base.html b/templates/base.html new file mode 100644 index 00000000..7f635adc --- /dev/null +++ b/templates/base.html @@ -0,0 +1,121 @@ + + + + + +{% block title %}Domoticz Google Assistant{% endblock %} + + +{{ meta }} + + + + + + + + + + + +
+ + +
+ {% include 'navbar.html' %} +
+
+
+ {% block content%} + + {% endblock %} +
+
+
+ {% include 'footer.html' %} +
+
+ + + + +{% block javascript %} + + + + + + + + + + + + +{% endblock %} + + \ No newline at end of file diff --git a/templates/config.html b/templates/config.html new file mode 100644 index 00000000..ebb5344b --- /dev/null +++ b/templates/config.html @@ -0,0 +1,23 @@ + \ No newline at end of file diff --git a/templates/devices.html b/templates/devices.html new file mode 100644 index 00000000..fec2a93f --- /dev/null +++ b/templates/devices.html @@ -0,0 +1,30 @@ + \ No newline at end of file diff --git a/templates/footer.html b/templates/footer.html new file mode 100644 index 00000000..0a126f8c --- /dev/null +++ b/templates/footer.html @@ -0,0 +1,30 @@ + \ No newline at end of file diff --git a/templates/help.html b/templates/help.html new file mode 100644 index 00000000..0775036c --- /dev/null +++ b/templates/help.html @@ -0,0 +1,20 @@ + diff --git a/templates/home.html b/templates/home.html new file mode 100644 index 00000000..ae4f9896 --- /dev/null +++ b/templates/home.html @@ -0,0 +1,98 @@ +{% extends 'base.html' %} + +{% block title%}Home{% endblock %} + +{% block content %} +
+
+
+
+
+

About Domoticz-Google-Assistant

+

+
+
+


This project is based on Pawcio's script at domoticz forum
+

Before you can use dzga. Setup Action on Google and configure settings in configuration.

+

Domoticz-Google-Assistant delivers:
+

    +
  • The oauth authorization and smarthome endpoint for the google assistant
  • +
  • Two-factor authentication pin for domoticz protected devices (limited language support)
  • +
  • Acknowledgement with Yes or No. (limited language support)
  • +
  • Arm Disarm Securitypanel (limited language support)
  • +
  • Supports Ngrok and SSL
  • +
  • Function to change device type, icon and some behavior depending on the device.
  • +
+

Please feel free to modify, extend and improve it!

+

+ + GitHub issues + + + Discord + +

+
+
+
+
+
+
+

Quick start

+

+
+
+ + Visit the Actions on Google console at http://console.actions.google.com.
Under Develop section, replace the fulfillment URL in Actions with:
+ {{ public_url }}/smarthome

+ In Account linking, set the Authorization URL to:
+ {{ public_url }}/oauth

+ Then set the Token URL to:
+ {{ public_url }}/token

+ Finally press SAVE and then TEST button
+
+
+
+
+
+
+
+
+
+

Information

+

+
+
+ timelapse DZGA Uptime:
{{ uptime }}

+ DZGA Version:
{{ dzgaversion }} {{ branch }}
+ Domoticz Version:
{{ dzversion }}


+
+
+
+
+
+
+

Functions

+

+
+
+
+ + +
+
+
+
+
+
+
+ +{% include 'devices.html' %} + +{% include 'config.html' %} + +{% include 'help.html' %} + +{% include 'logs.html' %} + +{% endblock %} \ No newline at end of file diff --git a/templates/logs.html b/templates/logs.html new file mode 100644 index 00000000..274e6c9b --- /dev/null +++ b/templates/logs.html @@ -0,0 +1,26 @@ + \ No newline at end of file diff --git a/templates/navbar.html b/templates/navbar.html new file mode 100644 index 00000000..43c16435 --- /dev/null +++ b/templates/navbar.html @@ -0,0 +1,61 @@ + + + \ No newline at end of file diff --git a/templates/sidebar.html b/templates/sidebar.html new file mode 100644 index 00000000..015b6db0 --- /dev/null +++ b/templates/sidebar.html @@ -0,0 +1,70 @@ +
+ +
\ No newline at end of file From c8ead4381d5819f31ccb7b6ec6bb5f7770085010 Mon Sep 17 00:00:00 2001 From: DewGew Date: Thu, 5 Nov 2020 17:57:23 +0100 Subject: [PATCH 16/84] Add files via upload --- templates/js/myscript.js | 175 +++++++++++++++++++++++++++++++++++++++ templates/js/sidebar.js | 169 +++++++++++++++++++++++++++++++++++++ 2 files changed, 344 insertions(+) create mode 100644 templates/js/myscript.js create mode 100644 templates/js/sidebar.js diff --git a/templates/js/myscript.js b/templates/js/myscript.js new file mode 100644 index 00000000..d2120778 --- /dev/null +++ b/templates/js/myscript.js @@ -0,0 +1,175 @@ +/* Main */ +var config = {{ conf }} +var updates = {{ update }} +/* document.getElementById("logsheader").innerHTML = 'Logs
Loglevel: ' + config.loglevel + ''; */ +if (updates) { + document.getElementById("updates").innerHTML = "(Updates are Availible)"; + $('#buttonUpdate').append('
'); +}; + +// Add Active Class to Current Element sidebar +var btnContainer = document.getElementById("sidebar"); +var btns = btnContainer.getElementsByClassName("nav-item"); +for (var i = 0; i < btns.length; i++) { + btns[i].addEventListener("click", function() { + var current = document.getElementsByClassName("active"); + if (current.length > 0) { + current[0].className = current[0].className.replace(" active", ""); + } + this.className += " active"; + }); +} + +if (config.auth_user == 'admin' || config.auth_pass == 'admin'){ + $('#messageModal').modal('show') +}; +message = '{{ message }}' +if (message != '') { + document.getElementById("modalLabel").innerHTML = "Information!"; + document.getElementById("message").innerHTML = message; + $('#messageModal').modal('show') +}; + +/* Device page */ +function sortTable(n) { + var table, rows, switching, i, x, y, shouldSwitch, dir, switchcount = 0; + table = document.getElementById("deviceTable"); + switching = true; + dir = "asc"; + while (switching) { + switching = false; + rows = table.rows; + for (i = 1; i < (rows.length - 1); i++) { + shouldSwitch = false; + x = rows[i].getElementsByTagName("TD")[n]; + y = rows[i + 1].getElementsByTagName("TD")[n]; + if (dir == "asc") { + if (x.innerHTML.toLowerCase() > y.innerHTML.toLowerCase()) { + shouldSwitch = true; + break; + } + } else if (dir == "desc") { + if (x.innerHTML.toLowerCase() < y.innerHTML.toLowerCase()) { + shouldSwitch = true; + break; + } + } + } + if (shouldSwitch) { + rows[i].parentNode.insertBefore(rows[i + 1], rows[i]); + switching = true; + switchcount ++; + } else { + if (switchcount == 0 && dir == "asc") { + dir = "desc"; + switching = true; + } + } + } +} +function sortIdxTable(n) { + var table, rows, switching, i, x, y, shouldSwitch, dir, switchcount = 0; + table = document.getElementById("deviceTable"); + switching = true; + dir = "asc"; + while (switching) { + switching = false; + rows = table.rows; + for (i = 1; i < (rows.length - 1); i++) { + shouldSwitch = false; + x = rows[i].getElementsByTagName("TH")[n]; + y = rows[i + 1].getElementsByTagName("TH")[n]; + if (dir == "asc") { + if (Number(x.innerHTML) > Number(y.innerHTML)) { + shouldSwitch = true; + break; + } + } else if (dir == "desc") { + if (Number(x.innerHTML) < Number(y.innerHTML)) { + shouldSwitch = true; + break; + } + } + } + if (shouldSwitch) { + rows[i].parentNode.insertBefore(rows[i + 1], rows[i]); + switching = true; + switchcount ++; + } else { + if (switchcount == 0 && dir == "asc") { + dir = "desc"; + switching = true; + } + } + } +} + +function readDevices(){ + var devicelist = {{ list }} + + var xl, i, nicknames = ""; + for (i in devicelist){ + if (devicelist[i][4] == undefined) { + devicelist[i][4] = " " + } + if (devicelist[i][5] == undefined) { + nicknames = " "; + }else{ nicknames = " (" + devicelist[i][5] + ")"} + xl += "" + devicelist[i][1] + "" + devicelist[i][0] + nicknames + "" + devicelist[i][2] + "" + devicelist[i][3] + "" + devicelist[i][4] + ""; + console.log(devicelist[i][1] + " - " + devicelist[i][3]) + }; + if (typeof xl !== "undefined"){ + $('#deviceList_idx').html(xl.replace('undefined','')); + }else{ + document.getElementById("modalLabel").innerHTML = "Check configuration."; + document.getElementById("message").innerHTML = "Connection to Domoticz refused! Check configuration."; + $('#messageModal').modal('show') + }; + console.log($('#deviceList_idx').length) + +} +readDevices() + +/* config page */ +var editor = CodeMirror.fromTextArea(document.getElementById("code"), { + lineNumbers: true, + mode: "yaml", + autoRefresh:true +}); +editor.setOption("extraKeys", { + Tab: function(cm) { + var spaces = Array(cm.getOption("indentUnit") + 1).join(" "); + cm.replaceSelection(spaces); + } +}); +editor.on("change", function() { + textTosave = editor.getValue(); + document.getElementById("save").value = textTosave; + }); + +document.getElementById("save").value = document.getElementById("code").value + +/* Logs page */ +function readTextFile(){ + var x = document.getElementById("autoScroll").checked; //if autoscrool is checked + if(x==true){ + document.getElementById("logs").scrollTop = document.getElementById("logs").scrollHeight; //autoscroll + } + + var filePath = "/log" + + $.ajax({ + dataType: "text", + success : function (data) { + $("#logs").load(filePath); + } + }); + +} +readTextFile() +setInterval(readTextFile, 5000); + + + + + diff --git a/templates/js/sidebar.js b/templates/js/sidebar.js new file mode 100644 index 00000000..0090082e --- /dev/null +++ b/templates/js/sidebar.js @@ -0,0 +1,169 @@ +$(document).ready(function() { + $().ready(function() { + $sidebar = $('.sidebar'); + + $sidebar_img_container = $sidebar.find('.sidebar-background'); + + $full_page = $('.full-page'); + + $sidebar_responsive = $('body > .navbar-collapse'); + + window_width = $(window).width(); + + fixed_plugin_open = $('.sidebar .sidebar-wrapper .nav li.active a p').html(); + + if (window_width > 767 && fixed_plugin_open == 'Dashboard') { + if ($('.fixed-plugin .dropdown').hasClass('show-dropdown')) { + $('.fixed-plugin .dropdown').addClass('open'); + } + + } + + $('.fixed-plugin a').click(function(event) { + // Alex if we click on switch, stop propagation of the event, so the dropdown will not be hide, otherwise we set the section active + if ($(this).hasClass('switch-trigger')) { + if (event.stopPropagation) { + event.stopPropagation(); + } else if (window.event) { + window.event.cancelBubble = true; + } + } + }); + + $('.fixed-plugin .active-color span').click(function() { + $full_page_background = $('.full-page-background'); + + $(this).siblings().removeClass('active'); + $(this).addClass('active'); + + var new_color = $(this).data('color'); + + if ($sidebar.length != 0) { + $sidebar.attr('data-color', new_color); + } + + if ($full_page.length != 0) { + $full_page.attr('filter-color', new_color); + } + + if ($sidebar_responsive.length != 0) { + $sidebar_responsive.attr('data-color', new_color); + } + }); + + $('.fixed-plugin .background-color .badge').click(function() { + $(this).siblings().removeClass('active'); + $(this).addClass('active'); + + var new_color = $(this).data('background-color'); + + if ($sidebar.length != 0) { + $sidebar.attr('data-background-color', new_color); + } + }); + + $('.fixed-plugin .img-holder').click(function() { + $full_page_background = $('.full-page-background'); + + $(this).parent('li').siblings().removeClass('active'); + $(this).parent('li').addClass('active'); + + + var new_image = $(this).find("img").attr('src'); + + if ($sidebar_img_container.length != 0 && $('.switch-sidebar-image input:checked').length != 0) { + $sidebar_img_container.fadeOut('fast', function() { + $sidebar_img_container.css('background-image', 'url("' + new_image + '")'); + $sidebar_img_container.fadeIn('fast'); + }); + } + + if ($full_page_background.length != 0 && $('.switch-sidebar-image input:checked').length != 0) { + var new_image_full_page = $('.fixed-plugin li.active .img-holder').find('img').data('src'); + + $full_page_background.fadeOut('fast', function() { + $full_page_background.css('background-image', 'url("' + new_image_full_page + '")'); + $full_page_background.fadeIn('fast'); + }); + } + + if ($('.switch-sidebar-image input:checked').length == 0) { + var new_image = $('.fixed-plugin li.active .img-holder').find("img").attr('src'); + var new_image_full_page = $('.fixed-plugin li.active .img-holder').find('img').data('src'); + + $sidebar_img_container.css('background-image', 'url("' + new_image + '")'); + $full_page_background.css('background-image', 'url("' + new_image_full_page + '")'); + } + + if ($sidebar_responsive.length != 0) { + $sidebar_responsive.css('background-image', 'url("' + new_image + '")'); + } + }); + + $('.switch-sidebar-image input').change(function() { + $full_page_background = $('.full-page-background'); + + $input = $(this); + + if ($input.is(':checked')) { + if ($sidebar_img_container.length != 0) { + $sidebar_img_container.fadeIn('fast'); + $sidebar.attr('data-image', '#'); + } + + if ($full_page_background.length != 0) { + $full_page_background.fadeIn('fast'); + $full_page.attr('data-image', '#'); + } + + background_image = true; + } else { + if ($sidebar_img_container.length != 0) { + $sidebar.removeAttr('data-image'); + $sidebar_img_container.fadeOut('fast'); + } + + if ($full_page_background.length != 0) { + $full_page.removeAttr('data-image', '#'); + $full_page_background.fadeOut('fast'); + } + + background_image = false; + } + }); + + $('.switch-sidebar-mini input').change(function() { + $body = $('body'); + + $input = $(this); + + if (md.misc.sidebar_mini_active == true) { + $('body').removeClass('sidebar-mini'); + md.misc.sidebar_mini_active = false; + + $('.sidebar .sidebar-wrapper, .main-panel').perfectScrollbar(); + + } else { + + $('.sidebar .sidebar-wrapper, .main-panel').perfectScrollbar('destroy'); + + setTimeout(function() { + $('body').addClass('sidebar-mini'); + + md.misc.sidebar_mini_active = true; + }, 300); + } + + // we simulate the window Resize so the charts will get updated in realtime. + var simulateWindowResize = setInterval(function() { + window.dispatchEvent(new Event('resize')); + }, 180); + + // we stop the simulation of Window Resize after the animations are completed + setTimeout(function() { + clearInterval(simulateWindowResize); + }, 1000); + + }); + }); +}); \ No newline at end of file From 5c243024a4de9513a17f0fbd85716ff51ced453d Mon Sep 17 00:00:00 2001 From: DewGew Date: Thu, 5 Nov 2020 18:04:31 +0100 Subject: [PATCH 17/84] Delete README.md --- templates/js/README.md | 1 - 1 file changed, 1 deletion(-) delete mode 100644 templates/js/README.md diff --git a/templates/js/README.md b/templates/js/README.md deleted file mode 100644 index bcc3aa52..00000000 --- a/templates/js/README.md +++ /dev/null @@ -1 +0,0 @@ -Custom js files From f70525dca72b0d6efcff5544ec2d6849fe1c50e8 Mon Sep 17 00:00:00 2001 From: DewGew Date: Thu, 5 Nov 2020 18:04:51 +0100 Subject: [PATCH 18/84] Delete myscript.js --- templates/js/myscript.js | 175 --------------------------------------- 1 file changed, 175 deletions(-) delete mode 100644 templates/js/myscript.js diff --git a/templates/js/myscript.js b/templates/js/myscript.js deleted file mode 100644 index d2120778..00000000 --- a/templates/js/myscript.js +++ /dev/null @@ -1,175 +0,0 @@ -/* Main */ -var config = {{ conf }} -var updates = {{ update }} -/* document.getElementById("logsheader").innerHTML = 'Logs
Loglevel: ' + config.loglevel + ''; */ -if (updates) { - document.getElementById("updates").innerHTML = "(Updates are Availible)"; - $('#buttonUpdate').append('
'); -}; - -// Add Active Class to Current Element sidebar -var btnContainer = document.getElementById("sidebar"); -var btns = btnContainer.getElementsByClassName("nav-item"); -for (var i = 0; i < btns.length; i++) { - btns[i].addEventListener("click", function() { - var current = document.getElementsByClassName("active"); - if (current.length > 0) { - current[0].className = current[0].className.replace(" active", ""); - } - this.className += " active"; - }); -} - -if (config.auth_user == 'admin' || config.auth_pass == 'admin'){ - $('#messageModal').modal('show') -}; -message = '{{ message }}' -if (message != '') { - document.getElementById("modalLabel").innerHTML = "Information!"; - document.getElementById("message").innerHTML = message; - $('#messageModal').modal('show') -}; - -/* Device page */ -function sortTable(n) { - var table, rows, switching, i, x, y, shouldSwitch, dir, switchcount = 0; - table = document.getElementById("deviceTable"); - switching = true; - dir = "asc"; - while (switching) { - switching = false; - rows = table.rows; - for (i = 1; i < (rows.length - 1); i++) { - shouldSwitch = false; - x = rows[i].getElementsByTagName("TD")[n]; - y = rows[i + 1].getElementsByTagName("TD")[n]; - if (dir == "asc") { - if (x.innerHTML.toLowerCase() > y.innerHTML.toLowerCase()) { - shouldSwitch = true; - break; - } - } else if (dir == "desc") { - if (x.innerHTML.toLowerCase() < y.innerHTML.toLowerCase()) { - shouldSwitch = true; - break; - } - } - } - if (shouldSwitch) { - rows[i].parentNode.insertBefore(rows[i + 1], rows[i]); - switching = true; - switchcount ++; - } else { - if (switchcount == 0 && dir == "asc") { - dir = "desc"; - switching = true; - } - } - } -} -function sortIdxTable(n) { - var table, rows, switching, i, x, y, shouldSwitch, dir, switchcount = 0; - table = document.getElementById("deviceTable"); - switching = true; - dir = "asc"; - while (switching) { - switching = false; - rows = table.rows; - for (i = 1; i < (rows.length - 1); i++) { - shouldSwitch = false; - x = rows[i].getElementsByTagName("TH")[n]; - y = rows[i + 1].getElementsByTagName("TH")[n]; - if (dir == "asc") { - if (Number(x.innerHTML) > Number(y.innerHTML)) { - shouldSwitch = true; - break; - } - } else if (dir == "desc") { - if (Number(x.innerHTML) < Number(y.innerHTML)) { - shouldSwitch = true; - break; - } - } - } - if (shouldSwitch) { - rows[i].parentNode.insertBefore(rows[i + 1], rows[i]); - switching = true; - switchcount ++; - } else { - if (switchcount == 0 && dir == "asc") { - dir = "desc"; - switching = true; - } - } - } -} - -function readDevices(){ - var devicelist = {{ list }} - - var xl, i, nicknames = ""; - for (i in devicelist){ - if (devicelist[i][4] == undefined) { - devicelist[i][4] = " " - } - if (devicelist[i][5] == undefined) { - nicknames = " "; - }else{ nicknames = " (" + devicelist[i][5] + ")"} - xl += "" + devicelist[i][1] + "" + devicelist[i][0] + nicknames + "" + devicelist[i][2] + "" + devicelist[i][3] + "" + devicelist[i][4] + ""; - console.log(devicelist[i][1] + " - " + devicelist[i][3]) - }; - if (typeof xl !== "undefined"){ - $('#deviceList_idx').html(xl.replace('undefined','')); - }else{ - document.getElementById("modalLabel").innerHTML = "Check configuration."; - document.getElementById("message").innerHTML = "Connection to Domoticz refused! Check configuration."; - $('#messageModal').modal('show') - }; - console.log($('#deviceList_idx').length) - -} -readDevices() - -/* config page */ -var editor = CodeMirror.fromTextArea(document.getElementById("code"), { - lineNumbers: true, - mode: "yaml", - autoRefresh:true -}); -editor.setOption("extraKeys", { - Tab: function(cm) { - var spaces = Array(cm.getOption("indentUnit") + 1).join(" "); - cm.replaceSelection(spaces); - } -}); -editor.on("change", function() { - textTosave = editor.getValue(); - document.getElementById("save").value = textTosave; - }); - -document.getElementById("save").value = document.getElementById("code").value - -/* Logs page */ -function readTextFile(){ - var x = document.getElementById("autoScroll").checked; //if autoscrool is checked - if(x==true){ - document.getElementById("logs").scrollTop = document.getElementById("logs").scrollHeight; //autoscroll - } - - var filePath = "/log" - - $.ajax({ - dataType: "text", - success : function (data) { - $("#logs").load(filePath); - } - }); - -} -readTextFile() -setInterval(readTextFile, 5000); - - - - - From f9b655d3b1d329ca5957f1ff8e4001979c8cecdf Mon Sep 17 00:00:00 2001 From: DewGew Date: Thu, 5 Nov 2020 18:05:01 +0100 Subject: [PATCH 19/84] Delete sidebar.js --- templates/js/sidebar.js | 169 ---------------------------------------- 1 file changed, 169 deletions(-) delete mode 100644 templates/js/sidebar.js diff --git a/templates/js/sidebar.js b/templates/js/sidebar.js deleted file mode 100644 index 0090082e..00000000 --- a/templates/js/sidebar.js +++ /dev/null @@ -1,169 +0,0 @@ -$(document).ready(function() { - $().ready(function() { - $sidebar = $('.sidebar'); - - $sidebar_img_container = $sidebar.find('.sidebar-background'); - - $full_page = $('.full-page'); - - $sidebar_responsive = $('body > .navbar-collapse'); - - window_width = $(window).width(); - - fixed_plugin_open = $('.sidebar .sidebar-wrapper .nav li.active a p').html(); - - if (window_width > 767 && fixed_plugin_open == 'Dashboard') { - if ($('.fixed-plugin .dropdown').hasClass('show-dropdown')) { - $('.fixed-plugin .dropdown').addClass('open'); - } - - } - - $('.fixed-plugin a').click(function(event) { - // Alex if we click on switch, stop propagation of the event, so the dropdown will not be hide, otherwise we set the section active - if ($(this).hasClass('switch-trigger')) { - if (event.stopPropagation) { - event.stopPropagation(); - } else if (window.event) { - window.event.cancelBubble = true; - } - } - }); - - $('.fixed-plugin .active-color span').click(function() { - $full_page_background = $('.full-page-background'); - - $(this).siblings().removeClass('active'); - $(this).addClass('active'); - - var new_color = $(this).data('color'); - - if ($sidebar.length != 0) { - $sidebar.attr('data-color', new_color); - } - - if ($full_page.length != 0) { - $full_page.attr('filter-color', new_color); - } - - if ($sidebar_responsive.length != 0) { - $sidebar_responsive.attr('data-color', new_color); - } - }); - - $('.fixed-plugin .background-color .badge').click(function() { - $(this).siblings().removeClass('active'); - $(this).addClass('active'); - - var new_color = $(this).data('background-color'); - - if ($sidebar.length != 0) { - $sidebar.attr('data-background-color', new_color); - } - }); - - $('.fixed-plugin .img-holder').click(function() { - $full_page_background = $('.full-page-background'); - - $(this).parent('li').siblings().removeClass('active'); - $(this).parent('li').addClass('active'); - - - var new_image = $(this).find("img").attr('src'); - - if ($sidebar_img_container.length != 0 && $('.switch-sidebar-image input:checked').length != 0) { - $sidebar_img_container.fadeOut('fast', function() { - $sidebar_img_container.css('background-image', 'url("' + new_image + '")'); - $sidebar_img_container.fadeIn('fast'); - }); - } - - if ($full_page_background.length != 0 && $('.switch-sidebar-image input:checked').length != 0) { - var new_image_full_page = $('.fixed-plugin li.active .img-holder').find('img').data('src'); - - $full_page_background.fadeOut('fast', function() { - $full_page_background.css('background-image', 'url("' + new_image_full_page + '")'); - $full_page_background.fadeIn('fast'); - }); - } - - if ($('.switch-sidebar-image input:checked').length == 0) { - var new_image = $('.fixed-plugin li.active .img-holder').find("img").attr('src'); - var new_image_full_page = $('.fixed-plugin li.active .img-holder').find('img').data('src'); - - $sidebar_img_container.css('background-image', 'url("' + new_image + '")'); - $full_page_background.css('background-image', 'url("' + new_image_full_page + '")'); - } - - if ($sidebar_responsive.length != 0) { - $sidebar_responsive.css('background-image', 'url("' + new_image + '")'); - } - }); - - $('.switch-sidebar-image input').change(function() { - $full_page_background = $('.full-page-background'); - - $input = $(this); - - if ($input.is(':checked')) { - if ($sidebar_img_container.length != 0) { - $sidebar_img_container.fadeIn('fast'); - $sidebar.attr('data-image', '#'); - } - - if ($full_page_background.length != 0) { - $full_page_background.fadeIn('fast'); - $full_page.attr('data-image', '#'); - } - - background_image = true; - } else { - if ($sidebar_img_container.length != 0) { - $sidebar.removeAttr('data-image'); - $sidebar_img_container.fadeOut('fast'); - } - - if ($full_page_background.length != 0) { - $full_page.removeAttr('data-image', '#'); - $full_page_background.fadeOut('fast'); - } - - background_image = false; - } - }); - - $('.switch-sidebar-mini input').change(function() { - $body = $('body'); - - $input = $(this); - - if (md.misc.sidebar_mini_active == true) { - $('body').removeClass('sidebar-mini'); - md.misc.sidebar_mini_active = false; - - $('.sidebar .sidebar-wrapper, .main-panel').perfectScrollbar(); - - } else { - - $('.sidebar .sidebar-wrapper, .main-panel').perfectScrollbar('destroy'); - - setTimeout(function() { - $('body').addClass('sidebar-mini'); - - md.misc.sidebar_mini_active = true; - }, 300); - } - - // we simulate the window Resize so the charts will get updated in realtime. - var simulateWindowResize = setInterval(function() { - window.dispatchEvent(new Event('resize')); - }, 180); - - // we stop the simulation of Window Resize after the animations are completed - setTimeout(function() { - clearInterval(simulateWindowResize); - }, 1000); - - }); - }); -}); \ No newline at end of file From 5aca76de0eb6e036b6ec7b3bbd486b297b42afd7 Mon Sep 17 00:00:00 2001 From: DewGew Date: Thu, 5 Nov 2020 18:05:10 +0100 Subject: [PATCH 20/84] Delete base.html --- templates/base.html | 121 -------------------------------------------- 1 file changed, 121 deletions(-) delete mode 100644 templates/base.html diff --git a/templates/base.html b/templates/base.html deleted file mode 100644 index 7f635adc..00000000 --- a/templates/base.html +++ /dev/null @@ -1,121 +0,0 @@ - - - - - -{% block title %}Domoticz Google Assistant{% endblock %} - - -{{ meta }} - - - - - - - - - - - -
- - -
- {% include 'navbar.html' %} -
-
-
- {% block content%} - - {% endblock %} -
-
-
- {% include 'footer.html' %} -
-
- - - - -{% block javascript %} - - - - - - - - - - - - -{% endblock %} - - \ No newline at end of file From 2e7f42d2c797eba6191610f4a8b4ecfb8d7e0d36 Mon Sep 17 00:00:00 2001 From: DewGew Date: Thu, 5 Nov 2020 18:05:18 +0100 Subject: [PATCH 21/84] Delete config.html --- templates/config.html | 23 ----------------------- 1 file changed, 23 deletions(-) delete mode 100644 templates/config.html diff --git a/templates/config.html b/templates/config.html deleted file mode 100644 index ebb5344b..00000000 --- a/templates/config.html +++ /dev/null @@ -1,23 +0,0 @@ - \ No newline at end of file From 5bf120cec55c9f787743245963a3ef1864114e4e Mon Sep 17 00:00:00 2001 From: DewGew Date: Thu, 5 Nov 2020 18:05:25 +0100 Subject: [PATCH 22/84] Delete devices.html --- templates/devices.html | 30 ------------------------------ 1 file changed, 30 deletions(-) delete mode 100644 templates/devices.html diff --git a/templates/devices.html b/templates/devices.html deleted file mode 100644 index fec2a93f..00000000 --- a/templates/devices.html +++ /dev/null @@ -1,30 +0,0 @@ - \ No newline at end of file From a2d342229dbc816d228a6da4eb42b0afe257a4d7 Mon Sep 17 00:00:00 2001 From: DewGew Date: Thu, 5 Nov 2020 18:05:32 +0100 Subject: [PATCH 23/84] Delete footer.html --- templates/footer.html | 30 ------------------------------ 1 file changed, 30 deletions(-) delete mode 100644 templates/footer.html diff --git a/templates/footer.html b/templates/footer.html deleted file mode 100644 index 0a126f8c..00000000 --- a/templates/footer.html +++ /dev/null @@ -1,30 +0,0 @@ - \ No newline at end of file From 1339a40c7da932390981e8a929f1e6675ec4f57b Mon Sep 17 00:00:00 2001 From: DewGew Date: Thu, 5 Nov 2020 18:05:40 +0100 Subject: [PATCH 24/84] Delete help.html --- templates/help.html | 20 -------------------- 1 file changed, 20 deletions(-) delete mode 100644 templates/help.html diff --git a/templates/help.html b/templates/help.html deleted file mode 100644 index 0775036c..00000000 --- a/templates/help.html +++ /dev/null @@ -1,20 +0,0 @@ - From 52b7576c5cdee1abe5415a0483e66babd80cabd2 Mon Sep 17 00:00:00 2001 From: DewGew Date: Thu, 5 Nov 2020 18:05:48 +0100 Subject: [PATCH 25/84] Delete home.html --- templates/home.html | 98 --------------------------------------------- 1 file changed, 98 deletions(-) delete mode 100644 templates/home.html diff --git a/templates/home.html b/templates/home.html deleted file mode 100644 index ae4f9896..00000000 --- a/templates/home.html +++ /dev/null @@ -1,98 +0,0 @@ -{% extends 'base.html' %} - -{% block title%}Home{% endblock %} - -{% block content %} -
-
-
-
-
-

About Domoticz-Google-Assistant

-

-
-
-


This project is based on Pawcio's script at domoticz forum
-

Before you can use dzga. Setup Action on Google and configure settings in configuration.

-

Domoticz-Google-Assistant delivers:
-

    -
  • The oauth authorization and smarthome endpoint for the google assistant
  • -
  • Two-factor authentication pin for domoticz protected devices (limited language support)
  • -
  • Acknowledgement with Yes or No. (limited language support)
  • -
  • Arm Disarm Securitypanel (limited language support)
  • -
  • Supports Ngrok and SSL
  • -
  • Function to change device type, icon and some behavior depending on the device.
  • -
-

Please feel free to modify, extend and improve it!

-

- - GitHub issues - - - Discord - -

-
-
-
-
-
-
-

Quick start

-

-
-
- - Visit the Actions on Google console at http://console.actions.google.com.
Under Develop section, replace the fulfillment URL in Actions with:
- {{ public_url }}/smarthome

- In Account linking, set the Authorization URL to:
- {{ public_url }}/oauth

- Then set the Token URL to:
- {{ public_url }}/token

- Finally press SAVE and then TEST button
-
-
-
-
-
-
-
-
-
-

Information

-

-
-
- timelapse DZGA Uptime:
{{ uptime }}

- DZGA Version:
{{ dzgaversion }} {{ branch }}
- Domoticz Version:
{{ dzversion }}


-
-
-
-
-
-
-

Functions

-

-
-
-
- - -
-
-
-
-
-
-
- -{% include 'devices.html' %} - -{% include 'config.html' %} - -{% include 'help.html' %} - -{% include 'logs.html' %} - -{% endblock %} \ No newline at end of file From fc336f5d0eec30c9de95a83c6dc8a69bf02a2596 Mon Sep 17 00:00:00 2001 From: DewGew Date: Thu, 5 Nov 2020 18:05:56 +0100 Subject: [PATCH 26/84] Delete logs.html --- templates/logs.html | 26 -------------------------- 1 file changed, 26 deletions(-) delete mode 100644 templates/logs.html diff --git a/templates/logs.html b/templates/logs.html deleted file mode 100644 index 274e6c9b..00000000 --- a/templates/logs.html +++ /dev/null @@ -1,26 +0,0 @@ - \ No newline at end of file From 156fdd0a9c756186fdbb7eccaf2ad3e7a5cb882a Mon Sep 17 00:00:00 2001 From: DewGew Date: Thu, 5 Nov 2020 18:06:03 +0100 Subject: [PATCH 27/84] Delete navbar.html --- templates/navbar.html | 61 ------------------------------------------- 1 file changed, 61 deletions(-) delete mode 100644 templates/navbar.html diff --git a/templates/navbar.html b/templates/navbar.html deleted file mode 100644 index 43c16435..00000000 --- a/templates/navbar.html +++ /dev/null @@ -1,61 +0,0 @@ - - - \ No newline at end of file From ed48688a779a3da49fe872028d77c0607c8946b3 Mon Sep 17 00:00:00 2001 From: DewGew Date: Thu, 5 Nov 2020 18:06:10 +0100 Subject: [PATCH 28/84] Delete sidebar.html --- templates/sidebar.html | 70 ------------------------------------------ 1 file changed, 70 deletions(-) delete mode 100644 templates/sidebar.html diff --git a/templates/sidebar.html b/templates/sidebar.html deleted file mode 100644 index 015b6db0..00000000 --- a/templates/sidebar.html +++ /dev/null @@ -1,70 +0,0 @@ -
- -
\ No newline at end of file From ff7b28fce141eafc2ac26d23fb5dea40fc7b9016 Mon Sep 17 00:00:00 2001 From: DewGew Date: Thu, 5 Nov 2020 18:06:49 +0100 Subject: [PATCH 29/84] Create README.md --- templates/js/README.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 templates/js/README.md diff --git a/templates/js/README.md b/templates/js/README.md new file mode 100644 index 00000000..bcc3aa52 --- /dev/null +++ b/templates/js/README.md @@ -0,0 +1 @@ +Custom js files From 1cd6ff5027466e18660b142198b8dd0ec5624517 Mon Sep 17 00:00:00 2001 From: DewGew Date: Thu, 5 Nov 2020 18:07:08 +0100 Subject: [PATCH 30/84] Add files via upload --- templates/js/myscript.js | 175 +++++++++++++++++++++++++++++++++++++++ templates/js/sidebar.js | 169 +++++++++++++++++++++++++++++++++++++ 2 files changed, 344 insertions(+) create mode 100644 templates/js/myscript.js create mode 100644 templates/js/sidebar.js diff --git a/templates/js/myscript.js b/templates/js/myscript.js new file mode 100644 index 00000000..d2120778 --- /dev/null +++ b/templates/js/myscript.js @@ -0,0 +1,175 @@ +/* Main */ +var config = {{ conf }} +var updates = {{ update }} +/* document.getElementById("logsheader").innerHTML = 'Logs
Loglevel: ' + config.loglevel + ''; */ +if (updates) { + document.getElementById("updates").innerHTML = "(Updates are Availible)"; + $('#buttonUpdate').append('
'); +}; + +// Add Active Class to Current Element sidebar +var btnContainer = document.getElementById("sidebar"); +var btns = btnContainer.getElementsByClassName("nav-item"); +for (var i = 0; i < btns.length; i++) { + btns[i].addEventListener("click", function() { + var current = document.getElementsByClassName("active"); + if (current.length > 0) { + current[0].className = current[0].className.replace(" active", ""); + } + this.className += " active"; + }); +} + +if (config.auth_user == 'admin' || config.auth_pass == 'admin'){ + $('#messageModal').modal('show') +}; +message = '{{ message }}' +if (message != '') { + document.getElementById("modalLabel").innerHTML = "Information!"; + document.getElementById("message").innerHTML = message; + $('#messageModal').modal('show') +}; + +/* Device page */ +function sortTable(n) { + var table, rows, switching, i, x, y, shouldSwitch, dir, switchcount = 0; + table = document.getElementById("deviceTable"); + switching = true; + dir = "asc"; + while (switching) { + switching = false; + rows = table.rows; + for (i = 1; i < (rows.length - 1); i++) { + shouldSwitch = false; + x = rows[i].getElementsByTagName("TD")[n]; + y = rows[i + 1].getElementsByTagName("TD")[n]; + if (dir == "asc") { + if (x.innerHTML.toLowerCase() > y.innerHTML.toLowerCase()) { + shouldSwitch = true; + break; + } + } else if (dir == "desc") { + if (x.innerHTML.toLowerCase() < y.innerHTML.toLowerCase()) { + shouldSwitch = true; + break; + } + } + } + if (shouldSwitch) { + rows[i].parentNode.insertBefore(rows[i + 1], rows[i]); + switching = true; + switchcount ++; + } else { + if (switchcount == 0 && dir == "asc") { + dir = "desc"; + switching = true; + } + } + } +} +function sortIdxTable(n) { + var table, rows, switching, i, x, y, shouldSwitch, dir, switchcount = 0; + table = document.getElementById("deviceTable"); + switching = true; + dir = "asc"; + while (switching) { + switching = false; + rows = table.rows; + for (i = 1; i < (rows.length - 1); i++) { + shouldSwitch = false; + x = rows[i].getElementsByTagName("TH")[n]; + y = rows[i + 1].getElementsByTagName("TH")[n]; + if (dir == "asc") { + if (Number(x.innerHTML) > Number(y.innerHTML)) { + shouldSwitch = true; + break; + } + } else if (dir == "desc") { + if (Number(x.innerHTML) < Number(y.innerHTML)) { + shouldSwitch = true; + break; + } + } + } + if (shouldSwitch) { + rows[i].parentNode.insertBefore(rows[i + 1], rows[i]); + switching = true; + switchcount ++; + } else { + if (switchcount == 0 && dir == "asc") { + dir = "desc"; + switching = true; + } + } + } +} + +function readDevices(){ + var devicelist = {{ list }} + + var xl, i, nicknames = ""; + for (i in devicelist){ + if (devicelist[i][4] == undefined) { + devicelist[i][4] = " " + } + if (devicelist[i][5] == undefined) { + nicknames = " "; + }else{ nicknames = " (" + devicelist[i][5] + ")"} + xl += "" + devicelist[i][1] + "" + devicelist[i][0] + nicknames + "" + devicelist[i][2] + "" + devicelist[i][3] + "" + devicelist[i][4] + ""; + console.log(devicelist[i][1] + " - " + devicelist[i][3]) + }; + if (typeof xl !== "undefined"){ + $('#deviceList_idx').html(xl.replace('undefined','')); + }else{ + document.getElementById("modalLabel").innerHTML = "Check configuration."; + document.getElementById("message").innerHTML = "Connection to Domoticz refused! Check configuration."; + $('#messageModal').modal('show') + }; + console.log($('#deviceList_idx').length) + +} +readDevices() + +/* config page */ +var editor = CodeMirror.fromTextArea(document.getElementById("code"), { + lineNumbers: true, + mode: "yaml", + autoRefresh:true +}); +editor.setOption("extraKeys", { + Tab: function(cm) { + var spaces = Array(cm.getOption("indentUnit") + 1).join(" "); + cm.replaceSelection(spaces); + } +}); +editor.on("change", function() { + textTosave = editor.getValue(); + document.getElementById("save").value = textTosave; + }); + +document.getElementById("save").value = document.getElementById("code").value + +/* Logs page */ +function readTextFile(){ + var x = document.getElementById("autoScroll").checked; //if autoscrool is checked + if(x==true){ + document.getElementById("logs").scrollTop = document.getElementById("logs").scrollHeight; //autoscroll + } + + var filePath = "/log" + + $.ajax({ + dataType: "text", + success : function (data) { + $("#logs").load(filePath); + } + }); + +} +readTextFile() +setInterval(readTextFile, 5000); + + + + + diff --git a/templates/js/sidebar.js b/templates/js/sidebar.js new file mode 100644 index 00000000..0090082e --- /dev/null +++ b/templates/js/sidebar.js @@ -0,0 +1,169 @@ +$(document).ready(function() { + $().ready(function() { + $sidebar = $('.sidebar'); + + $sidebar_img_container = $sidebar.find('.sidebar-background'); + + $full_page = $('.full-page'); + + $sidebar_responsive = $('body > .navbar-collapse'); + + window_width = $(window).width(); + + fixed_plugin_open = $('.sidebar .sidebar-wrapper .nav li.active a p').html(); + + if (window_width > 767 && fixed_plugin_open == 'Dashboard') { + if ($('.fixed-plugin .dropdown').hasClass('show-dropdown')) { + $('.fixed-plugin .dropdown').addClass('open'); + } + + } + + $('.fixed-plugin a').click(function(event) { + // Alex if we click on switch, stop propagation of the event, so the dropdown will not be hide, otherwise we set the section active + if ($(this).hasClass('switch-trigger')) { + if (event.stopPropagation) { + event.stopPropagation(); + } else if (window.event) { + window.event.cancelBubble = true; + } + } + }); + + $('.fixed-plugin .active-color span').click(function() { + $full_page_background = $('.full-page-background'); + + $(this).siblings().removeClass('active'); + $(this).addClass('active'); + + var new_color = $(this).data('color'); + + if ($sidebar.length != 0) { + $sidebar.attr('data-color', new_color); + } + + if ($full_page.length != 0) { + $full_page.attr('filter-color', new_color); + } + + if ($sidebar_responsive.length != 0) { + $sidebar_responsive.attr('data-color', new_color); + } + }); + + $('.fixed-plugin .background-color .badge').click(function() { + $(this).siblings().removeClass('active'); + $(this).addClass('active'); + + var new_color = $(this).data('background-color'); + + if ($sidebar.length != 0) { + $sidebar.attr('data-background-color', new_color); + } + }); + + $('.fixed-plugin .img-holder').click(function() { + $full_page_background = $('.full-page-background'); + + $(this).parent('li').siblings().removeClass('active'); + $(this).parent('li').addClass('active'); + + + var new_image = $(this).find("img").attr('src'); + + if ($sidebar_img_container.length != 0 && $('.switch-sidebar-image input:checked').length != 0) { + $sidebar_img_container.fadeOut('fast', function() { + $sidebar_img_container.css('background-image', 'url("' + new_image + '")'); + $sidebar_img_container.fadeIn('fast'); + }); + } + + if ($full_page_background.length != 0 && $('.switch-sidebar-image input:checked').length != 0) { + var new_image_full_page = $('.fixed-plugin li.active .img-holder').find('img').data('src'); + + $full_page_background.fadeOut('fast', function() { + $full_page_background.css('background-image', 'url("' + new_image_full_page + '")'); + $full_page_background.fadeIn('fast'); + }); + } + + if ($('.switch-sidebar-image input:checked').length == 0) { + var new_image = $('.fixed-plugin li.active .img-holder').find("img").attr('src'); + var new_image_full_page = $('.fixed-plugin li.active .img-holder').find('img').data('src'); + + $sidebar_img_container.css('background-image', 'url("' + new_image + '")'); + $full_page_background.css('background-image', 'url("' + new_image_full_page + '")'); + } + + if ($sidebar_responsive.length != 0) { + $sidebar_responsive.css('background-image', 'url("' + new_image + '")'); + } + }); + + $('.switch-sidebar-image input').change(function() { + $full_page_background = $('.full-page-background'); + + $input = $(this); + + if ($input.is(':checked')) { + if ($sidebar_img_container.length != 0) { + $sidebar_img_container.fadeIn('fast'); + $sidebar.attr('data-image', '#'); + } + + if ($full_page_background.length != 0) { + $full_page_background.fadeIn('fast'); + $full_page.attr('data-image', '#'); + } + + background_image = true; + } else { + if ($sidebar_img_container.length != 0) { + $sidebar.removeAttr('data-image'); + $sidebar_img_container.fadeOut('fast'); + } + + if ($full_page_background.length != 0) { + $full_page.removeAttr('data-image', '#'); + $full_page_background.fadeOut('fast'); + } + + background_image = false; + } + }); + + $('.switch-sidebar-mini input').change(function() { + $body = $('body'); + + $input = $(this); + + if (md.misc.sidebar_mini_active == true) { + $('body').removeClass('sidebar-mini'); + md.misc.sidebar_mini_active = false; + + $('.sidebar .sidebar-wrapper, .main-panel').perfectScrollbar(); + + } else { + + $('.sidebar .sidebar-wrapper, .main-panel').perfectScrollbar('destroy'); + + setTimeout(function() { + $('body').addClass('sidebar-mini'); + + md.misc.sidebar_mini_active = true; + }, 300); + } + + // we simulate the window Resize so the charts will get updated in realtime. + var simulateWindowResize = setInterval(function() { + window.dispatchEvent(new Event('resize')); + }, 180); + + // we stop the simulation of Window Resize after the animations are completed + setTimeout(function() { + clearInterval(simulateWindowResize); + }, 1000); + + }); + }); +}); \ No newline at end of file From 50a56a73ffc3ee4264ed213468c78e707b466ccd Mon Sep 17 00:00:00 2001 From: DewGew Date: Thu, 5 Nov 2020 18:07:46 +0100 Subject: [PATCH 31/84] Delete README.md --- templates/js/README.md | 1 - 1 file changed, 1 deletion(-) delete mode 100644 templates/js/README.md diff --git a/templates/js/README.md b/templates/js/README.md deleted file mode 100644 index bcc3aa52..00000000 --- a/templates/js/README.md +++ /dev/null @@ -1 +0,0 @@ -Custom js files From 8053451cc837a598f0ceac35aac632c6a067d05a Mon Sep 17 00:00:00 2001 From: DewGew Date: Thu, 5 Nov 2020 18:08:19 +0100 Subject: [PATCH 32/84] Add files via upload --- templates/base.html | 121 +++++++++++++++++++++++++++++++++++++++++ templates/config.html | 23 ++++++++ templates/devices.html | 30 ++++++++++ templates/footer.html | 30 ++++++++++ templates/help.html | 20 +++++++ templates/home.html | 98 +++++++++++++++++++++++++++++++++ templates/logs.html | 26 +++++++++ templates/navbar.html | 61 +++++++++++++++++++++ templates/sidebar.html | 70 ++++++++++++++++++++++++ 9 files changed, 479 insertions(+) create mode 100644 templates/base.html create mode 100644 templates/config.html create mode 100644 templates/devices.html create mode 100644 templates/footer.html create mode 100644 templates/help.html create mode 100644 templates/home.html create mode 100644 templates/logs.html create mode 100644 templates/navbar.html create mode 100644 templates/sidebar.html diff --git a/templates/base.html b/templates/base.html new file mode 100644 index 00000000..7f635adc --- /dev/null +++ b/templates/base.html @@ -0,0 +1,121 @@ + + + + + +{% block title %}Domoticz Google Assistant{% endblock %} + + +{{ meta }} + + + + + + + + + + + +
+ + +
+ {% include 'navbar.html' %} +
+
+
+ {% block content%} + + {% endblock %} +
+
+
+ {% include 'footer.html' %} +
+
+ + + + +{% block javascript %} + + + + + + + + + + + + +{% endblock %} + + \ No newline at end of file diff --git a/templates/config.html b/templates/config.html new file mode 100644 index 00000000..ebb5344b --- /dev/null +++ b/templates/config.html @@ -0,0 +1,23 @@ + \ No newline at end of file diff --git a/templates/devices.html b/templates/devices.html new file mode 100644 index 00000000..fec2a93f --- /dev/null +++ b/templates/devices.html @@ -0,0 +1,30 @@ + \ No newline at end of file diff --git a/templates/footer.html b/templates/footer.html new file mode 100644 index 00000000..0a126f8c --- /dev/null +++ b/templates/footer.html @@ -0,0 +1,30 @@ + \ No newline at end of file diff --git a/templates/help.html b/templates/help.html new file mode 100644 index 00000000..0775036c --- /dev/null +++ b/templates/help.html @@ -0,0 +1,20 @@ + diff --git a/templates/home.html b/templates/home.html new file mode 100644 index 00000000..ae4f9896 --- /dev/null +++ b/templates/home.html @@ -0,0 +1,98 @@ +{% extends 'base.html' %} + +{% block title%}Home{% endblock %} + +{% block content %} +
+
+
+
+
+

About Domoticz-Google-Assistant

+

+
+
+


This project is based on Pawcio's script at domoticz forum
+

Before you can use dzga. Setup Action on Google and configure settings in configuration.

+

Domoticz-Google-Assistant delivers:
+

    +
  • The oauth authorization and smarthome endpoint for the google assistant
  • +
  • Two-factor authentication pin for domoticz protected devices (limited language support)
  • +
  • Acknowledgement with Yes or No. (limited language support)
  • +
  • Arm Disarm Securitypanel (limited language support)
  • +
  • Supports Ngrok and SSL
  • +
  • Function to change device type, icon and some behavior depending on the device.
  • +
+

Please feel free to modify, extend and improve it!

+

+ + GitHub issues + + + Discord + +

+
+
+
+
+
+
+

Quick start

+

+
+
+ + Visit the Actions on Google console at http://console.actions.google.com.
Under Develop section, replace the fulfillment URL in Actions with:
+ {{ public_url }}/smarthome

+ In Account linking, set the Authorization URL to:
+ {{ public_url }}/oauth

+ Then set the Token URL to:
+ {{ public_url }}/token

+ Finally press SAVE and then TEST button
+
+
+
+
+
+
+
+
+
+

Information

+

+
+
+ timelapse DZGA Uptime:
{{ uptime }}

+ DZGA Version:
{{ dzgaversion }} {{ branch }}
+ Domoticz Version:
{{ dzversion }}


+
+
+
+
+
+
+

Functions

+

+
+
+
+ + +
+
+
+
+
+
+
+ +{% include 'devices.html' %} + +{% include 'config.html' %} + +{% include 'help.html' %} + +{% include 'logs.html' %} + +{% endblock %} \ No newline at end of file diff --git a/templates/logs.html b/templates/logs.html new file mode 100644 index 00000000..274e6c9b --- /dev/null +++ b/templates/logs.html @@ -0,0 +1,26 @@ + \ No newline at end of file diff --git a/templates/navbar.html b/templates/navbar.html new file mode 100644 index 00000000..43c16435 --- /dev/null +++ b/templates/navbar.html @@ -0,0 +1,61 @@ + + + \ No newline at end of file diff --git a/templates/sidebar.html b/templates/sidebar.html new file mode 100644 index 00000000..015b6db0 --- /dev/null +++ b/templates/sidebar.html @@ -0,0 +1,70 @@ +
+ +
\ No newline at end of file From 3d3a4d2e6f6c036be8232e5cc36b33420bd76d5b Mon Sep 17 00:00:00 2001 From: DewGew Date: Thu, 5 Nov 2020 18:12:50 +0100 Subject: [PATCH 33/84] Update myscript.js --- templates/js/myscript.js | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/templates/js/myscript.js b/templates/js/myscript.js index d2120778..de956cc5 100644 --- a/templates/js/myscript.js +++ b/templates/js/myscript.js @@ -1,7 +1,7 @@ /* Main */ var config = {{ conf }} var updates = {{ update }} -/* document.getElementById("logsheader").innerHTML = 'Logs
Loglevel: ' + config.loglevel + ''; */ +document.getElementById("logsheader").innerHTML = 'Logs
Loglevel: ' + config.loglevel + ''; if (updates) { document.getElementById("updates").innerHTML = "(Updates are Availible)"; $('#buttonUpdate').append('
'); @@ -168,8 +168,3 @@ function readTextFile(){ } readTextFile() setInterval(readTextFile, 5000); - - - - - From bbefd8fbac599d05200cdb08cd9afb42a712b43d Mon Sep 17 00:00:00 2001 From: DewGew Date: Thu, 5 Nov 2020 18:43:12 +0100 Subject: [PATCH 34/84] Update base.html --- templates/base.html | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/templates/base.html b/templates/base.html index 7f635adc..50b4d1ec 100644 --- a/templates/base.html +++ b/templates/base.html @@ -109,7 +109,6 @@ - @@ -118,4 +117,4 @@ {% endblock %} - \ No newline at end of file + From f7c568ce3fe450dd742c432c5e91423cefb3de32 Mon Sep 17 00:00:00 2001 From: DewGew Date: Thu, 5 Nov 2020 18:49:19 +0100 Subject: [PATCH 35/84] Rename custom js file --- templates/base.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/base.html b/templates/base.html index 50b4d1ec..90332df4 100644 --- a/templates/base.html +++ b/templates/base.html @@ -110,7 +110,7 @@ + + + + + + + + - - - - From 247e32a97cb2514ce7635894ff9d12d2be26cc84 Mon Sep 17 00:00:00 2001 From: DewGew Date: Sat, 7 Nov 2020 11:22:11 +0100 Subject: [PATCH 50/84] Update const.py --- const.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/const.py b/const.py index 8800086e..3eefc82c 100644 --- a/const.py +++ b/const.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- """Constants for Google Assistant.""" -VERSION = '1.9.0' +VERSION = '1.9.1' PUBLIC_URL = 'https://[your public url]' CONFIGFILE = 'config/config.yaml' LOGFILE = 'dzga.log' From 6bb318015a161e71ac785d56bcaf2100c97eae26 Mon Sep 17 00:00:00 2001 From: DewGew Date: Sat, 7 Nov 2020 13:46:45 +0100 Subject: [PATCH 51/84] Update home.html --- templates/home.html | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/templates/home.html b/templates/home.html index 8cdeaee3..7f5ccc28 100644 --- a/templates/home.html +++ b/templates/home.html @@ -9,11 +9,10 @@

About Domoticz-Google-Assistant

-

+

Before you can use dzga. Setup Action on Google and configure settings in configuration.

-


This project is based on Pawcio's script at domoticz forum
-

Before you can use dzga. Setup Action on Google and configure settings in configuration.

+

This project is based on Pawcio's script at domoticz forum

Domoticz-Google-Assistant delivers:

  • The oauth authorization and smarthome endpoint for the google assistant
  • @@ -23,7 +22,7 @@

    About Domoticz-Google-Assistant

  • Supports Ngrok and SSL
  • Function to change device type, icon and some behavior depending on the device.
-

Please feel free to modify, extend and improve it!

+

Please feel free to modify, extend and improve it!

GitHub issues @@ -63,9 +62,9 @@

Information

- timelapse DZGA Uptime:
{{ uptime }}

- DZGA Version:
{{ dzgaversion }} {{ branch }}
- Domoticz Version:
{{ dzversion }}


+ DZGA Uptime: {{ uptime }}
+ DZGA Version: {{ dzgaversion }} {{ branch }}
+ Domoticz Version: {{ dzversion }}


From 603b6990db42f0b903709635f5ab0b5afcc5f646 Mon Sep 17 00:00:00 2001 From: DewGew Date: Sun, 8 Nov 2020 12:39:15 +0100 Subject: [PATCH 52/84] Update Dockerfile --- Dockerfile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 7946fa72..c649b5b5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,7 +6,8 @@ FROM jfloff/alpine-python:3.7-slim RUN mkdir -p config COPY *.py / -COPY *.html / +COPY templates/*.* /templates +COPY static/*.* /static COPY requirements/pip-requirements.txt /requirements.txt # Create volume @@ -15,4 +16,4 @@ VOLUME /config # Configure Services and Port CMD ["python3 /__main__.py"] -EXPOSE 3030 \ No newline at end of file +EXPOSE 3030 From 4040b6b5dbd9a4bf2d3078f0374728b6f7bb8502 Mon Sep 17 00:00:00 2001 From: DewGew Date: Sun, 8 Nov 2020 12:53:14 +0100 Subject: [PATCH 53/84] Update Dockerfile --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index c649b5b5..a3ec8793 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,8 +6,8 @@ FROM jfloff/alpine-python:3.7-slim RUN mkdir -p config COPY *.py / -COPY templates/*.* /templates -COPY static/*.* /static +COPY templates/ /templates/ +COPY static/ /static/ COPY requirements/pip-requirements.txt /requirements.txt # Create volume From 0ef5c020ecbe33302954517b51b27a1dae2dc6e8 Mon Sep 17 00:00:00 2001 From: DewGew Date: Sun, 8 Nov 2020 13:16:42 +0100 Subject: [PATCH 54/84] Update smarthome.py --- smarthome.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/smarthome.py b/smarthome.py index 45b07fe1..b781cca0 100644 --- a/smarthome.py +++ b/smarthome.py @@ -827,7 +827,7 @@ def settings_post(self, s): conf=confJSON, public_url=public_url, update=update, branch=branch, dzversion=settings['dzversion'], dzgaversion=VERSION)) - subprocess.call(['pip', 'install','-r', os.path.join(FILE_DIR, 'requirements/pip-requirements.txt')]) + subprocess.call(['pip3', 'install','-r', os.path.join(FILE_DIR, 'requirements/pip-requirements.txt')]) restartServer() From 98de5c82ce4942d8fc312a15fffa2ef7394c193e Mon Sep 17 00:00:00 2001 From: DewGew Date: Sun, 8 Nov 2020 13:17:26 +0100 Subject: [PATCH 55/84] Update const.py --- const.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/const.py b/const.py index 3eefc82c..4f801ca2 100644 --- a/const.py +++ b/const.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- """Constants for Google Assistant.""" -VERSION = '1.9.1' +VERSION = '1.9.2' PUBLIC_URL = 'https://[your public url]' CONFIGFILE = 'config/config.yaml' LOGFILE = 'dzga.log' From 3981290c09942c8e26f8f08e2c5ac2dc03b0f8e7 Mon Sep 17 00:00:00 2001 From: DewGew Date: Sun, 8 Nov 2020 13:18:23 +0100 Subject: [PATCH 56/84] Update smarthome.py --- smarthome.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/smarthome.py b/smarthome.py index ffee1388..56897da5 100644 --- a/smarthome.py +++ b/smarthome.py @@ -798,7 +798,7 @@ def settings_post(self, s): branch=branch, dzversion=settings['dzversion']) s.send_message(200, template) - subprocess.call(['pip', 'install','-r', os.path.join(FILE_DIR, 'requirements/pip-requirements.txt')]) + subprocess.call(['pip3', 'install','-r', os.path.join(FILE_DIR, 'requirements/pip-requirements.txt')]) restartServer() def delay_report_state(self, states, token): From 4cfd8b3b225728f5220394db5380fa9cc313b4e3 Mon Sep 17 00:00:00 2001 From: DewGew Date: Sun, 8 Nov 2020 13:18:50 +0100 Subject: [PATCH 57/84] Update const.py --- const.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/const.py b/const.py index d251ae67..3f7768c9 100644 --- a/const.py +++ b/const.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- """Constants for Google Assistant.""" -VERSION = '1.8.13' +VERSION = '1.8.14' PUBLIC_URL = 'https://[your public url]' CONFIGFILE = 'config/config.yaml' LOGFILE = 'dzga.log' From 2122c41dd259ab05a02f68c809c37693283e1cae Mon Sep 17 00:00:00 2001 From: DewGew Date: Mon, 9 Nov 2020 11:12:30 +0100 Subject: [PATCH 58/84] Try jinja2 else install package --- smarthome.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/smarthome.py b/smarthome.py index b781cca0..84d2215b 100644 --- a/smarthome.py +++ b/smarthome.py @@ -9,8 +9,6 @@ from collections.abc import Mapping from itertools import product from pid import PidFile -from jinja2 import Environment, FileSystemLoader - import requests import trait @@ -23,6 +21,13 @@ from helpers import (configuration, readFile, saveFile, SmartHomeError, SmartHomeErrorNoChallenge, AogState, uptime, getTunnelUrl, FILE_DIR, logger, ReportState, Auth, logfilepath) +try: + from jinja2 import Enviroment, FileSystemLoader +except ImportError: + logger.info('Installing package jinja2') + subprocess.call(['pip', 'install', 'jinja2']) + from jinja2 import Environment, FileSystemLoader + DOMOTICZ_URL = configuration['Domoticz']['ip'] + ':' + configuration['Domoticz']['port'] CREDITS = (configuration['Domoticz']['username'], configuration['Domoticz']['password']) From d29ceb6a35dd3279619d5bb321cef5fe3633ef96 Mon Sep 17 00:00:00 2001 From: DewGew Date: Mon, 9 Nov 2020 11:43:54 +0100 Subject: [PATCH 59/84] typo --- smarthome.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/smarthome.py b/smarthome.py index 84d2215b..4e04315d 100644 --- a/smarthome.py +++ b/smarthome.py @@ -22,7 +22,7 @@ getTunnelUrl, FILE_DIR, logger, ReportState, Auth, logfilepath) try: - from jinja2 import Enviroment, FileSystemLoader + from jinja2 import Environment, FileSystemLoader except ImportError: logger.info('Installing package jinja2') subprocess.call(['pip', 'install', 'jinja2']) From bdd0c56f35f605702ff6b74cef441117a7ddde68 Mon Sep 17 00:00:00 2001 From: DewGew Date: Tue, 10 Nov 2020 10:26:30 +0100 Subject: [PATCH 60/84] Update const.py --- const.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/const.py b/const.py index 4f801ca2..27e03b6c 100644 --- a/const.py +++ b/const.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- """Constants for Google Assistant.""" -VERSION = '1.9.2' +VERSION = '1.9.3' PUBLIC_URL = 'https://[your public url]' CONFIGFILE = 'config/config.yaml' LOGFILE = 'dzga.log' From d1d5a9c5f332aabda1e49e3c902e0ad8181cc468 Mon Sep 17 00:00:00 2001 From: DewGew Date: Tue, 10 Nov 2020 10:35:32 +0100 Subject: [PATCH 61/84] Add primary name change in device_config name = My cool name or Device_Config: 123: name: 'My cool name' --- smarthome.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/smarthome.py b/smarthome.py index 4e04315d..44781283 100644 --- a/smarthome.py +++ b/smarthome.py @@ -246,6 +246,9 @@ def getAog(device): if aog.domain in [domains['selector']]: if dt.lower() in ['vacuum']: aog.domain = domains[dt.lower()] + pn = desc.get('name', None) + if pn is not None: + aog.name = pn n = desc.get('nicknames', None) if n is not None: aog.nicknames = n From 0729f3a0492a41dc3cba64e7e435d1d40b3afa0e Mon Sep 17 00:00:00 2001 From: DewGew Date: Wed, 11 Nov 2020 15:08:26 +0100 Subject: [PATCH 62/84] Update sidebar.js --- templates/js/sidebar.js | 51 ++++++++++++++++++++++++++++++++++------- 1 file changed, 43 insertions(+), 8 deletions(-) diff --git a/templates/js/sidebar.js b/templates/js/sidebar.js index 0090082e..f3c3dd5f 100644 --- a/templates/js/sidebar.js +++ b/templates/js/sidebar.js @@ -29,16 +29,45 @@ $(document).ready(function() { } } }); + + if ($sidebar.length != 0) { + $sidebar.attr('data-color', localStorage.getItem("data-color")); + $('.fixed-plugin .active-color span.badge.filter.badge-' + localStorage.getItem('data-color')).addClass('active'); + } + if ($full_page.length != 0) { + $full_page.attr('filter-color', localStorage.getItem('data-color')); + } + + if ($sidebar_responsive.length != 0) { + $sidebar_responsive.attr('data-color', localStorage.getItem('data-color')); + } + + $sidebar_img_container.css('background-image', 'url("' + localStorage.getItem('background-image') + '")'); + + if (localStorage.getItem('background-image') == 'static/img/sidebar-1.jpg'){ + $('.fixed-plugin li .img1').parent('li').addClass('active'); + } + if (localStorage.getItem('background-image') == 'static/img/sidebar-2.jpg'){ + $('.fixed-plugin li .img2').parent('li').addClass('active'); + } + if (localStorage.getItem('background-image') == 'static/img/sidebar-3.jpg'){ + $('.fixed-plugin li .img3').parent('li').addClass('active'); + } + if (localStorage.getItem('background-image') == 'static/img/sidebar-4.jpg'){ + $('.fixed-plugin li .img4').parent('li').addClass('active'); + } + $('.fixed-plugin .active-color span').click(function() { $full_page_background = $('.full-page-background'); - $(this).siblings().removeClass('active'); $(this).addClass('active'); var new_color = $(this).data('color'); + localStorage.setItem('data-color', new_color); + + if ($sidebar.length != 0) { - if ($sidebar.length != 0) { $sidebar.attr('data-color', new_color); } @@ -50,8 +79,10 @@ $(document).ready(function() { $sidebar_responsive.attr('data-color', new_color); } }); + $('.fixed-plugin .background-color .badge').click(function() { + $(this).siblings().removeClass('active'); $(this).addClass('active'); @@ -64,14 +95,17 @@ $(document).ready(function() { $('.fixed-plugin .img-holder').click(function() { $full_page_background = $('.full-page-background'); - + $(this).parent('li').siblings().removeClass('active'); $(this).parent('li').addClass('active'); var new_image = $(this).find("img").attr('src'); - + + localStorage.setItem('background-image', new_image); + if ($sidebar_img_container.length != 0 && $('.switch-sidebar-image input:checked').length != 0) { + $sidebar_img_container.fadeOut('fast', function() { $sidebar_img_container.css('background-image', 'url("' + new_image + '")'); $sidebar_img_container.fadeIn('fast'); @@ -79,8 +113,9 @@ $(document).ready(function() { } if ($full_page_background.length != 0 && $('.switch-sidebar-image input:checked').length != 0) { - var new_image_full_page = $('.fixed-plugin li.active .img-holder').find('img').data('src'); + var new_image_full_page = $('.fixed-plugin li.active .img-holder').find('img').data('src'); + $full_page_background.fadeOut('fast', function() { $full_page_background.css('background-image', 'url("' + new_image_full_page + '")'); $full_page_background.fadeIn('fast'); @@ -88,9 +123,10 @@ $(document).ready(function() { } if ($('.switch-sidebar-image input:checked').length == 0) { + var new_image = $('.fixed-plugin li.active .img-holder').find("img").attr('src'); var new_image_full_page = $('.fixed-plugin li.active .img-holder').find('img').data('src'); - + $sidebar_img_container.css('background-image', 'url("' + new_image + '")'); $full_page_background.css('background-image', 'url("' + new_image_full_page + '")'); } @@ -134,7 +170,6 @@ $(document).ready(function() { $('.switch-sidebar-mini input').change(function() { $body = $('body'); - $input = $(this); if (md.misc.sidebar_mini_active == true) { @@ -166,4 +201,4 @@ $(document).ready(function() { }); }); -}); \ No newline at end of file +}); From 12542a947a9755f93dfe5b7931899b157a51130f Mon Sep 17 00:00:00 2001 From: DewGew Date: Wed, 11 Nov 2020 15:16:28 +0100 Subject: [PATCH 63/84] add localstorage --- templates/js/sidebar.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/templates/js/sidebar.js b/templates/js/sidebar.js index f3c3dd5f..0f5e2863 100644 --- a/templates/js/sidebar.js +++ b/templates/js/sidebar.js @@ -11,7 +11,14 @@ $(document).ready(function() { window_width = $(window).width(); fixed_plugin_open = $('.sidebar .sidebar-wrapper .nav li.active a p').html(); - + + if (localStorage.getItem('data-color') === null) { + localStorage.setItem('data-color', 'purple'); + } + if (localStorage.getItem('background-image') === null) { + localStorage.setItem('background-image', 'static/img/sidebar-3.jpg'); + } + if (window_width > 767 && fixed_plugin_open == 'Dashboard') { if ($('.fixed-plugin .dropdown').hasClass('show-dropdown')) { $('.fixed-plugin .dropdown').addClass('open'); From bd6416e80a3d865d8faaf991a9cc17d0da9a7987 Mon Sep 17 00:00:00 2001 From: DewGew Date: Wed, 11 Nov 2020 15:17:08 +0100 Subject: [PATCH 64/84] Update functions.js --- templates/js/functions.js | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/templates/js/functions.js b/templates/js/functions.js index 5bc9f2c8..c5208c20 100644 --- a/templates/js/functions.js +++ b/templates/js/functions.js @@ -1,9 +1,13 @@ /* Main */ var config = {{ conf }} var updates = {{ update }} -document.getElementById("logsheader").innerHTML = 'Logs
Loglevel: ' + config.loglevel + ''; + +$('#notes').hide() +$('#logsheader').html('Logs
Loglevel: ' + config.loglevel + ''); + if (updates) { - document.getElementById("updates").innerHTML = "(Updates are Availible)"; + $('#updates').html("Updates are Availible"); + $('#notes').show() $('#buttonUpdate').append('
'); }; @@ -23,10 +27,14 @@ for (var i = 0; i < btns.length; i++) { if (config.auth_user == 'admin' || config.auth_pass == 'admin'){ $('#messageModal').modal('show') }; + + +$('#user').append(config.auth_user) + message = '{{ message }}' if (message != '') { - document.getElementById("modalLabel").innerHTML = "Information!"; - document.getElementById("message").innerHTML = message; + $('#modalLabel').html("Information!"); + $('#message').html(message); $('#messageModal').modal('show') }; @@ -135,8 +143,8 @@ function readDevices(devicelist){ if (typeof xl !== "undefined"){ $('#deviceList_idx').html(xl.replace('undefined','')); }else{ - document.getElementById("modalLabel").innerHTML = "Check configuration."; - document.getElementById("message").innerHTML = "Connection to Domoticz refused! Check configuration."; + $('#modalLabel').html("Check configuration."); + $('#message').html("Connection to Domoticz refused! Check configuration."); $('#messageModal').modal('show') }; }, From d18501878c1b272c7e5b7ed8c4302bed23886ece Mon Sep 17 00:00:00 2001 From: DewGew Date: Wed, 11 Nov 2020 15:17:59 +0100 Subject: [PATCH 65/84] Update navbar.html --- templates/navbar.html | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/templates/navbar.html b/templates/navbar.html index 8aed598d..51393b6b 100644 --- a/templates/navbar.html +++ b/templates/navbar.html @@ -14,30 +14,26 @@
From 25c81b4368cbfa04f802fc026eae490ea43985ae Mon Sep 17 00:00:00 2001 From: DewGew Date: Wed, 11 Nov 2020 15:18:30 +0100 Subject: [PATCH 66/84] Update home.html --- templates/home.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/home.html b/templates/home.html index 7f5ccc28..c3ba93ad 100644 --- a/templates/home.html +++ b/templates/home.html @@ -63,7 +63,7 @@

Information

DZGA Uptime: {{ uptime }}
- DZGA Version: {{ dzgaversion }} {{ branch }}
+ DZGA Version: {{ dzgaversion }} {{ branch }}
Domoticz Version: {{ dzversion }}


From 87e85c8496ad87acc7aa53c7e4572c9e0e366560 Mon Sep 17 00:00:00 2001 From: DewGew Date: Wed, 11 Nov 2020 15:19:27 +0100 Subject: [PATCH 67/84] Update base.html --- templates/base.html | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/templates/base.html b/templates/base.html index 90332df4..d46c979d 100644 --- a/templates/base.html +++ b/templates/base.html @@ -82,32 +82,34 @@
- {% include 'navbar.html' %} -
-
-
- {% block content%} - - {% endblock %} + {% include 'navbar.html' %} +
+
+
+ {% block content%} + + {% endblock %} +
+
+ {% include 'footer.html' %}
- {% include 'footer.html' %} -
-
- + {% include 'sidebar.html' %} {% block javascript %} - - - + + + + + - + - + + + + + + + + + diff --git a/templates/home.html b/templates/home.html index c3ba93ad..1626cbfe 100644 --- a/templates/home.html +++ b/templates/home.html @@ -4,7 +4,55 @@ {% block content %}
-
+
+
+
+
+
+ devices_other +
+

Connected Devices

+

0

+
+
+
+ + +
+
+
+ +
+
+
+
+
+
+ info_outline +
+

Info

+

{{ uptime }}

+
+
+ + DZGA Version: {{ dzgaversion }} {{ branch }}
+ Domoticz Version: {{ dzversion }}
+ Github Issues: +
+
+ +
+
+
+
@@ -53,36 +101,6 @@

Quick start

-
-
-
-
-
-

Information

-

-
-
- DZGA Uptime: {{ uptime }}
- DZGA Version: {{ dzgaversion }} {{ branch }}
- Domoticz Version: {{ dzversion }}


-
-
-
-
-
-
-

Functions

-

-
-
-
- - -
-
-
-
-
@@ -93,5 +111,7 @@

Functions

{% include 'help.html' %} {% include 'logs.html' %} + +{% include 'settings.html' %} {% endblock %} diff --git a/templates/js/functions.js b/templates/js/functions.js index 7f3ecbed..9a5b130f 100644 --- a/templates/js/functions.js +++ b/templates/js/functions.js @@ -1,9 +1,7 @@ /* Main */ -var config = {{ conf }} var updates = {{ update }} $('#notes').hide() -$('#logsheader').html('Logs
Loglevel: ' + config.loglevel + ''); if (updates) { $('#updates').html("Updates are Availible"); @@ -24,12 +22,12 @@ for (var i = 0; i < btns.length; i++) { }); } -if (config.auth_user == 'admin' || config.auth_pass == 'admin'){ +if ('{{ conf.auth_user }}' == 'admin' || '{{ conf.auth_pass }}' == 'admin'){ $('#messageModal').modal('show') }; -$('#user').append(config.auth_user) +$('#user').append('{{ conf.auth_user }}') message = '{{ message }}' if (message != '') { @@ -140,13 +138,14 @@ function readDevices(devicelist){ } xl += "" + devicelist[i][4] + ""; }; + $("#devices_count").html(devicelist.length) if (typeof xl !== "undefined"){ $('#deviceList_idx').html(xl.replace('undefined','')); }else{ $('#modalLabel').html("Check configuration."); $('#message').html("Connection to Domoticz refused! Check configuration."); $('#messageModal').modal('show') - }; + }; }, error: function() { console.log('Error, states not availible'); @@ -154,7 +153,7 @@ function readDevices(devicelist){ }); } readDevices() -setInterval(readDevices, 2000); +/* setInterval(readDevices, 2000); */ /* config page */ var editor = CodeMirror.fromTextArea(document.getElementById("code"), { @@ -174,8 +173,59 @@ editor.on("change", function() { }); document.getElementById("save").value = document.getElementById("code").value + +$("#saveSettings").click(function(){ + if ($('#loglevel_debug:checked').val() === 'on'){ + level = 'Debug' + }else if ($('#loglevel_error:checked').val() === 'on'){ + level = 'Error' + }else{ + level = 'Info' + } + + if ($('#logtofile').val() == 'True'){ + logfile = true + }else if ($('#logtofile').val() == 'False'){ + logfile = false + }else{ + logfile = $('#logtofile').val() + } + + stext = { + 'auth_user': $('#auth_user').val(), + 'auth_pass': $('#auth_pass').val(), + 'port_number': parseInt($('#port_number').val()), + 'Low_battery_limit': parseInt($('#Low_battery_limit').val()), + 'CheckForUpdates': ($('#CheckForUpdates:checked').val() === 'on'), + 'userinterface': ($('#userinterface:checked').val() === 'on'), + 'use_ssl': ($('#use_ssl:checked').val() == 'on'), + 'ssl_key': $('#ssl_key').val(), + 'ssl_cert': $('#ssl_cert').val(), + 'ngrok_tunnel': ($('#ngrok_tunnel:checked').val() === 'on'), + 'ngrok_auth_token': $('#ngrok_auth_token').val(), + 'loglevel': level, + 'logtofile': logfile, + 'pathToLogFile': $('#pathToLogFile').val(), + 'ClientID': $('#ClientID').val(), + 'ClientSecret': $('#ClientSecret').val(), + 'PidFile': $('#PidFile').val(), + 'Domoticz':{ + 'ip': $('#Domoticzip').val(), + 'port': $('#Domoticzport').val(), + 'roomplan': $('#Domoticzroomplan').val(), + 'username': $('#Domoticzusername').val(), + 'password': $('#Domoticzpassword').val(), + 'switchProtectionPass': $('#DomoticzswitchProtectionPass').val(), + }, + } + document.getElementById("saveSettings").value = JSON.stringify(stext) +}); + + + /* Logs page */ + function getlogs(){ var x = document.getElementById("autoScroll").checked; //if autoscrool is checked if(x==true){ @@ -191,4 +241,43 @@ function getlogs(){ }); } getlogs() -setInterval(getlogs, 2000); +/* setInterval(getlogs, 2000); */ + +/* Settings */ +$("#loglevel_info").click(function(){ + $('input#loglevel_debug[type="radio"]').prop('checked', false); + $('input#loglevel_error[type="radio"]').prop('checked', false); +}); +$("#loglevel_debug").click(function(){ + $('input#loglevel_info[type="radio"]').prop('checked', false); + $('input#loglevel_error[type="radio"]').prop('checked', false); +}); +$("#loglevel_error").click(function(){ + $('input#loglevel_info[type="radio"]').prop('checked', false); + $('input#loglevel_debug[type="radio"]').prop('checked', false); +}); + +$("#use_ssl").click(function(){ + if ($('input#use_ssl[type="checkbox"]').prop('checked') == true){ + $('input#ngrok_tunnel[type="checkbox"]').prop('checked', false) + } +}); + +$("#ngrok_tunnel").click(function(){ + if ($('input#ngrok_tunnel[type="checkbox"]').prop('checked') == true){ + $('input#use_ssl[type="checkbox"]').prop('checked', false) + } +}); + +function getIssues(){ + + $.ajax({ + type: 'GET', + url: 'https://api.github.com/repos/DewGew/Domoticz-Google-Assistant', + success: function(response) { + $("#github_issues").html(response['open_issues'] + ' open'); + } + }); +} +getIssues() + diff --git a/templates/js/sidebar.js b/templates/js/sidebar.js index 0f5e2863..291f68a6 100644 --- a/templates/js/sidebar.js +++ b/templates/js/sidebar.js @@ -1,5 +1,16 @@ $(document).ready(function() { - $().ready(function() { + $().ready(function() { + + $('.fixed-plugin #dropdown-menu').hide() + $(".fixed-plugin #sidebar").click(function(){ + + if ($('.fixed-plugin .dropdown').hasClass('show')){ + $('.fixed-plugin #dropdown-menu').hide() + }else{ + $('.fixed-plugin #dropdown-menu').show() + } + }); + $sidebar = $('.sidebar'); $sidebar_img_container = $sidebar.find('.sidebar-background'); diff --git a/templates/logs.html b/templates/logs.html index 92d52f60..23acedf1 100644 --- a/templates/logs.html +++ b/templates/logs.html @@ -1,12 +1,19 @@ + + +
\ No newline at end of file diff --git a/templates/settings.html b/templates/settings.html new file mode 100644 index 00000000..9b6b9faf --- /dev/null +++ b/templates/settings.html @@ -0,0 +1,326 @@ + \ No newline at end of file diff --git a/templates/sidebar.html b/templates/sidebar.html index fe82b3ac..d3960580 100644 --- a/templates/sidebar.html +++ b/templates/sidebar.html @@ -1,9 +1,9 @@