Convert timestamp to HH:MM and test in condition

In my thermostat PLEG I have a condition that will fire whenever the thermostat’s temperature changes. Do determine if the condition is true or false, I want to compare the timestamp to an time interval. For example: If timestamp between 04:00 am and 08:00 a.m then true.

This thread [url=http://forum.micasaverde.com/index.php/topic,23207.msg157242.html#msg157242]http://forum.micasaverde.com/index.php/topic,23207.msg157242.html#msg157242[/url] shows how to capture the timestamp when the condition fires and write it to a container variable. I get the timestamp: 1483385255.1031.

How can I get the hours and minutes from the timestamp in order to do the comparison?
Is there another way to get the current time without using something like NOW in the expression? I do not want the condition to fire very minute.

Thanks!

I don’t understand why you’d need to capture the timestamp. Use a schedule and just catch the changing of the thermostat during the schedule. Without thinking about it for a minute, and I’m not in any shape at the moment to do it, I’m not even sure you’d need the NOW…

the time stamp is in Epoch time. the number of seconds since midnight 1/1/1970 UTC time. http://www.epochconverter.com/

Thanks for your reply Mike.

I read the Example - Simple Heater Timer in the PLEG Basics document and understand I can configure and run schedules to represent the various time intervals. I am trying to implement similar logic without having to setup the schedules. I also want to get the timestamp into hours / minutes format so that I can log and/or update a container with a message like “Heat last came on at 06:35 and has run for xx minutes”. I can get the run time using an expression like (#!SomeEvent - #SomeEvent) / 60 (thanks to a reply from Richard in another thread).

I’m still stuck, however, with converting a timestamp to a hh:mm format or a dd-mm-yy hh:mm format that I can use.

Thanks Beast -

I cam across that site earlier but did not understand if / how I can use it from within PLEG. Is it possible to call that site with the timestamp and have it return the formatted time?

I doubt it. but in Pleg it’s simple and you don’t need to do the calculations. (06:30:00; tmsKitchen; 22:30:00) This say if the time stamp of tmsKitchen is between 6:30 and 10:30 then true

Ok, I understand what you’re trying to do now. There is a way to do it but I have no idea if the libraries are present. Simple code, such as :

local ts = os.time()
print(os.date(‘%Y-%m-%d %H:%M:%S’, ts)

may give you a start. May I ask why you’re wanting to “record” that data when you could simply push it off (using one of the data logging plugins) to an external site? In the long run, I don’t think you’ll find it useful, but maybe you will. I pushed a ton of information off to an external site and I rarely look at it…