I have a few drivers that I have scheduling future tasks using runIn. And it is working perfectly. My question is, how can I use either that info (the runIn seconds) or the scheduled execution to get the into info a state variable or attribute? Is there a way to "access" the scheduled executions of upcoming commands in a driver? I'm guessing there has to be but I can't find anything on it.
You could do something like state.nextRun = now() + (runInSeconds × 1000)
You know, Bruce hit the nail right on he head in that Hubitat live a few weeks ago...."Avoid working with time in software whenever you can." LOL It seems that's all I come up with to work on recently is time-based stuff.
So, what you gave me got me the Epoch time. After a little digging, I came up with:
state.nextRun = new Date(now() + (myDelay * 1000)).format('HH:mm',location.timeZone)
I also added a custom attribute called "next" with the string type and then did the following:
sendEvent(name: "next", value: state.nextRun, displayed: True)
At first I didn't have the displayed so it wouldn't show up on my dashboard but a little poking and I found that. Is there anything there that should be done in a better way? There's 100 ways to skin a cat but there are definitely ways that are easier and less problematic from a software perspective. You know, this stuff is all starting to make sense to me. But the more I learn, I realize how much more I have left to learn. Thank you @mike.maxwell!!!
Update: I even got the times to display in US format by changing "HH:mm" to "hh:mm a". And I didn't even have to look that one up! Okay...now I'm starting to scare myself.