ashald / home-assistant-lywsd02 Goto Github PK
View Code? Open in Web Editor NEWA customer component for HomeAssistant to configure LYWSD02
License: The Unlicense
A customer component for HomeAssistant to configure LYWSD02
License: The Unlicense
Hi!
Thanks for this project which could finally solve my lagging e-ink clocks around the house.
Unfortunately, I don't seem to get it to work as it runs into timeout all the time. I'm using four BLE proxies, one of which very close to the clock in question.
Here's the log of the ESP32 connecting to the watch:
[12:55:58][I][bluetooth_proxy:282]: [0] [XX:XX:XX:XX:XX:XX] Connecting v3 without cache
[12:55:58][D][esp32_ble_tracker:215]: Pausing scan to make connection...
[12:55:58][I][esp32_ble_client:067]: [0] [XX:XX:XX:XX:XX:XX] 0x00 Attempting BLE connection
[12:56:07][D][esp32_ble_client:110]: [0] [XX:XX:XX:XX:XX:XX] ESP_GATTC_CONNECT_EVT
[12:56:07][D][esp32_ble_client:110]: [0] [XX:XX:XX:XX:XX:XX] ESP_GATTC_OPEN_EVT
[12:56:07][D][esp32_ble_tracker:266]: Starting scan...
[12:56:08][I][esp32_ble_client:084]: [0] [XX:XX:XX:XX:XX:XX] Disconnecting.
[12:56:08][D][esp-idf:000]: E (57775) BT_GATT: GATTC_ConfigureMTU GATT_BUSY conn_id = 3
[12:56:08][D][esp32_ble_client:110]: [0] [XX:XX:XX:XX:XX:XX] ESP_GATTC_SEARCH_CMPL_EVT
[12:56:08][I][esp32_ble_client:227]: [0] [XX:XX:XX:XX:XX:XX] Connected
[12:56:08][D][esp32_ble_client:110]: [0] [XX:XX:XX:XX:XX:XX] ESP_GATTC_CLOSE_EVT
[12:56:08][D][esp32_ble_client:172]: [0] [XX:XX:XX:XX:XX:XX] ESP_GATTC_DISCONNECT_EVT, reason 22
The time on the clock is not set and the HA log file shows a time out error:
File "/config/custom_components/lywsd02/init.py", line 78, in set_time
async with BleakClient(ble_device) as client:
File "/usr/local/lib/python3.12/site-packages/bleak/init.py", line 565, in aenter
await self.connect()
File "/usr/local/lib/python3.12/site-packages/habluetooth/wrappers.py", line 300, in connect
connected = await super().connect(**kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/bleak/init.py", line 605, in connect
return await self._backend.connect(**kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/bleak_esphome/backend/client.py", line 79, in _async_wrap_bluetooth_operation
raise asyncio.TimeoutError(str(err)) from err
TimeoutError: Timeout waiting for connect response while connecting to XX:XX:XX:XX:XX:XX after 10.0s, disconnect timed out: True, after 20.0s
Setting the clock via the webapp (https://saso5.github.io/LYWSD02-clock-sync/) works just fine.
Any help is greatly appreciated :).
hello,
First of all, thanks for the hard work.
Can you give more detail on how to configure the service.yaml file.
timestamp:
description: Time to Set
example: 1702200346
How is time coded in example?
or can you make an example for the service.yaml to get the time that home assistant have in that moment?
best regards.
Hello, thank you very much for this integration. It's very useful because I travel a lot by sea. I often change time zones, but not always according to the actual location; sometimes I do it earlier or later depending on how long we'll be at sea.
That's why I set the time zone on my phone, and I would like the watches to immediately synchronize with the time zone set on my phone. It works great, but the watches act up when we're in places like Sri Lanka, where it's GMT+05:30.
Unfortunately, your service doesn't accept tz_offset: 5.5.
Generally, my automation looks like this:
alias: Synchronize Xiaomi Clock
description: ""
trigger:
- platform: state
entity_id:
- sensor.z_flip_5_sm_f731b_current_time_zone
condition: []
action:
- service: lywsd02.set_time
data:
mac: 77:2E:4592:44:34
tz_offset: >-
{{ ((state_attr('sensor.z_flip_5_sm_f731b_current_time_zone',
'utc_offset') | float / 3600) | int // 1000 -1) | string }}
mode: single
It works only with full hour offset, but even manual invocation doesn't work anymore:
service: lywsd02.set_time
data:
mac: 77:2E:4592:44:34
tz_offset: 5.5
Do you think you could somehow add the ability to handle tz_offset in the format X.X?
Thanks,
Waldek B.
Hello !
My LYWSD02MMC doesn't sync (maybe because it's a "MMC" ?).
HACS is installed and you repo too.
My automation :
trigger:
- platform: time
at: "04:00:00"
condition: []
action:
- service: lywsd02.set_time
metadata: {}
data:
mac: E7:2E:00:E2:71:01
mode: single
I have no error when it runs but nothings appends, the clock isn't synced (1 minute is still missing).
HA runs on rpi 3 and the pi clock is OK.
HAOS is up to date.
Just a question:
Is it possible to use more than one lywsd02 by adding multiple mac addresses?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.