If this is your first visit, be sure to check out the FAQ. You must register before you can post. Your first post will be checked for appropriate content
(SPAM) - please allow a bit of time for that. After that, you'll be able to post at will!
The time is set as follows. The variable type is date. This means it can't be string. It could be a defined date that you can use as a trigger. You would also have to check the update for the device to not update unless values change.
From help file: Purpose
This function sets the last change time of a device. Parameters
Parameter: dvRef
Type: Integer
Description: This is the device reference ID number.
Parameter: date-time
Type: date
Description: This is the date and time to set the last change to. Returns
He wants to change an Event Last Triggered Date, not a Device. I have been trying to find that function and had no luck. As far as I know Event info is stored in the database as a "blob", which I think must be deserialized, edited then stored again. Perhaps Jon00 or one of the other developers can answer. Here is the Event data string structure.
I did some investigation and in HS3, I don't think you can write it back with any readily available functions/subroutines. It appears that in HS2 you could. Seems odd that you can't get the object by reference. There have been many posts of frustration on this in the forum.
My only thought on a workaround is to create a device that is a proxy for the event and use that for triggering as needed. It seems inconsistent in design to prevent modification of this when you have control of most things via script.
I wrote a script to show the behavior: hs.SaveEventsDevices only saves script created events.
'-------------------------------------------
'Set the last time an event was triggered
'12/2/2019 Parm should be the EventID if you are passing
'-------------------------------------------
MyEventData = hs.Event_Info(evRef) 'Get the Event Data Structure
hs.writelog("Script", "The Date-Time is: " & CStr(MyEventData.Last_Triggered)) 'Write 2 log for debug
Comment