From 449707893d7c9475f8c749a6e37babe7cf2518cd Mon Sep 17 00:00:00 2001 From: realraum Date: Wed, 24 Mar 2010 13:34:59 +0000 Subject: [PATCH] turn everything off when nobody is here --- switch-power.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/switch-power.py b/switch-power.py index 131361a..5364de1 100755 --- a/switch-power.py +++ b/switch-power.py @@ -31,6 +31,7 @@ class UWSConfig: self.config_parser.set('slug','cgiuri','http://slug.realraum.at/cgi-bin/switch.cgi?id=%ID%&power=%ONOFF%') self.config_parser.set('slug','ids_present','logo werkzeug') self.config_parser.set('slug','ids_panic','idee schreibtisch labor werkzeug') + self.config_parser.set('slug','ids_nonpresent_off','idee schreibtisch labor werkzeug stereo logo') self.config_parser.add_section('debug') self.config_parser.set('debug','enabled',"True") self.config_parser.add_section('tracker') @@ -106,9 +107,13 @@ def switchPower(powerid,turn_on=False): onoff="off" touchURL(uwscfg.slug_cgiuri.replace("%ID%",powerid).replace("%ONOFF%",onoff)) -def eventPresent(somebody_present=False): +def eventPresent(): for id in uwscfg.slug_ids_present.split(" "): - switchPower(id,somebody_present) + switchPower(id,True) + +def eventNobodyHere(): + for id in uwscfg.slug_ids_nonpresent_off.split(" "): + switchPower(id,False) def eventPanic(): lst1 = uwscfg.slug_ids_panic.split(" ") @@ -175,7 +180,10 @@ while True: m = RE_PRESENCE.match(line) if not m is None: status = m.group(1) - eventPresent(status == "yes") + if status == "yes": + eventPresent() + else: + eventNobodyHere() continue m = RE_BUTTON.match(line) if not m is None: -- 1.7.10.4