diff --git a/content/cli/_index.md b/content/cli/_index.md index 806b16d..83dfdb3 100644 --- a/content/cli/_index.md +++ b/content/cli/_index.md @@ -5,3 +5,46 @@ 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/configuration/_index.md b/content/configuration/_index.md index 78b9e87..4a24371 100644 --- a/content/configuration/_index.md +++ b/content/configuration/_index.md @@ -39,3 +39,126 @@ class Config(ConfigObject): if self.timer_test.event == "triggered": self.log.debug("Timer DONE!") ``` + +Example: +```python +from libhaasp import EventObject, ConfigObject +# ------------------------------------------------------------------------- +# User defined imports +# ------------------------------------------------------------------------- + +class Config(ConfigObject): + + def config(self): + config = {} + + # Clock + config["clock"] = {} + config["clock"]["location"] = "copenhagen" + + # Zwave + config["zwave"] = {} + config["zwave"]["device"] = "/dev/serial/by-id/usb-0658_0200_12345678-9012-3456-7890-123456789012-if00" + + 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") + + # Zwave + self.zwave_livingroom_window_light = EventObject("zwave", "72057594512490496") + + self.zwave_kitchen_ceiling_light = EventObject("zwave", "144115188500086784") + self.zwave_kitchen_sink_light = EventObject("zwave", "72057594462158848") + self.zwave_kitchen_window_light = EventObject("zwave", "72057594143391744") + self.zwave_kitchen_motion = EventObject("zwave", "72057594428784640") + + self.zwave_stairway_light = EventObject("zwave", "216172782303133696") + self.zwave_stairway_motion = EventObject("zwave", "72057594344898560") + + self.zwave_workshop_solder_iron = EventObject("zwave", "432345564265922560") + + self.zwave_bedroom_closet_light = EventObject("zwave", "72057594294386688") + + self.zwave_restroom_ceiling_light = EventObject("zwave", "216172782319910912") + self.zwave_restroom_mirror_light = EventObject("zwave", "288230376357838848") + self.zwave_restroom_motion = EventObject("zwave", "72057594210680832") + + self.zwave_outdoor_entrance_light = EventObject("zwave", "288230376341061632") + self.zwave_outdoor_balcony_light = EventObject("zwave", "72057594277609472") + + + # WebApp + self.webapp_livingroom_tv = EventObject("webapp", "toggle.livingroom.tv") + + + # Timers + self.timer_restroom = EventObject("timer", "restroom") + self.timer_closet = EventObject("timer", "closet") + self.timer_stairway = EventObject("timer", "stairway") + self.timer_solder_iron = EventObject("timer", "solder_iron") + self.timer_sink = EventObject("timer", "sink") + + + def process_event(self): + + # ------------------------------------------------------------------------- + # Create workflows + # ------------------------------------------------------------------------- + + # WebApp + if self.webapp_livingroom_tv.event == "true": + self.webapp_livingroom_tv.set("true") + if self.webapp_livingroom_tv.event == "false": + self.webapp_livingroom_tv.set("false") + + # Comfort light + if self.clock.event == "06:30" or self.clock.event == self.sunset.value: + self.zwave_livingroom_window_light.set("true") + self.zwave_kitchen_window_light.set("true") + self.zwave_outdoor_entrance_light.set("true") + self.zwave_outdoor_balcony_light.set("true") + + if self.clock.event == "23:00" or self.clock.event == self.sunrise.value: + self.zwave_livingroom_window_light.set("false") + self.zwave_kitchen_window_light.set("false") + self.zwave_outdoor_entrance_light.set("false") + self.zwave_outdoor_balcony_light.set("false") + + # Timers + if self.timer_sink.event == "triggered": + self.zwave_kitchen_sink_light.set("false") + + if self.timer_closet.event == "triggered": + self.zwave_bedroom_closet_light.set("false") + + if self.timer_stairway.event == "triggered": + self.zwave_stairway_light.set("false") + + if self.timer_restroom.event == "triggered": + self.zwave_restroom_mirror_light.set("false") + self.zwave_restroom_ceiling_light.set("false") + + # Motion triggers + if self.zwave_kitchen_motion.event == "true": + self.zwave_kitchen_sink_light.set("true") + self.timer_sink.set(120) + + if self.zwave_restroom_motion.event == "true": + self.zwave_restroom_mirror_light.set("true") + self.timer_restroom.set(600) + + if self.zwave_stairway_motion.event == "true": + self.zwave_stairway_light.set("true") + self.timer_stairway.set(120) +``` + + diff --git a/content/core/_index.md b/content/core/_index.md index 984580e..f017eef 100644 --- a/content/core/_index.md +++ b/content/core/_index.md @@ -5,3 +5,156 @@ 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/static/css/custom.css b/static/css/custom.css index 179ffe6..1071f3e 100644 --- a/static/css/custom.css +++ b/static/css/custom.css @@ -95,12 +95,23 @@ article section.page h1:first-of-type { article section.page h2 { font-size: 1.5rem; + background: #161616; + padding-top: 5px; + padding-bottom: 5px; + padding-left: 5px; + margin-left: -5px; } article section.page h3 { - font-size: 1.2rem; + font-size: 1.5rem; + border-bottom: solid #303030; + padding-left: 5px; + margin-left: -5px; } +article section.page h4 { + font-size: 1.2rem; +} .nav i { color: #c6c6c6; }