Knx Datetime update Vimar

Hello,
After some tinkering, I managed to send datetime updates to the Vimar By-me bus via KNX. While searching, I found a few unresolved posts, so I’m sharing a package here in case someone else needs it.

sensor:
  # Base sensor: ISO date/time
  - platform: time_date
    display_options:
      - "date_time_iso"

  - platform: template
    sensors:
      knx_datetime:
        value_template: >
          {% set now = states('sensor.date_time_iso') | as_datetime %}
          {{ "%d,%d,%d,%d,%d,%d,0,0" | format(
             now.year - 1900,
             now.month,
             now.day,
             ((now.isoweekday() % 7) + 1)*32 + now.hour,
             now.minute,
             now.second
          ) }}
        icon_template: "mdi:calendar-clock"

script:
  send_knx_datetime:
    alias: Update Knx DateTime
    sequence:
      - service: knx.send
        data:
          address: "0/0/65" # Replace with your clock address
          payload: >
            {{ states('sensor.knx_datetime').split(',') | map('trim') | map('int') | list }}

The package should be pasted into a file at packages/knx/datetime.yaml, and in the main configuration, this should be added in case you are not using packages:

homeassistant:
  packages: !include_dir_named packages

date format is DPT 19.001

After installing the package, it is enough to create an automation that calls the send_knx_datetime service every X hours, and the time will be updated automatically. My Vimar KNX controller used to run a few minutes ahead after a few weeks from the last adjustment.

Hi :wave:!
Have you had a look at https://www.home-assistant.io/integrations/knx/#exposing-entity-states-entity-attributes-or-time-to-knx-bus?
The thing you posted should be possible by simply using

knx:
  expose:
    - type: datetime
      address: "0/0/1"

Sure, but I had no luck with that configuration, probably the Vimar knx implementation is not so standard , I had to log the packets sent from the Vimar display to the bus to intercept the payload and recreate it on homeassistant.

Interesting. Apart from “day_of_week” being set to 0, it looks like the integrations implementation sends the same as yours… but the payload is 2bytes (0,0) longer.
https://github.com/XKNX/xknx/blob/784ea40f977755e7286a70cbfd7ec5353dafd1c1/xknx/dpt/dpt_19.py

Maybe you should also file a bug at Vimars customer support.

From what I have logged, the last parameter can be either 0x00 or 0x80. On the Vimar panel, it refers to a master and a slave. Additionally, the second-to-last value can be sent as either 0x00 or 0x40, but I haven’t figured out what this corresponds to. I noticed, however, that it works fine when always sending 0x00.

See the link above Line 185-195 or the Knx datapoint specs https://support.knx.org/hc/en-us/articles/15392604906514-Interworking-Datapoint-types

Oh, just fyi, you can get current time in a template. https://www.home-assistant.io/blog/2017/10/15/templating-date-time/
So you could omit the first helper entity. And if you use this in the scripts knx.send payload, you may even omit the other template entity.
Using an automation instead of script - with time pattern trigger - would make a nice start for a blueprint for other Vimar users :wink: