This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Comapration of hours
#1
Hi

I am a little novice in this programming through lua.

I need to compare the current time with a specific time to start a device.

How can 3-byte communication objects be compared?

The code used but does not work for me is the following:


Code:
hora = grp.getvalue('33/0/1')--,dt.time)

log (hora)
value = grp.getvalue('33/1/21')--,dt.time)

log (value)

if hora == value then
  log ("esto funciona")
  total = hora + value
  log (total)
else
  log("ERROR")
end
 and I get the following error


Code:
Event for Hora Actual (33/0/1) 28.01.2020 16:00:34
* table:
[day]
  * number: 2
[minute]
  * number: 0
[second]
  * number: 0
[hour]
  * number: 0
[min]
  * number: 0
[sec]
  * number: 0
Event for Hora Actual (33/0/1) 28.01.2020 16:00:34
* table:
[day]
  * number: 2
[minute]
  * number: 0
[second]
  * number: 0
[hour]
  * number: 0
[min]
  * number: 0
[sec]
  * number: 0
Event for Hora Actual (33/0/1) 28.01.2020 16:00:34
* string: ERROR
Can someone please help me?

Thank you
Reply
#2
Hi
Can you explain what problem are trying to solve? It is easier to compare os.time() You can easily read object update time and compare it with os.time.
BR
------------------------------
Ctrl+F5
Reply
#3
Hello Daniel
I am trying to compare the current time with a specific time to be able to perform a series of tasks.

Please, can you help me?

Thank you
Reply
#4
Current time with what? There is a lot of different time formats so you need to be more specific.
------------------------------
Ctrl+F5
Reply
#5
I want to compare the current time that is type 10. 3 Byte time / day with another time (it would also be type 10. 3 Byte time / day) that the user can put on a page of the visualization to be able to start a pump.

Thank you
Reply
#6
OK then you should compare all individual values from the table. hora.day == value.day etc..
------------------------------
Ctrl+F5
Reply
#7
Why not use schedulers for this?
Reply
#8
I don't use the planner because the time I want to calculate comes from a formula that has a delay or advance of a preset time depending on the pump.

Thanks a lot
Reply
#9
You can convert date/time table to minutes and then compare using <, > and ==
Code:
minutes = value.hour * 60 + value.min
Reply


Forum Jump: