X-Git-Url: https://git.realraum.at/?a=blobdiff_plain;f=r3-webstatus-spaceapi%2Fmain.go;h=f4e4e766d7621d52eb6949ca7daebb188ebc65dd;hb=a5a4ac7a8733c31c14065230127c7836ac0de4f6;hp=114777e323ddff0d4e4fe7276aa96d76c9573a44;hpb=7867988775a7b6ec1604a863b665e46ac91e70ac;p=svn42.git diff --git a/r3-webstatus-spaceapi/main.go b/r3-webstatus-spaceapi/main.go index 114777e..f4e4e76 100644 --- a/r3-webstatus-spaceapi/main.go +++ b/r3-webstatus-spaceapi/main.go @@ -19,6 +19,7 @@ type SpaceState struct { var ( re_presence_ *regexp.Regexp = regexp.MustCompile("Presence: (yes|no)(?:, (opened|closed), (.+))?") + re_status_ *regexp.Regexp = regexp.MustCompile("Status: (closed|opened), (opening|waiting|closing|idle), (ajar|shut).*") re_button_ *regexp.Regexp = regexp.MustCompile("PanicButton|button\\d?") re_temp_ *regexp.Regexp = regexp.MustCompile("temp0: (\\d+\\.\\d+)") re_photo_ *regexp.Regexp = regexp.MustCompile("photo0: (\\d+)") @@ -67,14 +68,20 @@ func publishStateToWeb() { func parseSocketInputLine(line string) { match_presence := re_presence_.FindStringSubmatch(line) + match_status := re_status_.FindStringSubmatch(line) match_button := re_button_.FindStringSubmatch(line) match_temp := re_temp_.FindStringSubmatch(line) match_photo := re_photo_.FindStringSubmatch(line) if match_presence != nil { statusstate.present = (match_presence[1] == "yes") - spaceapidata.MergeInSensor(spaceapi.MakeDoorLockSensor("Torwaechter", "Front Door", match_presence[2] == "closed")) + //spaceapidata.MergeInSensor(spaceapi.MakeDoorLockSensor("Torwaechter", "Front Door", match_presence[2] == "closed")) + spaceapidata.MergeInSensor(spaceapi.MakeDoorLockSensor("TorwaechterLock", "Türschloß", match_presence[2] == "closed")) publishStateToWeb() + } else if match_status != nil { + spaceapidata.MergeInSensor(spaceapi.MakeDoorLockSensor("TorwaechterLock", "Türschloß", match_status[1] == "closed")) + spaceapidata.MergeInSensor(spaceapi.MakeDoorLockSensor("TorwaechterAjarSensor", "Türkontakt", match_status[3] == "shut")) + //spaceapidata.MergeInSensor(spaceapi.MakeDoorAjarSensor("Torwaechter", "Front Door", match_presence[3] == "shut")) } else if match_button != nil { statusstate.buttonpress_until = time.Now().Unix() + 3600 spaceapidata.AddSpaceEvent("PanicButton", "check-in", "The button has been pressed") @@ -82,12 +89,12 @@ func parseSocketInputLine(line string) { } else if match_temp != nil { newtemp, err := strconv.ParseFloat((match_temp[1]), 32) if err == nil { - spaceapidata.MergeInSensor(spaceapi.MakeTempCSensor("Temp0","Ceiling",newtemp)) + spaceapidata.MergeInSensor(spaceapi.MakeTempCSensor("Temp0","Decke",newtemp)) } } else if match_photo != nil { newphoto, err := strconv.ParseInt(match_photo[1], 10, 32) if err == nil { - spaceapidata.MergeInSensor(spaceapi.MakeIlluminationSensor("Photodiode","Ceiling","1024V/5V",newphoto)) + spaceapidata.MergeInSensor(spaceapi.MakeIlluminationSensor("Photodiode","Decke","1024V/5V",newphoto)) } } } @@ -119,7 +126,7 @@ func main() { spaceapidata.AddSpaceFeed("google+", "text/html", "https://plus.google.com/113737596421797426873") spaceapidata.AddSpaceContactInfo("+43780700888524", "irc://irc.oftc.net/#realraum", "realraum@realraum.at", "realraum@realraum.at", "realraum@realraum.at", "vorstand@realraum.at") eventqueue := make(chan string) - ticker := time.NewTicker(time.Duration(15) * time.Minute) + ticker := time.NewTicker(time.Duration(7) * time.Minute) go readFromUSocket("/var/run/tuer/presence.socket", eventqueue) for { select {