Configuration
The config file is located at ~/.haasp/haasp_config.py
Template
from libhaasp import EventObject, ConfigObject
class Config(ConfigObject):
def config(self):
config = {}
# Clock
config["clock"] = {}
config["clock"]["location"] = "copenhagen"
return config
def setup(self):
# -------------------------------------------------------------------------
# Create event objects
# -------------------------------------------------------------------------
self.clock = EventObject("clock", "now")
self.timer_test = EventObject("timer", "test")
def process_event(self):
# -------------------------------------------------------------------------
# Create workflows
# -------------------------------------------------------------------------
if self.timer_test.event == "triggered":
self.log.debug("Timer DONE!")
Example:
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)