Formating input signal into Time Format

Hi, I am completely new to Node Red and want to use it to integrate some PLC Logic into HomeAssistant.
My PLC is a Siemens LOGO!8 which controlls light and temperature of some terrariums - while HomeAssistant should be a "nice Dashboard" with other integrations.

I would like to display some parameters of the PLC control on this Dashboard (for now, only displaying, not controlling anything in LOGO)

I've got the NodeRed integration into HomeAssistant working - and also the connection to my LOGO Hardware.
This is fine - and I am also able to display the Status of some Sensors, and stuff like this.

Now, comming to my main issue:

On my LOGO, I have an astronomical clock running, which is checking for Sunrise and Sunset to trigger, when the lights should go on and off.

On the LOGO Display, I can see the correct time format:
2021-02-24 13_05_36-LOGO! TD

Sunrise: 07:04 AM
Sunset: 05:37 PM (17:37)

But if I'm trying to get the value of this block in NodeRed, I am getting:
2021-02-24 13_05_10-Node-RED - Home Assistant
Sunrise: 1796
Sunset: 5943

Any Idea, what I need to do to get the same output as in the LOGO Display?
Any kind of calculation or formatting?

Honestly, I were not able to figure out, what kind of format the output from my logo SHOULD be (it's not seconds or minutes, or anything that I could convert into a date/time format)

Thanks a lot and with best regards,

Those values are decimal & if you convert to hex you will see the time.

1796 == 0x704
5943 == 0x1737

here is a demo

function code...

var asHex = parseInt(msg.payload).toString("16").padStart(4,"0");
var hh = asHex.substring(0,2);
var mm = asHex.substring(2,4);
msg.payload = `${hh}:${mm}`
return msg;

Thanks a lot, is working perfectly and exactly as expected :slight_smile:
Decimal values... I should have considered this :-/

Again, thanks a lot :slight_smile:

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.