I missed a feature to log the triggers, the event-flow of scenes or the temporal development of device variables at a glance. I want these logfiles outside of vera because of the limited space and the access restrictions.
So I created a way to write logs into specific files on a webserver: Now I get many specific logfiles per scene, per process etc…
-
-
-
-
- Examples: - - - - -
-
-
-
logfile for heater thermostates (danfoss,…) and the room temperature
2018-02-19 14:00:01 Scene Office SetpointNight
2018-02-19 14:00:01 Scene logCheck lastWake.13:50:35 TempRadiator:22.55 SPT_old:22.50 TempRoom:21.67 SPT_new:12.0 Trigger:ONight Action:setSPT
2018-02-19 14:11:10 Scene logCheck lastWake.14:10:08 TempRadiator:22.09 SPT_old:12.00 TempRoom:21.67 VariableOk noDo Trigger:check
logfile for security events
2018-02-20 08:41:01 Office Trigger: DoorOpen
2018-02-20 08:41:01 OfficeHall Trigger:MotionTrip
2018-02-20 08:41:05 Office Trigger: DoorClose
2018-02-20 08:42:12 OfficeHall Trigger:MotionUnTrip
logfile for envirement values
2017-12-06 11:37:15 Humidity RoomA:50.51 RoomB:41 RoomC:60.54
2017-12-06 17:37:15 Humidity RoomA:49.78 RoomB:42 RoomC:58.41
2017-12-06 23:37:15 Humidity RoomA:46.84 RoomB:42 RoomC:57.92
For me these logfiles are a neccessary help to watch the events of the last days and to debug unexpected behavior of the devices or the scenes.
The solution cosists of a lua function in startupLua, a php-script on the webserver and lua “log-calls” at appropriate places in scenes.
Maybe someone has a similar requirement and thus parts of this solution maybe helpfull for him.
-
The lua function “strLog(arg)” and the help function “mySplit” are pasted into startup LUA.
function mySplit(inStr,sep)
if sep == nil then sep=“%s” end
local t={}; i=1
for str in string.gmatch(inStr,“([^”…sep…“]+)”) do
t[i] = str
i = i + 1
end
return t
end
function strLog(arg)
local sArg=mySplit(arg,“!”)
local logFile=sArg[1]
local aStr=sArg[2]
local aaStr=string.gsub(aStr, “%s+”, “+”)
luup.inet.wget (“myDomain/path/strVera.php?tgt=” … logFile … “&aStr=” … aaStr)
end -
The function “strLog(arg)” can be called at appropriate places in all scenes with:
→ strLog(“targetFile!Text example”) or better: luup.call_delay(‘strLog’,0,“targetFile!text example”)
The result in this case is an updated file “targetFile.log” with the content “timestamp example”
A way to include values or to identify one out of multiple scene actions:
local aStr=“Text1 Text2”
local ValueA=123
local ValueB=luup.variable_get(“urn:upnp-org:serviceId:SwitchPower1”,“Status”,devNr)
aStr=aStr … " ValueA:" … ValueA … " ValueB:" … ValueB
strLog(aStr )
A way to identify and include scene triggers:
Add a piece of lua into the scene’s trigger definition luaBox. For scene 123: scn123=“openDoor”
This defines a global variable you can evaluate in the scene’s lua box with:
local scnTrig=scn123 or “”
scn123=“”
aStr=aStr … " scnTrigger:" … scnTrig
strLog(aStr )
- The function “strLog(arg)” transfers the logData per luup.inet.wget to a small script “strVera.php” on my webserver (see attachment). The behavior of strVera.php to generate the logfile “LogDevCheck.log” can be tested per browser url: //csvVera.php?LogDevCheck!testString .
The results are specific logfiles on the webserver.
A variant of this method to monitor the zwave net variables for all devices in one table (Neighbors, WakeupRating…) is described in:
http://forum.micasaverde.com/index.php/topic,60546.0.html