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+)")
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")
} 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))
}
}
}
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 {
html='<table border="0" cellpadding="0" cellspacing="0" width="100%" height="100"><tr><td style="width:100px;"><img style="float:left;" src="'+iconuri+'" height="100" width="100"/></td><td style="width:4px;"></td><td class="anwesenheitsstatus" style="background-color:'+statuscolor+'; ">'+data.status+'</td></tr></table>';
document.getElementById('anwesenheit_status').innerHTML=html;
- if (data.sensors)
+if (data.sensors)
{
if (data.sensors.temperature)
{
+ sensorstd+='<td style="background-color:white; height:42px; text-align:center; vertical-align:middle; display:table-cell;"><b>Temperatur</b>';
$.each( data.sensors.temperature, function(s, sensorobj) {
- sensorstd+='<td style="background-color:white; height:42px; text-align:center; vertical-align:middle; display:table-cell;"><b>Temperatur</b><br/>'+sensorobj.location+': '+sensorobj.value.toFixed(2)+sensorobj.unit+'</td>';
+ sensorstd+='<br/>'+sensorobj.location+': '+sensorobj.value.toFixed(2)+sensorobj.unit;
});
+ sensorstd+='</td>';
}
if (data.sensors.ext_illumination)
{
+ sensorstd+='<td style="background-color:white; height:42px; text-align:center; vertical-align:middle; display:table-cell;"><b>Licht</b>';
$.each( data.sensors.ext_illumination, function(s, sensorobj) {
- sensorstd+='<td style="background-color:white; height:42px; text-align:center; vertical-align:middle; display:table-cell;"><b>Licht</b><br/>'+sensorobj.location+': '+sensorobj.value+'</td>';
+ sensorstd+='<br/>'+sensorobj.location+': '+sensorobj.value;
});
+ sensorstd+='</td>';
}
if (data.sensors.door_locked)
{
+ sensorstd+='<td style="background-color:white; height:42px; text-align:center; vertical-align:middle; display:table-cell;"><b>Eingangstür</b>';
$.each( data.sensors.door_locked, function(s, sensorobj) {
- var lockstatus="Unlocked";
- if (sensorobj.value) { lockstatus = "Locked"; }
- sensorstd+='<td style="background-color:white; height:42px; text-align:center; vertical-align:middle; display:table-cell;"><b>Türschloß</b><br/>'+sensorobj.location+': '+lockstatus+'</td>';
+ var lockstatus="Auf";
+ if (sensorobj.value) { lockstatus = "Zu"; }
+ sensorstd+='<br/>'+sensorobj.location+': '+lockstatus;
});
+ sensorstd+='</td>';
}
if (data.sensors.ext_door_ajar)
{
+ sensorstd+='<td style="background-color:white; height:42px; text-align:center; vertical-align:middle; display:table-cell;"><b>Türkontakt</b>';
$.each( data.sensors.ext_door_ajar, function(s, sensorobj) {
- var lockstatus="Shut";
- if (sensorobj.value) { lockstatus = "Ajar"; }
- sensorstd+='<td style="background-color:white; height:42px; text-align:center; vertical-align:middle; display:table-cell;"><b>Türkontakt</b><br/>'+sensorobj.location+': '+lockstatus+'</td>';
+ var lockstatus="Auf";
+ if (sensorobj.value) { lockstatus = "Zu"; }
+ sensorstd+='<br/>'+sensorobj.location+': '+lockstatus;
});
+ sensorstd+='</td>';
}
if (data.sensors.ext_dust)
{
+ sensorstd+='<td style="background-color:white; height:42px; text-align:center; vertical-align:middle; display:table-cell;"><b>Staub</b>';
$.each( data.sensors.ext_dust, function(s, sensorobj) {
- sensorstd+='<td style="background-color:white; height:42px; text-align:center; vertical-align:middle; display:table-cell;"><b>Staub</b><br/>'+sensorobj.location+': '+sensorobj.value+sensorobj.unit+'</td>';
+ sensorstd+='<br/>'+sensorobj.location+': '+sensorobj.value+sensorobj.unit+'</td>';
});
+ sensorstd+='</td>';
}
if (sensorstd != "")
sensorshtml='<table border="0" cellpadding="0" cellspacing="0" width="100%"><tr>'+sensorstd+'</tr></table>';
document.getElementById('sensor_status').innerHTML=sensorshtml;
}
- }
+ }
}
function updateAnwesenheitStatus()