Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

aioshelly BLE scan parameters cause data loss with Shelly BLU H&T (Possibly others too) #126988

Open
SharpEdgeMarshall opened this issue Sep 28, 2024 · 1 comment

Comments

@SharpEdgeMarshall
Copy link

SharpEdgeMarshall commented Sep 28, 2024

The problem

Looks like a lot of people using Shelly devices as BLE gateway are experiencing problems of data not being collected consistently (it seems that this affects also native Shelly users).

Possibly related issues: #119878, #123841

After a lot of investigation, I convinced myself that there might be a desynchronization between the scan window and the instant the sensor sends packets. I sniffed the packets sent by the sensor (in my case Shelly BLU H&T) directly with my phone and discovered that:

  • If I press the button, it sends about 40 messages with an interval of about 20-30 ms.

  • If I wait for the minute to expire, 6 messages are sent with an interval of 150 ms.

I open the script that HA puts on the Shelly for scanning and check the scan parameters, probably are the default ones (that would explain why also Shelly native users are experiencing issues):

  • Interval: 320 ms (pause between each window)

  • Window: 30 ms (how much time the antenna listens for messages)

With these parameters is reasonable that the scan could miss all 6 messages for several minutes (even hours).
After several trials and errors I set the interval to 200 ms and the window to 50 ms.

Now data is collected consistently:
Screenshot 2024-09-28 at 11 19 04

What version of Home Assistant Core has the issue?

ALL probably

What was the last working version of Home Assistant Core?

N/A

What type of installation are you running?

Home Assistant Container

Integration causing the issue

Shelly

Link to integration documentation on our website

No response

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

@home-assistant
Copy link

Hey there @balloob, @bieniu, @thecode, @chemelli74, @bdraco, mind taking a look at this issue as it has been labeled with an integration (shelly) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of shelly can trigger bot actions by commenting:

  • @home-assistant close Closes the issue.
  • @home-assistant rename Awesome new title Renames the issue.
  • @home-assistant reopen Reopen the issue.
  • @home-assistant unassign shelly Removes the current integration label and assignees on the issue, add the integration domain after the command.
  • @home-assistant add-label needs-more-information Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue.
  • @home-assistant remove-label needs-more-information Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.

(message by CodeOwnersMention)


shelly documentation
shelly source
(message by IssueLinks)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants