Bluetooth-Devices / bthome-ble

Parser for BTHome BLE devices
https://bthome.io/
MIT License
67 stars 12 forks source link

How do enter a custom variable in BTHome v2.0? #78

Closed pvvx closed 10 months ago

pvvx commented 1 year ago
  1. There is a receiving device that has a current table of variable sizes to parse, but with an additional identifier assigned. The additional assigned identifier is not written in the current official (proprietary?) format, but is needed only for this device and uses a previously unused number.
  2. New identifiers have been added to the general format of BTHome v2.0. The transmitter has been updated to transmit new variables with new identifiers.
  3. The receiving device does not have an OTA function or there are other difficulties in reprogramming it for users.

How to resolve such a situation? Or how to assign a range with user (and debug) IDs?

Ernst79 commented 1 year ago

That isn't possible, because: It is using an unused object_id of BTHome format. These object_ids can be assigned in future versions of BTHome to official sensor types, so, it's the risk of using unassigned object_ids. The user should instead request a new object_id to be assigned to a sensor type he/she wants. Using unofficial object_ids with a device that can't be updated seems to be something one should not do.

However, I like the idea of a debug object_id, or a custom object_id. We can e.g. say that we assign 0xFF to custom messages, followed by a length byte and than the data. However, it will be hard/impossible to translate this to a sensor in e.g. Home Assistant, as HA would have to guess what kind of data it is (int, float, text).

We might also define multiple custom sensors, like FF for integers, FE for text, etc.

pvvx commented 1 year ago

The user should instead request a new object_id to be assigned to a sensor type he/she wants.

As practice shows, it takes more than 3 months from the request to the input of a new identifier.

The BT Home format is highly specialized and is only applicable in `HA' with BTHome integration? (This complicates support in other integrations. For example, in ESPHome and many others, because it requires constant monitoring of new IDs and updates of all software.)

Ernst79 commented 1 year ago

It can be faster if people create a PR themselves. My time is limited, and I’m just doing this as a hobby, including maintaining other repo’s like ble monitor. It is what it is.

BTHome can be used by any other home automation software, but my focus will be on HA. But it’s up to others if they want to implement BTHome, all info is on bthome.io.

I think your concern is on the receiving part, regarding the needed updates. But if e.g your ESPhome is able to receive the objects you want, why would you need to update it? If the reviver receives a new object that is not supported, it will just not process it, not a big issue, I think.

Ernst79 commented 10 months ago

Custom sensors have been added in bthome 3.2.0 (raw sensor) and 3.1.0 (text sensor), so it is possible to send custom data in text (UTF-8) and raw (hex) format now. Raw sensor will be included in Home Assistant 2023.11, text sensor in already included in 2023.10.