Set clock over Bluetooth Proxy on LYWSD02 by Xiaomi (Bluetooth Temp, humidity, clock device)

There are several stand-alone projects that will adjust the clock on the LYWSD02
by Xiaomi. The device is recognised by HA but only as a set of sensors.
The clock drifts quite quickly and it would be good to sync the clock over Bluetooth via a proxy.
Example projects:

https://saso5.github.io/LYWSD02-clock-sync/

I have just Installed the ESPhome Solution for that, but you right having this from HA via BT Proxy in the house would be better

What is the ESPhome solution for this?

@rojexx the link is the post.

Had the same issue and quickly hacked together a HomeAssistant integration to do that - see GitHub - ashald/home-assistant-lywsd02: A customer component for HomeAssistant to configure LYWSD02. It adds a new service that can be invoked via any automation to set time on any given LYWSD02.

Thanks for this!
Is there a way to get this merged with the main code for the device?

I’ve see few HA integrations supporting it - did you mean a specific one?

Generally speaking, I doubt I will have time to contribute it to any other integrations is it’s good enough for me as it is, but you could reach out to those integration owners and point them to this thing and ask if they would be willing to take it in.

1 Like

@ashald is your integration/service designed to be able to set a LYWSD02 that’s only visible to HA via bluetooth proxies? When I call the service with one of my clock’s MACs, I get “not found” in the logs:

2024-05-19 15:42:30.001 ERROR (MainThread) [custom_components.lywsd02] Could not find '17:29:XX:XX:6C:BE'.

Edit: I’ll add that I’m running HA core in docker, with no BT/BLE capabilities exposed to the container. My (minimal) Bluetooth functionality operates only through hardwired Shelly wifi devices that act as bluetooth proxies.

exactly the same problem here.
Could not find ‘mac_here’.
it worked for 1 device, before i updated to 2024.10.1

Hi All,

Perhaps a stupid question but I am facing the same issue with the time of this device.
I tried the solution provided but so far no luck.
therefor a quick check.
am I doing this right it the following automation?

alias: "Set time bathroom Clock "
description: ""
triggers:
  - trigger: sun
    event: sunrise
    offset: 0
conditions: []
actions:
  - action: lywsd02.set_time
    data:
      mac: "XX:XX:XX:XX:XX:XX"
mode: single

thanks in advance!