X-Git-Url: https://git.realraum.at/?a=blobdiff_plain;f=r3-webstatus-spaceapi%2Fmain.go;h=114777e323ddff0d4e4fe7276aa96d76c9573a44;hb=a4e62b633d9f6c0325282eac8be35c5137d7fb48;hp=07bb19414a9c705c9a51994436ed58d556b974ee;hpb=7c22f62515e41750db14fff3181ab3452a6506bb;p=svn42.git diff --git a/r3-webstatus-spaceapi/main.go b/r3-webstatus-spaceapi/main.go index 07bb194..114777e 100644 --- a/r3-webstatus-spaceapi/main.go +++ b/r3-webstatus-spaceapi/main.go @@ -9,6 +9,7 @@ import ( "net/url" "regexp" "time" + "strconv" ) type SpaceState struct { @@ -72,24 +73,22 @@ func parseSocketInputLine(line string) { if match_presence != nil { statusstate.present = (match_presence[1] == "yes") + spaceapidata.MergeInSensor(spaceapi.MakeDoorLockSensor("Torwaechter", "Front Door", match_presence[2] == "closed")) publishStateToWeb() } else if match_button != nil { statusstate.buttonpress_until = time.Now().Unix() + 3600 spaceapidata.AddSpaceEvent("PanicButton", "check-in", "The button has been pressed") publishStateToWeb() } else if match_temp != nil { - spaceapidata.UpdateSensorData("temp", "Ceiling", match_temp[1]+"C") - //newtemp, err = strconv.ParseFloat((match_temp[1]), 32) - //if err == nil { - // spaceapidata.UpdateSensorData("temp", "Ceiling", strconv.FormatFloat(newtemp, 'f', 2, 32)+"C") - // spacestate.temperature = newtemp - //} + newtemp, err := strconv.ParseFloat((match_temp[1]), 32) + if err == nil { + spaceapidata.MergeInSensor(spaceapi.MakeTempCSensor("Temp0","Ceiling",newtemp)) + } } else if match_photo != nil { - spaceapidata.UpdateSensorData("light", "Front", match_photo[1]) - //newphoto, err = strconv.ParseInt(match_photo[1], 10, 32) - //if err == nil { - // spacestate.lightlevel = newphoto - //} + newphoto, err := strconv.ParseInt(match_photo[1], 10, 32) + if err == nil { + spaceapidata.MergeInSensor(spaceapi.MakeIlluminationSensor("Photodiode","Ceiling","1024V/5V",newphoto)) + } } }