Skip to content

matkovsky/ha_xiaomi_clock_sync

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Xiaomi Clock Time Sync

This Home Assistant custom component allows you to synchronize the time on one or more Xiaomi LYWSD02 Bluetooth clocks directly from Home Assistant.

Features

  • Sync the time on multiple Xiaomi LYWSD02 clocks with a single service call.
  • Uses Bluetooth (via the bleak library) to communicate with devices.
  • Simple service for manual or automated time sync.

Installation

  1. Copy the files Place the xiaomi_clock_sync folder in your Home Assistant custom_components directory.

  2. Enable in configuration.yaml file add the following line to configuration.yaml:

    xiaomi_clock_sync:
  3. Restart Home Assistant After copying the files, restart Home Assistant to load the new component.

Note: You do not need to install the bleak library manually. Home Assistant will automatically install all required dependencies as specified in manifest.json.

Configuration

add the following line to configuration.yaml:

xiaomi_clock_sync:

Usage

Service: xiaomi_clock_sync.sync_time

Sync the time on one or more Xiaomi LYWSD02 clocks.

Service Data

Field Type Required Description
macs list Yes List of MAC addresses of the clocks to sync

Example:

service: xiaomi_clock_sync.sync_time
data:
  macs:
    - "A4:C1:38:XX:XX:XX"
    - "3F:5B:7D:XX:XX:XX"

You can call this service from Developer Tools, automations, or scripts.

Troubleshooting

  • Ensure your Home Assistant host has a working Bluetooth adapter.
  • The clocks must be powered on and within Bluetooth range.
  • Connection slot errors: If you see BleakOutOfConnectionSlotsError, restart Home Assistant to release stuck BLE connections. BLE adapters typically support only 3-7 simultaneous connections.
  • Wrong time (off by 1 hour): This was caused by incorrect DST detection and has been fixed. The component now correctly detects whether Daylight Saving Time is currently active using time.localtime().tm_isdst.

Credits

License

MIT License

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Python 100.0%