Actually, I was looking for a trigger to and a subscription to execute when the system shutdown starts.
However, as that is not possible, I looked into the Application logs, as Pai suggested.
I was able to use the log ">>>>>>> PLATFORM SHUTDOWN START <<<<<<<<<" to identify when the system shutdown started.
I am getting this value on the trigger of ThingStart Event, on a system restart.
Below is the code I am using to fetch the last Platform shutdown.
// result: INFOTABLE dataShape: "LogEntry"
let QueryLog = Logs["ApplicationLog"].QueryLogEntries({
maxItems: 1 /* NUMBER {"defaultValue":500} */,
searchExpression: ">>>>>>> PLATFORM SHUTDOWN START <<<<<<<<<" /* STRING */,
fromLogLevel: undefined /* STRING */,
instance: undefined /* STRING */,
isRegex: undefined /* BOOLEAN {"defaultValue":false} */,
endDate: undefined /* DATETIME */,
origin: undefined /* STRING */,
thread: undefined /* STRING */,
platformId: undefined /* STRING */,
ascendingSearch: undefined /* BOOLEAN */,
oldestFirst: undefined /* BOOLEAN */,
toLogLevel: undefined /* STRING */,
user: undefined /* USERNAME */,
sortFieldName: undefined /* STRING */,
startDate: undefined /* DATETIME */
});
Thanks and Regards,
Bhushan