Sending time on MODBUS TCP, setting MSB and LSB

My ventilation system doesn’t have a very accurate clock, but the time can be set using MODBUS. I’m trying to figure out how I can send the hour and minute in the following format:

My current script looks like this:

alias: Komfovent set current time
sequence:
  - service: modbus.write_register
    data:
      address: 28
      hub: komfovent
      unit: 1
      value: "{{ now().timestamp() | timestamp_custom('%H%M') }}"

But this number, e.g. 1215, gets converted to hex as a whole, so the result becomes: 4BF, but the correct value should be 0C0F (0C = 12 and 0F = 15)

How can I do this with a template?

Hopefully someone can help with a template, but if I could make a suggestion - why not do it in Node red? Would be easy to do and you could schedule a clock update for every 10 minutes or longer, depending on how badly your ventilation system drifts so you are not writing to that register every few seconds.

My goal is not to write to the register every few seconds, but once a week. And that can easily be scheduled in Home Assistant as well.

Just spilt them ??

{{"%02x" | format( (now().timestamp()| timestamp_custom('%H'))|int)+ "%02x" | format( (now().timestamp()| timestamp_custom('%M'))|int)}}

I also stumbled on this in another topic, where msb and lsb are actually split :thinking:

  - service: modbus.write_register
    data:
      address: 28
      unit: 1
      hub: komfovent
      value:
        - '{{ "%02x" | format( (now().timestamp()| timestamp_custom('%H'))|int) }}' #msb
        - '{{ "%02x" | format( (now().timestamp()| timestamp_custom('%M'))|int) }}' #lsb

And shouldn’t it be address 29 (as shown in your screen shot :thinking:)