[MATTER] Sync Time with Matter Devices (e.g. IKEA ALPSTUGA)

Hello everyone, :wave:t2:

Frustrated by not being able to sync time on my IKEA ALPSTUGA, I created a small custom component that syncs time across various Matter devices. With this component, you can now set up an automation to automatically sync the time whenever you plug in a Matter device like the ALPSTUGA.

You’ll find all the information on my GitHub repository :
:point_right:t2: Matter-Time-Sync

A big thank you to rtbmd on Reddit, who gave me a solid foundation for creating this custom component.

23 Likes

Thank you that is very helpful. Btw I was able to enter “ws://homeassistant:5580/ws” as the address of my Matter Server, this way I don’t need to use the ip address.

1 Like

Very useful, surprised Home Assistant/Matter integration doesn’t handle this natively. Thanks to you (and rtbmd) for your work throwing this together :slight_smile:

Very helpful, thanks! Just one question: I managed to set up the action.

But how do you set up the automation so it can update itself?

What entity triggers the trigger?

Thanks

Hello,
You could do something like this:

alias: "[TIME] Sync IKEA ALPSTUGA"
description: >-
  Synchronizes the time on the IKEA ALPSTUGA on Sundays at 03:15 AM and whenever
  the device becomes available after being unavailable.
triggers:
  - at: "03:15:00"
    trigger: time
    weekday:
      - sun
  - entity_id:
      - switch.alpstuga_air_quality_monitor
    from:
      - unavailable
    to: null
    trigger: state
actions:
  - delay:
      hours: 0
      minutes: 0
      seconds: 5
      milliseconds: 0
  - action: matter_time_sync.sync_time
    data:
      node_id: 7
      endpoint: 0
mode: restart

I gave this add-on a shot as it sounds really handy, but whenever I try to use it in an automation, I get this error:

And this pops up in the debug logs:

2026-01-16 23:03:41.577 INFO (MainThread) [custom_components.matter_time_sync] Starting sync for node 3 (ep 0)
2026-01-16 23:03:41.588 DEBUG (MainThread) [custom_components.matter_time_sync] Server Welcome: {'fabric_id': 2, 'compressed_fabric_id': 7760850010980266393, 'schema_version': 11, 'min_supported_schema_version': 9, 'sdk_version': '2025.7.0', 'wifi_credentials_set': False, 'thread_credentials_set': False, 'bluetooth_enabled': False}
2026-01-16 23:03:42.194 ERROR (MainThread) [custom_components.matter_time_sync] FAILED: Time sync error: Matter Server Error: {'message_id': '2', 'error_code': 0, 'details': 'InteractionModelError: ConstraintError (0x87)'}
2026-01-16 23:03:42.196 ERROR (MainThread) [homeassistant.helpers.script.websocket_api_script] websocket_api script: Error executing script. Unexpected error for call_service at pos 1: Matter Server Error: {'message_id': '2', 'error_code': 0, 'details': 'InteractionModelError: ConstraintError (0x87)'}
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 524, in _async_step
    await getattr(self, handler)()
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 1011, in _async_step_call_service
    response_data = await self._async_run_long_action(
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    ...<9 lines>...
    )
    ^
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 624, in _async_run_long_action
    return await long_task
           ^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2819, in async_call
    response_data = await coro
                    ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2862, in _execute_service
    return await target(service_call)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/matter_time_sync/__init__.py", line 58, in handle_sync_time
    await syncer.run_sync(node_id, endpoint)
  File "/config/custom_components/matter_time_sync/__init__.py", line 102, in run_sync
    await self.send_command(ws, node_id, endpoint, CLUSTER_ID_TIME_SYNC, CMD_ID_SET_DST_OFFSET, "SetDSTOffset", {"DSTOffset": [dst_obj]})
  File "/config/custom_components/matter_time_sync/__init__.py", line 124, in send_command
    if "error_code" in response: raise Exception(f"Matter Server Error: {response}")
                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Exception: Matter Server Error: {'message_id': '2', 'error_code': 0, 'details': 'InteractionModelError: ConstraintError (0x87)'}
2026-01-16 23:03:42.207 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [546786874432] Error handling message: Unknown error (unknown_error) decryption from 192.168.1.66 (Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:146.0) Gecko/20100101 Firefox/146.0)
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/decorators.py", line 28, in _handle_async_response
    await func(hass, connection, msg)
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 1050, in handle_execute_script
    script_result = await script_obj.async_run(
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^
        msg.get("variables"), context=context
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 1837, in async_run
    return await asyncio.shield(create_eager_task(run.async_run()))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 460, in async_run
    await self._async_step(log_exceptions=False)
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 526, in _async_step
    self._handle_exception(
    ~~~~~~~~~~~~~~~~~~~~~~^
        ex, continue_on_error, self._log_exceptions or log_exceptions
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 556, in _handle_exception
    raise exception
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 524, in _async_step
    await getattr(self, handler)()
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 1011, in _async_step_call_service
    response_data = await self._async_run_long_action(
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    ...<9 lines>...
    )
    ^
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 624, in _async_run_long_action
    return await long_task
           ^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2819, in async_call
    response_data = await coro
                    ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2862, in _execute_service
    return await target(service_call)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/matter_time_sync/__init__.py", line 58, in handle_sync_time
    await syncer.run_sync(node_id, endpoint)
  File "/config/custom_components/matter_time_sync/__init__.py", line 102, in run_sync
    await self.send_command(ws, node_id, endpoint, CLUSTER_ID_TIME_SYNC, CMD_ID_SET_DST_OFFSET, "SetDSTOffset", {"DSTOffset": [dst_obj]})
  File "/config/custom_components/matter_time_sync/__init__.py", line 124, in send_command
    if "error_code" in response: raise Exception(f"Matter Server Error: {response}")
                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Exception: Matter Server Error: {'message_id': '2', 'error_code': 0, 'details': 'InteractionModelError: ConstraintError (0x87)'}


And this appears in the Matter server logs:

2026-01-16 23:07:44.515 (MainThread) ERROR [matter_server.server] Error doing task: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/matter_server/server/client_handler.py", line 213, in _run_handler
    raise err
  File "/usr/local/lib/python3.12/site-packages/matter_server/server/client_handler.py", line 196, in _run_handler
    result = await result
             ^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/matter_server/server/device_controller.py", line 717, in send_device_command
    return await self._chip_device_controller.send_command(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/matter_server/server/sdk.py", line 308, in send_command
    return await self._chip_controller.SendCommand(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/chip/ChipDeviceCtrl.py", line 1552, in SendCommand
    return await future
           ^^^^^^^^^^^^
chip.interaction_model.InteractionModelError: InteractionModelError: ConstraintError (0x87)

Any clues on what’s up?

2 Likes

Could you also make a Blueprint automation for Home Assistant Blueprint Exchange forum?

Would be nice to have matching Blueprints that could maybe be more or less plug-and-play?

1 Like

Tracing the automation shows that it cannot connect to the HA server:

Perform action 'Matter Time Sync: Sync time'
Executed: 26 January 2026 at 13:43:55
Error: Cannot connect to host 10.0.0.10:5580 ssl:default [Connect call failed ('10.0.0.10', 5580)]
Result:

params:
  domain: matter_time_sync
  service: sync_time
  service_data:
    node_id: 11
    endpoint: 0
  target: {}
running_script: false

What’s missing in the directions is that you have to expose the TCP port 5580. To do this, go to Settings → Add-ons → Matter Server → Configuration → Network and add 5580 to expose the Matter Server WebSocket port.

After doing that, it worked perfectly for me.

Credit to BMOtheConsole on github for that fix.

Everything was already explained on my GitHub page… :cry:

3 Likes

Hi Loweack,
I recently did some minor changes and pushed it for you to check.

(Automatic matter server detection, device detection by reading the ids from matter server, config flow, automated shedduling, device creation etc. ) only ease of use-stuff. if you intrestes - use it :)))

Thank you for your great work with the time sync.
:slight_smile:

Thomas

4 Likes

Brilliant, just what I needed, thank you!

1 Like

Thanks to @Lexorius (with some additional tweaks), the new v2.0.1 is now out!
For more information :point_right:t2: GitHub - Loweack/Matter-Time-Sync: Synchronize time and timezone on a Matter device using the global integration settings.

4 Likes

Awesome! Thanks OP :smiley:

This is the most simple and satisfying integration, it saves so much time fiddling with the buttons on the ALPSTUGA only to have the time reset after powerloss.

I can confirm this integration works when using a Google Streamer 4K as a matter hub without any additional configuration

One small note however is that the configurable device name filter seems to be a little buggy as it doesnt allow me to empty the field after having set a filter previously. It just remembers the last value. (The filter also didnt seem to work if a value is entered). I del(ye)eted the integration and reinstalled it but this time without the device filter and the devices were instantly detected :slight_smile:

(the cherry on top would be if the discovered device buttons that are created mirror the device name to make it easier to differentiate, saves pushing the button and seeing which one updated the time. I only have 2 ALPSTUGA’s at the moment so its not a problem but can get tedious if you have one in every room (like i’m planning onhaving))

1 Like

Hello, :wave:t2:
The “ghost filter” issue in the filter field has been fixed in pre-release 2.1.1. This should become an official release this week. The new release also fixes various bugs and adds new welcome tweaks.

Works like a charm with my Dirigera and Alpstuga. Thank you so much! :pray: :heart:

1 Like

Seems release 2026.3.0 has broken the time sync for me, at least the sync all command.

At first I had an error that the migration had failed, so I deleted it, redownloaded it (via HACS), and it appears to be ok in the devices UI, but my spook integration is still showing:-

The automation “Sync Matter Time on Startup” (automation.sync_matter_time_on_startup ) has an unknown action: matter_time_sync.sync_all .

If I try to run the automation, it runs without any errors in the logs, but the automation trace says that the last step did not run (the sync all command).

This is my pretty simple automation:-

alias: Sync Matter Time on Startup
description: ""
triggers:
  - event: start
    trigger: homeassistant
actions:
  - delay: "00:01:00"
  - action: matter_time_sync.sync_all

works great, thanks a lot!

something similar also for me, autosync not working but per device manually pressing the button worked. HA up to date and also this component.

Awesome thank you!