State timestamp

Hi, I just migrated from SmartThings Hub to Hubitat to be able to continue to run a few groovy apps. One of those apps controlled lights and checked if a room is occupied even if there is no movement. To be able to do this i compared state rawDateCreated of two devices, but that property is not accessible in Hubitat. Is there a way to read the rawDateCreated or do i need to rewrite the logic to record now in a variable which was not very reliable in Smartthings.

Motion1,currentState(“motion”).rawDateCreated.time

Thanks
Goppi

1 Like

event.getUnixTime() might be what you’re looking for.

1 Like

This seems to be for events rather then states. That said is there anywhere a dev docu for all the objects available in hubitat? I found one half finished docu. The SmartThings docu doesn’t have this method either listed.

1 Like

Yes, that’s the one that is half finished.

I would go this route. What you appear to be trying to do would be woefully inefficient (although it probably wouldn't matter much).

Write now() to a state.variable whenever a motion or contact event happens. Read that state.variable whenever you need to check how long.

Using a state variable is unnecessary as the state is used in the same function. Besides it’s not the answer to the original question.

With some debugging and cross referencing with other methods, I figured out that i can get the event timestamp with the following code

Motion1,currentState(“motion”).date.time

1 Like

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.