How to set variable with date of last event


#1

How can you set a variable for the time an event occurred? Specifically I’m using the smart weather device and want the variable to be the last time it rained. Also not sure if im supposed to use a dynamic variable or the date and time variable.

I’m obviously not setting the variable correctly as it is now because it show up as a series of numbers.

Lastly I’m looking to getting some feedback if I’m using the best method to setting the variable for the windows’s Contact sensor because it doesn’t seem to be updating for me. Thanks in advance!


Convert UTC / Epoch Time to Human Time
#2

That series of numbers is the date as an Epoch time stamp (the number of seconds that have passed since Jan 1 1970).

1519433775418 = February 24th 2018 @ 12:36:41 GMT


#3

If you want the variable to show human readable values then set it as {date($currentEventDate)} or {dateTime($currentEventDate)}


#4

I assume you’re building these variables with the intention of including them in a notification at some point?

Rather then setting the open closed status in a variable, just place this in a notification:

{([device name : contact])}


#5

Fair point on the notification part and as far as the variable for the event date - do I still use a dynamic variable or do I use the date time variable. I’ve only ever used dynamic or device and sometimes find it to be confusing which type to use for which circumstances and why.


#6

Thanks for the help again - feel bad because you’re always bailing me out.


#7

Dynamic should be fine… but if you want to use that time as a condition or a trigger then it probably needs to be defined as a time or dateTime.


#8

If you know the variable is going to hold a datetime, then I think it’s better to set the type of that variable to datetime. It’s more obvious, and it will display nicely (as a date & a time). :smile: