0

Control of communication with timestamp

Timi Adamer 3 weeks ago in bOS Configurator updated by Ricardo Pinto | visiontech pt 3 days ago 4

Hi,

I wan´t to make a heartbeat function to control my wireless device (LoraWan) so it is communicating with my bOS server.

I get a timestamp as a string, and i would like to check the string with the time on the bOS server. I think the month and date should be enough. Any suggestions on how to do this the best way. I started to try to parse out the string but I didn´t manage to parse it right. The string that is provided: 2025-05-20 09:26:05 and this will change every day.

Best regards Timi

Hello,

Yeah, it's not easy to parse the date time.

I was trying to do that, but still not finished, but I'll get there.

I think that one of the possibilities would be: parse your incoming lorawan timestamp, parse each value, create a task to compose a string with those values in the bOS format, compare the bOS time with the converted lorawan timestamp and do your thing.

I'm not an expert with the parsing stuff, and I did get some results, but not yet 100% working.

If someone has some already created task to parse the data time with 0's included (for example have 05 instead of 5, which means adding a zero when there isn't one), be my guest to share in the meanwhile :)

Best regards

So, I got something...

bOS apparentely ended with the seconds, at least I don't see them (I see them but they are always 00). No problem here, I just removed the seconds also from the time coming from Lorawan. Why I did that? Because now ComfortClick shows the seconds always as 00. So lets say you get the time from Lorawan with seconds showing (lets say 07), you won't be able to compare the strings, only if the time from Lorawan writes down 00 as seconds. So assuming the seconds are not important, I remove them. 

I had to compose two different strings, so I could have both ComfortClick and Lorawan timestamps in the same type, otherwise I wouldn't be able to compare both times. This might change depending on your location. ComfortClick configured in Portugal will shows the time as hh:mm:ss DD/MM/YYYY.

Also I was not able to show 0 before single digit numbers, Comfortclick treats 05 as 5. I didn't had trouble with the tasks, but in practice 21:05 will show as 21:5, where two digits will behave normally. But for the task, it doesn't matter.

Basically I created:

  • A demo string, simulating the timestamp coming from Lorawan, so I can force manually to test
  • A string where I could compose ComfortClick time minus the seconds
  • A string where I could compose Lorawan time in the ComfortClick format so that strings could be compared
  • A task with something like, if the time from Lorawan matches the time from ComfortClick, do something

I guess you'll have to fiddle around to adapt this example to your needs. Probably this is not the prettiest solution, but at least something works :) If I get a simpler solution, I'll keep you posted.

Also, bear in mind that I've done this example on a Jigsaw Pro. I had lots of trouble with the regex, as I'm not an expert. Don't know if the regex will work if you run this on a Windows Machine, or if you need to make any change in the regex. I had to try lots of examples from the internet. If someone has a better regex, please feel free to share.

Image 5328

Date-Time LoraWan.bos

Hi,

Thanks for the support!

I will try this out and see where it goes.

Hi,

I'm sorry for the not so cool implementation, but I'm really not an expert with parsing, so I came up with this long solution that may work for you.

At least I've tried and it worked. I just made a sample task where I would turn on a light if both times and dates were equal.

I'm sure there's a better way...but for now this is all I got :)

Best regards