This Home Assistant custom component allows you to synchronize the time on one or more Xiaomi LYWSD02 Bluetooth clocks directly from Home Assistant.
- Sync the time on multiple Xiaomi LYWSD02 clocks with a single service call.
- Uses Bluetooth (via the
bleaklibrary) to communicate with devices. - Simple service for manual or automated time sync.
-
Copy the files Place the
xiaomi_clock_syncfolder in your Home Assistantcustom_componentsdirectory. -
Enable in configuration.yaml file add the following line to
configuration.yaml:xiaomi_clock_sync: -
Restart Home Assistant After copying the files, restart Home Assistant to load the new component.
Note: You do not need to install the
bleaklibrary manually. Home Assistant will automatically install all required dependencies as specified inmanifest.json.
add the following line to configuration.yaml:
xiaomi_clock_sync:Sync the time on one or more Xiaomi LYWSD02 clocks.
| 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.
- 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.
- Based on h4/lywsd02
- Uses the bleak Bluetooth library
MIT License