thomasjsn
(Thomas Jensen)
September 18, 2023, 9:42am
1
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?
1 Like
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.
thomasjsn
(Thomas Jensen)
September 19, 2023, 6:10am
3
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.
aceindy
(Aceindy)
October 10, 2023, 2:52pm
4
Just spilt them ??
{{"%02x" | format( (now().timestamp()| timestamp_custom('%H'))|int)+ "%02x" | format( (now().timestamp()| timestamp_custom('%M'))|int)}}
aceindy
(Aceindy)
October 11, 2023, 6:46pm
5
I also stumbled on this in another topic, where msb and lsb are actually split
- 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 )
thomasjsn
(Thomas Jensen)
November 28, 2024, 8:01am
6
I still haven’t been able to figure this out, but instead resorted to setting the time to 0:30 every Monday.
alias: Komfovent reset time 0:30
sequence:
- data:
address: 28
hub: komfovent
unit: 1
value: 30
action: modbus.write_register
mode: single
description: ""
Documented here: (Re)set the time on our Komfovent ventilation system :: Cavelab blog — Stories from the Cavelab
Modbus addressing in Home Assistant starts at 0, but the document starts at 1.