Cleaned up code
This commit is contained in:
parent
000be4c9e1
commit
6f6c1ea9c1
5
.gitignore
vendored
Normal file
5
.gitignore
vendored
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
content/core
|
||||||
|
content/libhaasp
|
||||||
|
content/cli
|
||||||
|
content/applications
|
||||||
|
|
||||||
@ -1,7 +0,0 @@
|
|||||||
+++
|
|
||||||
title = "Applications"
|
|
||||||
weight=8
|
|
||||||
alwaysopen = true
|
|
||||||
+++
|
|
||||||
|
|
||||||
:
|
|
||||||
@ -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")
|
|
||||||
```
|
|
||||||
@ -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
|
|
||||||
@ -1,7 +0,0 @@
|
|||||||
+++
|
|
||||||
weight = "11"
|
|
||||||
title = "Huee"
|
|
||||||
date = "2018-08-06T13:14:07.000Z"
|
|
||||||
lastmodifierdisplayname = "Christoffer Martinsson"
|
|
||||||
lastmodifieremail = "christoffer.martinsson@mildef.com"
|
|
||||||
+++
|
|
||||||
@ -1,6 +0,0 @@
|
|||||||
+++
|
|
||||||
title = "Changelog"
|
|
||||||
date = "2018-08-06T13:14:07.000Z"
|
|
||||||
lastmodifierdisplayname = "Christoffer Martinsson"
|
|
||||||
lastmodifieremail = "christoffer.martinsson@mildef.com"
|
|
||||||
+++
|
|
||||||
@ -1,7 +0,0 @@
|
|||||||
+++
|
|
||||||
weight = "12"
|
|
||||||
title = "Webapp"
|
|
||||||
date = "2018-10-23T20:28:25.000Z"
|
|
||||||
lastmodifierdisplayname = "christianm"
|
|
||||||
lastmodifieremail = "chrillemz@gmail.com"
|
|
||||||
+++
|
|
||||||
@ -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
|
|
||||||
@ -1,7 +0,0 @@
|
|||||||
+++
|
|
||||||
weight = "13"
|
|
||||||
title = "Zwave"
|
|
||||||
date = "2018-08-06T12:01:09.000Z"
|
|
||||||
lastmodifierdisplayname = "Christoffer Martinsson"
|
|
||||||
lastmodifieremail = "christoffer.martinsson@mildef.com"
|
|
||||||
+++
|
|
||||||
@ -1,6 +0,0 @@
|
|||||||
+++
|
|
||||||
title = "Changelog"
|
|
||||||
date = "2018-08-06T12:01:09.000Z"
|
|
||||||
lastmodifierdisplayname = "Christoffer Martinsson"
|
|
||||||
lastmodifieremail = "christoffer.martinsson@mildef.com"
|
|
||||||
+++
|
|
||||||
@ -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`
|
|
||||||
@ -1,6 +0,0 @@
|
|||||||
+++
|
|
||||||
title = "Changelog"
|
|
||||||
date = "2018-08-06T11:09:51.000Z"
|
|
||||||
lastmodifierdisplayname = "Christian Martinsson"
|
|
||||||
lastmodifieremail = "chrillemz@gmail.com"
|
|
||||||
+++
|
|
||||||
@ -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"] = <string>` - 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>)`
|
|
||||||
|
|
||||||
**\<NAME\>** - 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)
|
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
@ -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
|
|
||||||
|
|
||||||
@ -1,8 +0,0 @@
|
|||||||
+++
|
|
||||||
title = "libHAASP"
|
|
||||||
head = "<label>Modules</label>"
|
|
||||||
weight = 5
|
|
||||||
date = "2018-08-09T14:27:53.000Z"
|
|
||||||
lastmodifierdisplayname = "Christoffer Martinsson"
|
|
||||||
lastmodifieremail = "cm@cmtec.se"
|
|
||||||
+++
|
|
||||||
@ -1,6 +0,0 @@
|
|||||||
+++
|
|
||||||
title = "Changelog"
|
|
||||||
date = "2018-08-09T14:27:53.000Z"
|
|
||||||
lastmodifierdisplayname = "Christoffer Martinsson"
|
|
||||||
lastmodifieremail = "cm@cmtec.se"
|
|
||||||
+++
|
|
||||||
@ -27,7 +27,7 @@ def create_files(path, readme, changelog):
|
|||||||
|
|
||||||
# LibHAASP
|
# LibHAASP
|
||||||
date,name,email,readme,changelog = get_data("64")
|
date,name,email,readme,changelog = get_data("64")
|
||||||
meta_readme = '+++\ntitle = "libHAASP"\nhead = "<label>Modules</label>"\nweight = 5\ndate = "' + date + '"\nlastmodifierdisplayname = "' + name + '"\nlastmodifieremail = "' + email + '"\n+++\n'
|
meta_readme = '+++\ntitle = "libHAASP"\nhead = "<label>Core Modules</label>"\nweight = 5\ndate = "' + date + '"\nlastmodifierdisplayname = "' + name + '"\nlastmodifieremail = "' + email + '"\n+++\n'
|
||||||
meta_changelog = '+++\ntitle = "Changelog"\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)
|
create_files("libhaasp", meta_readme + readme, meta_changelog + changelog)
|
||||||
|
|
||||||
@ -47,7 +47,10 @@ create_files("cli", meta_readme + readme, meta_changelog + changelog)
|
|||||||
weight = 10
|
weight = 10
|
||||||
for app in sorted(apps.keys()):
|
for app in sorted(apps.keys()):
|
||||||
date,name,email,readme,changelog = get_data(apps[app])
|
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 = "<label>Applications</label>"\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'
|
meta_changelog = '+++\ntitle = "Changelog"\ndate = "' + date + '"\nlastmodifierdisplayname = "' + name + '"\nlastmodifieremail = "' + email + '"\n+++\n'
|
||||||
create_files("applications/" + app, meta_readme + readme, meta_changelog + changelog)
|
create_files("applications/" + app, meta_readme + readme, meta_changelog + changelog)
|
||||||
weight = weight + 1
|
weight = weight + 1
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user