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

Support for Generic iTag buttons #80

Open
jclds139 opened this issue Jan 12, 2024 · 1 comment
Open

Support for Generic iTag buttons #80

jclds139 opened this issue Jan 12, 2024 · 1 comment

Comments

@jclds139
Copy link

I'm trying to add support for these cheap BLE button tags but I'm struggling with what needs to be defined in a "protocol" vs a "device".
They're a basic presence device but with a couple of extra features once connected:

  1. Battery percentage is a readable characteristic (some of them allow it to be notified, too)
  2. There's an "alert" characteristic that makes the device beep depending on what's written to it.
  3. There's a button that can be subscribed to to get notifications when it is clicked.

(1) seems like a straightforward sensor, (2) I'm not quite sure, but I'd imagine this could be a "select" or "switch" domain device. (3) seems the weirdest because the state is always off when read directly, and it sends an event whenever it's pressed.
Any guidance or documentation I'm missing for these?

@devbis
Copy link
Owner

devbis commented Jan 13, 2024

Hi! Protocol is an abstraction for complex communication with a device. You may ignore protocol folder if your device doesn't need to implement something odd.

There are two ways of communicating - direct connection (high battery consumption) and advertisement decoding (doesn't require connection, which allows the battery to work longer)

  1. looks like a sensor, see other devices

  2. Looks like a 'button' entity

  3. A button should be exposed to HA as 'device_automation' domain. There is no examples in the current project, but you may use https://www.home-assistant.io/integrations/device_trigger.mqtt/ as a documentation for discovery implementation and button handling from my other project
    https://github.com/openlumi/lumimqtt/blob/main/lumimqtt/lumimqtt.py#L269-L308
    https://github.com/openlumi/lumimqtt/blob/main/lumimqtt/lumimqtt.py#L444-L468

If you have a connection, you may subscribe to a characteristic to receive data from it periodically, maybe clicks are also transmitted through this mechanism.

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

No branches or pull requests

2 participants