Building an API interface for airconditioning automation

Since the fun is in the learning (I agree) I have two suggestions for you

  1. save the time in milliseconds (see https://www.w3schools.com/jsref/jsref_gettime.asp)
  2. read about context variables in functions (see https://nodered.org/docs/writing-functions#storing-data) and this A guide to understanding 'Persistent Context'

Using miliseconds will made the comparrisons easier and the two links should explain how to save and get the data.

If you have questions after reading them please ask.

"Tell me and I forget, teach me and I may remember, involve me and I learn." - Benjamin Franklin