Skip to content

Add time synchronization feature to BSB-Lan integration#156600

Merged
joostlek merged 3 commits into
home-assistant:devfrom
liudger:add-timesync-feature
Jan 2, 2026
Merged

Add time synchronization feature to BSB-Lan integration#156600
joostlek merged 3 commits into
home-assistant:devfrom
liudger:add-timesync-feature

Conversation

@liudger
Copy link
Copy Markdown
Contributor

@liudger liudger commented Nov 14, 2025

Breaking change

Proposed change

This pull request adds a new sync_time service to the BSB-LAN integration in Home Assistant, allowing users to synchronize the time on their BSB-LAN device with Home Assistant. The implementation includes service registration, validation, error handling, user-facing descriptions, and comprehensive tests.

Key changes:

New Service Implementation:

  • Added the sync_time service, which updates the BSB-LAN device time to match Home Assistant, only performing the update if the times differ. This includes schema validation, device/config entry checks, and error handling for device communication issues. [1] [2] [3] [4] [5]

  • Registered an appropriate Material Design Icon for the new service in icons.json.

User Interface and Documentation:

  • Updated services.yaml and strings.json to document the new service, including its description, fields, and error messages for failed sync attempts. [1] [2] [3]

Testing:

  • Added extensive tests for the sync_time service, covering successful syncs, no-op when times match, error conditions (such as device or entry not found, or device communication failures), and service registration. Also added a device time fixture for test consistency. [1] [2] [3] [4] [5] [6]

These changes ensure that users can reliably keep their BSB-LAN device clocks in sync with Home Assistant, with clear feedback and robust error handling.

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New integration (thank you!)
  • New feature (which adds functionality to an existing integration)
  • Deprecation (breaking change to happen in the future)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

Checklist

  • I understand the code I am submitting and can explain how it works.
  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • I have followed the perfect PR recommendations
  • The code has been formatted using Ruff (ruff format homeassistant tests)
  • Tests have been added to verify that the new code works.
  • Any generated code has been carefully reviewed for correctness and compliance with project standards.

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • The manifest file has all fields filled out correctly.
    Updated and included derived files by running: python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt.
    Updated by running python3 -m script.gen_requirements_all.
  • For the updated dependencies - a link to the changelog, or at minimum a diff between library versions is added to the PR description.

To help with the load of incoming pull requests:

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds a time synchronization feature to the BSB-Lan integration, allowing Home Assistant to synchronize its time with the BSB-Lan device once per hour when enabled via a new configuration option.

Key Changes

  • Adds user-configurable time synchronization option (sync_time) in the options flow
  • Implements hourly time synchronization logic with graceful error handling
  • Includes comprehensive test coverage for the new feature

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
homeassistant/components/bsblan/__init__.py Implements time sync logic with async_setup_time_sync function and update listener for option changes
homeassistant/components/bsblan/const.py Adds new constants for sync time option, default value, and hourly sync interval
homeassistant/components/bsblan/config_flow.py Adds options flow handler with schema for time sync configuration
homeassistant/components/bsblan/strings.json Adds user-facing strings for the time sync option
tests/components/bsblan/test_init.py Adds comprehensive tests covering enabled/disabled states, time synchronization behavior, error handling, and periodic sync
tests/components/bsblan/test_config_flow.py Adds tests for the options flow configuration
tests/components/bsblan/fixtures/time.json Adds test fixture for device time data

Comment thread homeassistant/components/bsblan/strings.json Outdated
Copy link
Copy Markdown
Member

@joostlek joostlek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't it be better to have this as a:

  1. Button
  2. Service

Instead of something that runs on boot?

@home-assistant
Copy link
Copy Markdown
Contributor

Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍

Learn more about our pull request process.

@home-assistant home-assistant Bot marked this pull request as draft November 14, 2025 15:59
@liudger
Copy link
Copy Markdown
Contributor Author

liudger commented Nov 14, 2025

Wouldn't it be better to have this as a:

  1. Button
  2. Service

Instead of something that runs on boot?

it's an option
image

@liudger liudger force-pushed the add-timesync-feature branch 2 times, most recently from 737e324 to 487c56b Compare November 15, 2025 13:45
@liudger liudger marked this pull request as ready for review November 15, 2025 13:45
@home-assistant home-assistant Bot requested a review from joostlek November 15, 2025 13:45
@liudger liudger marked this pull request as draft November 15, 2025 14:11
@liudger liudger force-pushed the add-timesync-feature branch from c0ef6ae to d423ce0 Compare November 15, 2025 14:21
@liudger liudger marked this pull request as ready for review November 15, 2025 14:55
Comment thread homeassistant/components/bsblan/services.py Outdated
@home-assistant home-assistant Bot marked this pull request as draft December 1, 2025 16:43
@liudger liudger force-pushed the add-timesync-feature branch from d423ce0 to 5e61af4 Compare December 2, 2025 09:06
@liudger liudger marked this pull request as ready for review December 2, 2025 12:49
@home-assistant home-assistant Bot requested a review from joostlek December 2, 2025 12:49
@liudger liudger marked this pull request as draft December 2, 2025 12:50
@liudger liudger force-pushed the add-timesync-feature branch from 3826d77 to 7aad879 Compare December 9, 2025 15:53
@liudger liudger force-pushed the add-timesync-feature branch 4 times, most recently from 67b1744 to 713f635 Compare January 1, 2026 22:02
@liudger liudger force-pushed the add-timesync-feature branch from 713f635 to 78015a1 Compare January 1, 2026 22:05
@liudger liudger marked this pull request as ready for review January 1, 2026 22:07
@joostlek joostlek merged commit 9539a61 into home-assistant:dev Jan 2, 2026
36 checks passed
@liudger liudger deleted the add-timesync-feature branch January 2, 2026 14:58
@github-actions github-actions Bot locked and limited conversation to collaborators Jan 3, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants