From 6f6c1ea9c15297ced225426380d3b6692d56230f Mon Sep 17 00:00:00 2001 From: Christoffer Martinsson Date: Thu, 1 Nov 2018 13:05:45 +0100 Subject: [PATCH] Cleaned up code --- .gitignore | 5 + content/applications/_index.md | 7 - content/applications/broadlink/_index.md | 52 ------- content/applications/broadlink/changelog.md | 11 -- content/applications/huee/_index.md | 7 - content/applications/huee/changelog.md | 6 - content/applications/webapp/_index.md | 7 - content/applications/webapp/changelog.md | 11 -- content/applications/zwave/_index.md | 7 - content/applications/zwave/changelog.md | 6 - content/cli/_index.md | 50 ------ content/cli/changelog.md | 6 - content/core/_index.md | 160 -------------------- content/core/changelog.md | 20 --- content/libhaasp/_index.md | 8 - content/libhaasp/changelog.md | 6 - get_app_data.py | 7 +- 17 files changed, 10 insertions(+), 366 deletions(-) create mode 100644 .gitignore delete mode 100644 content/applications/_index.md delete mode 100644 content/applications/broadlink/_index.md delete mode 100644 content/applications/broadlink/changelog.md delete mode 100644 content/applications/huee/_index.md delete mode 100644 content/applications/huee/changelog.md delete mode 100644 content/applications/webapp/_index.md delete mode 100644 content/applications/webapp/changelog.md delete mode 100644 content/applications/zwave/_index.md delete mode 100644 content/applications/zwave/changelog.md delete mode 100644 content/cli/_index.md delete mode 100644 content/cli/changelog.md delete mode 100644 content/core/_index.md delete mode 100644 content/core/changelog.md delete mode 100644 content/libhaasp/_index.md delete mode 100644 content/libhaasp/changelog.md diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1eb41d2 --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +content/core +content/libhaasp +content/cli +content/applications + diff --git a/content/applications/_index.md b/content/applications/_index.md deleted file mode 100644 index 108bf6b..0000000 --- a/content/applications/_index.md +++ /dev/null @@ -1,7 +0,0 @@ -+++ -title = "Applications" -weight=8 -alwaysopen = true -+++ - -: diff --git a/content/applications/broadlink/_index.md b/content/applications/broadlink/_index.md deleted file mode 100644 index 1856b3a..0000000 --- a/content/applications/broadlink/_index.md +++ /dev/null @@ -1,52 +0,0 @@ -+++ -weight = "10" -title = "Broadlink" -date = "2018-08-06T13:43:48.000Z" -lastmodifierdisplayname = "Christoffer Martinsson" -lastmodifieremail = "christoffer.martinsson@mildef.com" -+++ -The broadlink app will output all found devices on start, you can use this to setup your config file as shown bellow - -Config Setup example - -``` -class Config(ConfigObject): - - def setup(self): - # Broadlink devices -------------------------------------------------------- - self.broadlink_livingroom = EventObject("broadlink", "064cdf434ead4")` - - # WebApp ------------------------------------------------------------------- - self.webapp_livingroom_tv_on = EventObject("webapp", "livingroom.tv.on", "true") - - def process_event(self): - if self.webapp_livingroom_tv_on.event == "true": - self.broadlink_livingroom.set("26008403120a110b0e0f0d0f0d100d2c110b0d100d0f0d0f0d100d0f0e0f0d0f0d0f0e2b1309" - "0e0f0d100d0f0e0e0e0f0d0f110c0d2b0e0f0d2c0f290e2b0e2b120a120b11280d0f0d2c0e2b" - "0e2b0e2a0e0f11280e00097876350f0d0e2b120a0d100d0f0d100d0f120a0d100d0f0d100e0" - "e0e0f0d2b0e0f110b0d100d0f120a120b0d0f0d100e0e0d2c0e0e0e0f0d0f0d100e0e0e0e13" - "090e0f0d2c0e0f0d2b132613260f2a0e0e120a0f2a0e0f0d2c112713260e2b120a0e2b130009") -``` - -To lear a ir code send "learning" event to a broadlink device, aim you remote towards the broadlink device and -push the button you which to learn. - -You will then get an event back from the broadlink app with the code, cut and past that into your config file -as showed above - -Learning event example - -``` -class Config(ConfigObject): - - def setup(self): - # Broadlink devices -------------------------------------------------------- - self.broadlink_livingroom = EventObject("broadlink", "064cdf434ead4")` - - # WebApp ------------------------------------------------------------------- - self.webapp_livingroom_learn = EventObject("webapp", "livingroom.broadling.learn", "true") - - def process_event(self): - if self.webapp_livingroom_learn.event == "true": - self.broadlink_livingroom.set("learning") -``` \ No newline at end of file diff --git a/content/applications/broadlink/changelog.md b/content/applications/broadlink/changelog.md deleted file mode 100644 index b08f136..0000000 --- a/content/applications/broadlink/changelog.md +++ /dev/null @@ -1,11 +0,0 @@ -+++ -title = "Changelog" -date = "2018-08-06T13:43:48.000Z" -lastmodifierdisplayname = "Christoffer Martinsson" -lastmodifieremail = "christoffer.martinsson@mildef.com" -+++ -### v1.0 -Basic function like send ir/rf codes and learning ir/rf codes works now - -### v0.5 -Sending ir/rf codes works now \ No newline at end of file diff --git a/content/applications/huee/_index.md b/content/applications/huee/_index.md deleted file mode 100644 index 93834e5..0000000 --- a/content/applications/huee/_index.md +++ /dev/null @@ -1,7 +0,0 @@ -+++ -weight = "11" -title = "Huee" -date = "2018-08-06T13:14:07.000Z" -lastmodifierdisplayname = "Christoffer Martinsson" -lastmodifieremail = "christoffer.martinsson@mildef.com" -+++ diff --git a/content/applications/huee/changelog.md b/content/applications/huee/changelog.md deleted file mode 100644 index fa4ba25..0000000 --- a/content/applications/huee/changelog.md +++ /dev/null @@ -1,6 +0,0 @@ -+++ -title = "Changelog" -date = "2018-08-06T13:14:07.000Z" -lastmodifierdisplayname = "Christoffer Martinsson" -lastmodifieremail = "christoffer.martinsson@mildef.com" -+++ diff --git a/content/applications/webapp/_index.md b/content/applications/webapp/_index.md deleted file mode 100644 index ffccf42..0000000 --- a/content/applications/webapp/_index.md +++ /dev/null @@ -1,7 +0,0 @@ -+++ -weight = "12" -title = "Webapp" -date = "2018-10-23T20:28:25.000Z" -lastmodifierdisplayname = "christianm" -lastmodifieremail = "chrillemz@gmail.com" -+++ diff --git a/content/applications/webapp/changelog.md b/content/applications/webapp/changelog.md deleted file mode 100644 index e4c0ce8..0000000 --- a/content/applications/webapp/changelog.md +++ /dev/null @@ -1,11 +0,0 @@ -+++ -title = "Changelog" -date = "2018-10-23T20:28:25.000Z" -lastmodifierdisplayname = "christianm" -lastmodifieremail = "chrillemz@gmail.com" -+++ -### v0.10 -Updated web UI, we now group the buttons with color and som style update on buttons - -### v0.5 -Toggle and trigger buttons are auto generated and you can disable triggers by sending a false event \ No newline at end of file diff --git a/content/applications/zwave/_index.md b/content/applications/zwave/_index.md deleted file mode 100644 index 1579919..0000000 --- a/content/applications/zwave/_index.md +++ /dev/null @@ -1,7 +0,0 @@ -+++ -weight = "13" -title = "Zwave" -date = "2018-08-06T12:01:09.000Z" -lastmodifierdisplayname = "Christoffer Martinsson" -lastmodifieremail = "christoffer.martinsson@mildef.com" -+++ diff --git a/content/applications/zwave/changelog.md b/content/applications/zwave/changelog.md deleted file mode 100644 index 80c0c78..0000000 --- a/content/applications/zwave/changelog.md +++ /dev/null @@ -1,6 +0,0 @@ -+++ -title = "Changelog" -date = "2018-08-06T12:01:09.000Z" -lastmodifierdisplayname = "Christoffer Martinsson" -lastmodifieremail = "christoffer.martinsson@mildef.com" -+++ diff --git a/content/cli/_index.md b/content/cli/_index.md deleted file mode 100644 index 83dfdb3..0000000 --- a/content/cli/_index.md +++ /dev/null @@ -1,50 +0,0 @@ -+++ -title = "CLI" -weight = 7 -date = "2018-08-06T11:09:51.000Z" -lastmodifierdisplayname = "Christian Martinsson" -lastmodifieremail = "chrillemz@gmail.com" -+++ - -Command Line Interface for HAASP. - -* Monitor all HAASP activity remotly on the network -* Send command to applications *(application dependant)* - -## Installation -Make sure you have python3, git and pip installed -`pip install -U git+https://git.cmtec.se/haasp/libhaasp.git` -`pip install -U git+https://git.cmtec.se/haasp/haasp_cli.git` - -## Usage -`haasp_cli [OPTIONS] COMMAND [ARGS]` - -### Options: - -* --ip -Defines the HAASP core module IP on the network. Default to localhost if not defined. - -### Commands: -* cmd -`haasp_cli [OPTION] cmd DESTINATION [COMMAND] [VALUE]` -Passing through command to application -example: `haasp_cli -ip 192.168.30.30 cmd zwave list_values 1` -*! cmd are entirely dependant on how each module has implement the cmd function !* - -* event -`haasp_cli [OPTION] event SOURCE DESTINATION REFERENCE VALUE` -Simulate event -example: `haasp_cli -ip 192.168.30.30 event zwave core bedroom_light true` - -* log -`haasp_cli [OPTION] log [FILTER]` -Show log output for all HAASP events. Use FILTER to filter out one specific module. -example: `haasp_cli -ip 192.168.30.30 log` -example: `haasp_cli -ip 192.168.30.30 log core` -example: `haasp_cli -ip 192.168.30.30 log zwave` - -* ping -`haasp_cli [OPTION] ping DESTINATION` -Check if module is alive -example: `haasp_cli ping core` -example: `haasp_cli -ip 192.168.30.30 ping zwave` diff --git a/content/cli/changelog.md b/content/cli/changelog.md deleted file mode 100644 index 21b77f1..0000000 --- a/content/cli/changelog.md +++ /dev/null @@ -1,6 +0,0 @@ -+++ -title = "Changelog" -date = "2018-08-06T11:09:51.000Z" -lastmodifierdisplayname = "Christian Martinsson" -lastmodifieremail = "chrillemz@gmail.com" -+++ diff --git a/content/core/_index.md b/content/core/_index.md deleted file mode 100644 index f017eef..0000000 --- a/content/core/_index.md +++ /dev/null @@ -1,160 +0,0 @@ -+++ -title = "Core" -weight = 6 -date = "2018-08-06T20:43:20.000Z" -lastmodifierdisplayname = "Christoffer Martinsson" -lastmodifieremail = "christoffer.martinsson@mildef.com" -+++ -HAASP Core engine that transport all event to and from all other modules. It also deliver configuration to all modules. -*! This module is required to have a funtional installation of HAASP !* -## Installation -**Docker image:** -`cmtec/haasp_core` - -**Pip:** -Make sure you have python3, git and pip installed -`pip install -U git+https://git.cmtec.se/haasp/libhaasp.git` -`pip install -U git+https://git.cmtec.se/haasp/haasp_core.git` - -## Usage -The config file is located at `~/.haasp/haasp_config.py` -This configuration is the essential part of manageing HAASP. - -### Empty Template -```python -from libhaasp import EventObject, ConfigObject - -class Config(ConfigObject): - - def config(self): - config = {} - # ------------------------------------------------------------------------- - # Configure modules - # ------------------------------------------------------------------------- - - return config - - - def setup(self): - # ------------------------------------------------------------------------- - # Create event objects - # ------------------------------------------------------------------------- - - - def process_event(self): - # ------------------------------------------------------------------------- - # Create workflows - # ------------------------------------------------------------------------- - -``` - -Please see the configuration chapter for more example how to use the configuration file - - -## Built in applications -The core module has two built in application modules: - -* Clock -* Timer - -### Clock - -**Config:** - -`["clock"]["location"] = ` - local time definition as defined in XXXXXXX - -**Object:** - -`EventObject("clock", "now")` - -* Value - Current time: HH:MM -* Event - Every minutes - -`EventObject("clock", "day")` - -* Value - Current day: `Monday`, `Tuseday`, `Wednesday`, `Thursday`, `Friday`, `Saturday` or `Sunday` -* Event - Every day at 00:01 - -`EventObject("clock", "sunset")` - -* Value - Current time for todays sunset: HH:MM -* Event - Every day at 00:01 - -`EventObject("clock", "sunrise")` - -* Value - Current time for todays sunrise: HH:MM -* Event - Every day at 00:01 - -**Example:** - -```python -class Config(ConfigObject): - - def config(self): - config = {} - # ------------------------------------------------------------------------- - # Configure modules - # ------------------------------------------------------------------------- - config["clock"] = {} - config["clock"]["location"] = "copenhagen" - - return config - - - def setup(self): - # ------------------------------------------------------------------------- - # Create event objects - # ------------------------------------------------------------------------- - self.clock = EventObject("clock", "now") - self.day = EventObject("clock", "day") - self.sunset = EventObject("clock", "sunset") - self.sunrise = EventObject("clock", "sunrise") - - def process_event(self): - # ------------------------------------------------------------------------- - # Create workflows - # ------------------------------------------------------------------------- - if self.clock.event == "06:30" or self.clock.event == self.sunset.value: - self.zwave_livingroom_window_light.set("true") - - if self.clock.event == "23:00" or self.clock.event == self.sunrise.value: - self.zwave_livingroom_window_light.set("false") -``` - -### Timer - -**Object:** - -`EventObject("timer", ")` - -**\** - Name reference for timer - -* Value - Countdown timer in seconds -* Set - Set new countdown value in seconds -* Event - `"triggered"` When timer reches 0 seconds - -**Example:** - -```python -class Config(ConfigObject): - - - def setup(self): - # ------------------------------------------------------------------------- - # Create event objects - # ------------------------------------------------------------------------- - self.timer_test = EventObject("timer", "test") - - def process_event(self): - # ------------------------------------------------------------------------- - # Create workflows - # ------------------------------------------------------------------------- - if self.timer_sink.event == "triggered": - self.zwave_kitchen_sink_light.set("false") - - if self.zwave_kitchen_motion.event == "true": - self.timer_sink.set(120) - -``` - - diff --git a/content/core/changelog.md b/content/core/changelog.md deleted file mode 100644 index eeff15a..0000000 --- a/content/core/changelog.md +++ /dev/null @@ -1,20 +0,0 @@ -+++ -title = "Changelog" -date = "2018-08-06T20:43:20.000Z" -lastmodifierdisplayname = "Christoffer Martinsson" -lastmodifieremail = "christoffer.martinsson@mildef.com" -+++ -### v1.2 - -* Changed from plain text message to json message -* Fixed init request - -### v1.1 - -* Added init and refresh request support -* Readme file updated - -### v1.0 - -* First release - diff --git a/content/libhaasp/_index.md b/content/libhaasp/_index.md deleted file mode 100644 index 4d87c9a..0000000 --- a/content/libhaasp/_index.md +++ /dev/null @@ -1,8 +0,0 @@ -+++ -title = "libHAASP" -head = "" -weight = 5 -date = "2018-08-09T14:27:53.000Z" -lastmodifierdisplayname = "Christoffer Martinsson" -lastmodifieremail = "cm@cmtec.se" -+++ diff --git a/content/libhaasp/changelog.md b/content/libhaasp/changelog.md deleted file mode 100644 index 664da97..0000000 --- a/content/libhaasp/changelog.md +++ /dev/null @@ -1,6 +0,0 @@ -+++ -title = "Changelog" -date = "2018-08-09T14:27:53.000Z" -lastmodifierdisplayname = "Christoffer Martinsson" -lastmodifieremail = "cm@cmtec.se" -+++ diff --git a/get_app_data.py b/get_app_data.py index 633ece2..2309a62 100755 --- a/get_app_data.py +++ b/get_app_data.py @@ -27,7 +27,7 @@ def create_files(path, readme, changelog): # LibHAASP date,name,email,readme,changelog = get_data("64") -meta_readme = '+++\ntitle = "libHAASP"\nhead = ""\nweight = 5\ndate = "' + date + '"\nlastmodifierdisplayname = "' + name + '"\nlastmodifieremail = "' + email + '"\n+++\n' +meta_readme = '+++\ntitle = "libHAASP"\nhead = ""\nweight = 5\ndate = "' + date + '"\nlastmodifierdisplayname = "' + name + '"\nlastmodifieremail = "' + email + '"\n+++\n' meta_changelog = '+++\ntitle = "Changelog"\ndate = "' + date + '"\nlastmodifierdisplayname = "' + name + '"\nlastmodifieremail = "' + email + '"\n+++\n' create_files("libhaasp", meta_readme + readme, meta_changelog + changelog) @@ -47,7 +47,10 @@ create_files("cli", meta_readme + readme, meta_changelog + changelog) weight = 10 for app in sorted(apps.keys()): date,name,email,readme,changelog = get_data(apps[app]) - meta_readme = '+++\nweight = "' + str(weight) + '"\ntitle = "' + app[0].upper() + app[1:] + '"\ndate = "' + date + '"\nlastmodifierdisplayname = "' + name + '"\nlastmodifieremail = "' + email + '"\n+++\n' + if weight == 10: + meta_readme = '+++\nweight = "' + str(weight) + '"\nhead = ""\ntitle = "' + app[0].upper() + app[1:] + '"\ndate = "' + date + '"\nlastmodifierdisplayname = "' + name + '"\nlastmodifieremail = "' + email + '"\n+++\n' + else: + meta_readme = '+++\nweight = "' + str(weight) + '"\ntitle = "' + app[0].upper() + app[1:] + '"\ndate = "' + date + '"\nlastmodifierdisplayname = "' + name + '"\nlastmodifieremail = "' + email + '"\n+++\n' meta_changelog = '+++\ntitle = "Changelog"\ndate = "' + date + '"\nlastmodifierdisplayname = "' + name + '"\nlastmodifieremail = "' + email + '"\n+++\n' create_files("applications/" + app, meta_readme + readme, meta_changelog + changelog) weight = weight + 1