Author Topic: Device Snapshot - How to capture a point in time and share ?  (Read 141 times)

Offline parkerc

  • Sr. Hero Member
  • ******
  • Posts: 2330
  • Karma: +32/-44
  • Life Moves Pretty Fast....
    • Node Central
Device Snapshot - How to capture a point in time and share ?
« on: August 25, 2017, 06:06:48 am »
Hi

A very random fault (trouble condition) is occurring on my DSC Alarm panel, but it clears so quickly I'm not able to see it. 

While I can try and run through the logs etc. It made me wonder how I could capture a snap shot of my security system settings/variables as the exact time a trouble condition is met as that is captured by the DSC plugin

Ive created a function which would grab the key variables, but I'm not sure of the best way to store/share the gathered information ?

What do people recommend ?

Code below..

Code: [Select]
function dsc_systemcheck ()
local system = 333
-- "urn:micasaverde-com:serviceId:DSCAlarmPanel1","InterfaceType"
-- "urn:micasaverde-com:serviceId:DSCAlarmPanel1","ActivePartitions"
-- "urn:micasaverde-com:serviceId:DSCAlarmPanel1","DoorZones"
-- "urn:micasaverde-com:serviceId:DSCAlarmPanel1","MotionZones"
-- "urn:micasaverde-com:serviceId:DSCAlarmPanel1","SmokeZones"
-- "urn:micasaverde-com:serviceId:DSCAlarmPanel1","EnableRemoteArm"
-- "urn:micasaverde-com:serviceId:DSCAlarmPanel1","EnableRemotePanic"
-- "urn:micasaverde-com:serviceId:DSCAlarmPanel1","EnableManualLabels"
-- "urn:micasaverde-com:serviceId:DSCAlarmPanel1","VendorStatusData"
local VendorStatusData=luup.variable_get("urn:micasaverde-com:serviceId:DSCAlarmPanel1","VendorStatusData",system)
print ("VendorStatusData = " ..VendorStatusData)
-- "urn:micasaverde-com:serviceId:DSCAlarmPanel1","VendorStatusCode"
local VendorStatusCode=luup.variable_get("urn:micasaverde-com:serviceId:DSCAlarmPanel1","VendorStatusCode",system)
print ("VendorStatusCode = " ..VendorStatusCode)
-- "urn:micasaverde-com:serviceId:DSCAlarmPanel1","VendorStatus"
local VendorStatus=luup.variable_get("urn:micasaverde-com:serviceId:DSCAlarmPanel1","VendorStatus",system)
print ("VendorStatus = " ..VendorStatus)
-- "urn:micasaverde-com:serviceId:DSCAlarmPanel1","FirmwareVersion"
local FirmwareVersion=luup.variable_get("urn:micasaverde-com:serviceId:DSCAlarmPanel1","FirmwareVersion",system)
print ("FirmwareVersion = " ..FirmwareVersion)
-- "urn:micasaverde-com:serviceId:DSCAlarmPanel1","LCD"
local LCD=luup.variable_get("urn:micasaverde-com:serviceId:DSCAlarmPanel1","LCD",system)
print ("LCD = " ..LCD)
-- "urn:micasaverde-com:serviceId:DSCAlarmPanel1","TimeBroadcast"
local TimeBroadcast=luup.variable_get("urn:micasaverde-com:serviceId:DSCAlarmPanel1","TimeBroadcast",system)
print ("TimeBroadcast = " ..TimeBroadcast)
-- "urn:micasaverde-com:serviceId:DSCAlarmPanel1","PanicKeyAlarm"
-- "urn:micasaverde-com:serviceId:HaDevice1","LastUpdate"
-- "urn:micasaverde-com:serviceId:HaDevice1","CommFailure"
local CommFailure=luup.variable_get("urn:micasaverde-com:serviceId:HaDevice1","CommFailure",system)
print ("CommFailure = " ..CommFailure)
-- "urn:micasaverde-com:serviceId:HaDevice1","Configured"
local Configured=luup.variable_get("urn:micasaverde-com:serviceId:HaDevice1","Configured",system)
print ("Configured = " ..Configured)
print (" ")
print ("- - - - - - - - - - - - - - - - - - - - - - - - - - - -")
print (" ")
local system = 344
-- "urn:micasaverde-com:serviceId:AlarmPartition2","VendorStatusData"
local VendorStatusData=luup.variable_get("urn:micasaverde-com:serviceId:AlarmPartition2","VendorStatusData",system)
print ("VendorStatusData = " ..VendorStatusData)
-- "urn:micasaverde-com:serviceId:AlarmPartition2","VendorStatusCode"
local VendorStatusCode=luup.variable_get("urn:micasaverde-com:serviceId:AlarmPartition2","VendorStatusCode",system)
print ("VendorStatusCode = " ..VendorStatusCode)
-- "urn:micasaverde-com:serviceId:AlarmPartition2","VendorStatus"
local VendorStatus=luup.variable_get("urn:micasaverde-com:serviceId:AlarmPartition2","VendorStatus",system)
print ("VendorStatus = " ..VendorStatus)
-- "urn:micasaverde-com:serviceId:AlarmPartition2","ArmMode"
local ArmMode=luup.variable_get("urn:micasaverde-com:serviceId:AlarmPartition2","ArmMode",system)
print ("ArmMode = " ..ArmMode)
-- "urn:micasaverde-com:serviceId:AlarmPartition2","DetailedArmMode"
local DetailedArmMode=luup.variable_get("urn:micasaverde-com:serviceId:AlarmPartition2","DetailedArmMode",system)
print ("DetailedArmMode = " ..DetailedArmMode)
-- "urn:micasaverde-com:serviceId:AlarmPartition2","Alarm"
local Alarm=luup.variable_get("urn:micasaverde-com:serviceId:AlarmPartition2","Alarm",system)
print ("Alarm = " ..Alarm)
-- "urn:micasaverde-com:serviceId:AlarmPartition2","AlarmMemory"
local AlarmMemory=luup.variable_get("urn:micasaverde-com:serviceId:AlarmPartition2","AlarmMemory",system)
print ("AlarmMemory = " ..AlarmMemory)
-- "urn:micasaverde-com:serviceId:AlarmPartition2","LastAlarmActive"
local LastAlarmActive=luup.variable_get("urn:micasaverde-com:serviceId:AlarmPartition2","LastAlarmActive",system)
print ("LastAlarmActive = " ..LastAlarmActive)
-- "urn:micasaverde-com:serviceId:AlarmPartition2","LastUser"
local LastUser1=luup.variable_get("urn:micasaverde-com:serviceId:AlarmPartition2","LastUser",system)
print ("LastUser = " ..LastUser1)
-- "urn:micasaverde-com:serviceId:DSCAlarmPartition1","ArmModeNum"
local ArmModeNum=luup.variable_get("urn:micasaverde-com:serviceId:DSCAlarmPartition1","ArmModeNum",system)
print ("ArmModeNum = " ..ArmModeNum)
-- "urn:micasaverde-com:serviceId:HaDevice1","Configured"
local Configured=luup.variable_get("urn:micasaverde-com:serviceId:HaDevice1","Configured",system)
print ("Configured = " ..Configured)
print (" ")
print ("END")
print (" ")
end

dsc_systemcheck()
« Last Edit: August 25, 2017, 11:28:14 am by parkerc »

Online akbooer

  • Master Member
  • *******
  • Posts: 5131
  • Karma: +221/-67
  • "Less is more"
Re: Device Snapshot - How to capture a point in time and share ?
« Reply #1 on: August 25, 2017, 06:22:27 am »
You could append your results to a file in /www/ and then peruse it with a web browser.
3x Vera Lite-UI5/Edge-UI7, 25x Fibaro, 23x TKB, 9x MiniMote, 2x NorthQ Power, 2x Netatmo, 1x Foscam FI9831P.
Razberry, MySensors Arduino, HomeWave, AltUI, DataYours, openLuup, ZWay, ZeroBrane Studio.

Offline parkerc

  • Sr. Hero Member
  • ******
  • Posts: 2330
  • Karma: +32/-44
  • Life Moves Pretty Fast....
    • Node Central
Re: Device Snapshot - How to capture a point in time and share ?
« Reply #2 on: August 25, 2017, 11:58:57 am »
Nice idea, I think I can do that;  but how could I ensure that each file created is a new snapshot ?

UPDATE - Idea, I'll just add a header to the text file, with time stamp then append everything in order so it creates some history.. 
« Last Edit: August 25, 2017, 12:09:04 pm by parkerc »

Offline parkerc

  • Sr. Hero Member
  • ******
  • Posts: 2330
  • Karma: +32/-44
  • Life Moves Pretty Fast....
    • Node Central
Re: Device Snapshot - How to capture a point in time and share ?
« Reply #3 on: August 25, 2017, 12:14:37 pm »
Is there a cleaner way to do the writing ? The following works, but it feels code heavy/convoluted having to write file:write for every line ??

Code: [Select]
local time = os.date("%Y-%m-%d %H:%M:%S")

local file = io.open("/www/dsc_snapshot.txt", 'a')

file:write("\n")
file:write("DSC Snapshot taken at " ..time .. "\n")
-- file:write("- - - - - - - " "\n")
file:write("\n")
file:write("VendorStatusData = " ..VendorStatusData.. "\n")
file:write("VendorStatusCode = " ..VendorStatusCode.. "\n")
file:write("VendorStatus =     " ..VendorStatus.. "\n")
-- etc etc
file:close()

That creates this..

Quote
DSC Snapshot taken at 2017-08-25 17:12:19

VendorStatusData = 00032  Date     Time AUG 25/17  5:09p
VendorStatusCode = 901
VendorStatus =     LCD Update
« Last Edit: August 25, 2017, 12:17:22 pm by parkerc »

Online akbooer

  • Master Member
  • *******
  • Posts: 5131
  • Karma: +221/-67
  • "Less is more"
Re: Device Snapshot - How to capture a point in time and share ?
« Reply #4 on: August 25, 2017, 12:52:03 pm »
I'll just add a header to the text file, with time stamp then append everything in order so it creates some history..

Yes, that's what I was thinking.

Is there a cleaner way to do the writing ?

Oh, most certainly...

Write the 'fixed' text as a single string and using formatting escapes for the variable data.

Code: [Select]
local time = os.date("%Y-%m-%d %H:%M:%S")

local text = [[

DSC Snapshot taken at %s

VendorStatusData = %s
VendorStatusCode = %s
VendorStatus =     %s

]]

local file = io.open("/www/dsc_snapshot.txt", 'a')
file:write (text: format (time, VendorStatusData, VendorStatusCode, VendorStatus))
-- etc etc
file:close()

3x Vera Lite-UI5/Edge-UI7, 25x Fibaro, 23x TKB, 9x MiniMote, 2x NorthQ Power, 2x Netatmo, 1x Foscam FI9831P.
Razberry, MySensors Arduino, HomeWave, AltUI, DataYours, openLuup, ZWay, ZeroBrane Studio.