Closed smeersma closed 1 year ago
Hi @Ernst79, I'm interested in implementing this. Easiest way for me to wrap my head around how this work is if someone can point me at existing integrations that implements something similar?
I noticed the inkbird BLE integration and it's subsequent library which seems like a good starting point?
If there's any documentation on how to analyze and identify BLE traffic I'd appreciate an link 😄
Just as an reference, here's more debug data
04/10/2023 09:54:44
2023-04-10 09:54:44.325 DEBUG (MainThread) [homeassistant.components.bluetooth.manager] ac-1-etasje (c0:49:ef:f0:1c:88) [connectable]: DA:62:01:72:CB:1A AdvertisementData(manufacturer_data={1972: b'\x14\x00\x00\x00\x00\x00\x00\x00\x00\xef\xbb\xaf\xa9\xd1\xa7;\x04'}, service_uuids=['669a9001-0008-968f-e311-6050405558b3'], tx_power=-127, rssi=-94) match: set()
04/10/2023 09:54:44
2023-04-10 09:54:44.326 DEBUG (MainThread) [homeassistant.components.bluetooth.manager] ac-1-etasje (c0:49:ef:f0:1c:88) [connectable]: DA:62:01:72:CB:1A AdvertisementData(manufacturer_data={1972: b'\x02\x02- \x00\x00'}, service_uuids=['669a9001-0008-968f-e311-6050405558b3'], tx_power=-127, rssi=-95) match: set()
04/10/2023 09:54:45
2023-04-10 09:54:45.076 DEBUG (MainThread) [homeassistant.components.bluetooth.manager] ac-1-etasje (c0:49:ef:f0:1c:88) [connectable]: DA:62:01:72:CB:1A AdvertisementData(manufacturer_data={1972: b'\x14\x00\x00\x00\x00\x00\x00\x00\x00\xef\xbb\xaf\xa9\xd1\xa7;\x04'}, service_uuids=['669a9001-0008-968f-e311-6050405558b3'], tx_power=-127, rssi=-95) match: set()
04/10/2023 09:54:45
2023-04-10 09:54:45.486 DEBUG (MainThread) [homeassistant.components.bluetooth.manager] ac-1-etasje (c0:49:ef:f0:1c:88) [connectable]: DA:62:01:72:CB:1A AdvertisementData(manufacturer_data={1972: b'\x02\x02- \x00\x00'}, service_uuids=['669a9001-0008-968f-e311-6050405558b3'], tx_power=-127, rssi=-94) match: set()
04/10/2023 09:54:54
2023-04-10 09:54:54.600 DEBUG (MainThread) [homeassistant.components.bluetooth.manager] ac-1-etasje (c0:49:ef:f0:1c:88) [connectable]: DA:62:01:72:CB:1A AdvertisementData(manufacturer_data={1972: b'\x02\x02m \x00\x00'}, service_uuids=['669a9001-0008-968f-e311-6050405558b3'], tx_power=-127, rssi=-96) match: set()
04/10/2023 09:55:04
2023-04-10 09:55:04.737 DEBUG (MainThread) [homeassistant.components.bluetooth.manager] ac-1-etasje (c0:49:ef:f0:1c:88) [connectable]: DA:62:01:72:CB:1A AdvertisementData(manufacturer_data={1972: b'\x14\xb4\x00\x00\x00\x00\x00\x00\x00\xef\xbb\xaf\xa9\xd1\xa7;\x04'}, service_uuids=['669a9001-0008-968f-e311-6050405558b3'], tx_power=-127, rssi=-95) match: set()
04/10/2023 09:55:11
2023-04-10 09:55:11.803 DEBUG (MainThread) [homeassistant.components.bluetooth.manager] ac-1-etasje (c0:49:ef:f0:1c:88) [connectable]: DA:62:01:72:CB:1A AdvertisementData(manufacturer_data={1972: b'\x02\x02- \x00\x00'}, service_uuids=['669a9001-0008-968f-e311-6050405558b3'], tx_power=-127, rssi=-94) match: set()
04/10/2023 09:57:17
2023-04-10 09:57:17.039 DEBUG (MainThread) [homeassistant.components.bluetooth.manager] ac-1-etasje (c0:49:ef:f0:1c:88) [connectable]: DA:62:01:72:CB:1A AdvertisementData(manufacturer_data={1972: b'\x13\xc8\x00\x00\x00\x00\x00\x00\x00\xef\xbb\xaf\xa9\xd1\xa7;\x04'}, service_uuids=['669a9001-0008-968f-e311-6050405558b3'], tx_power=-127, rssi=-93) match: set()
04/10/2023 09:57:17
2023-04-10 09:57:17.756 DEBUG (MainThread) [homeassistant.components.bluetooth.manager] ac-1-etasje (c0:49:ef:f0:1c:88) [connectable]: DA:62:01:72:CB:1A AdvertisementData(manufacturer_data={1972: b'\x02\x02- \x00\x00'}, service_uuids=['669a9001-0008-968f-e311-6050405558b3'], tx_power=-127, rssi=-96) match: set()
04/10/2023 09:58:04
2023-04-10 09:58:04.863 DEBUG (MainThread) [homeassistant.components.bluetooth.manager] ac-1-etasje (c0:49:ef:f0:1c:88) [connectable]: DA:62:01:72:CB:1A AdvertisementData(manufacturer_data={1972: b'\x13\xc8\x00\x00\x00\x00\x00\x00\x00\xef\xbb\xaf\xa9\xd1\xa7;\x04'}, service_uuids=['669a9001-0008-968f-e311-6050405558b3'], tx_power=-127, rssi=-96) match: set()
04/10/2023 09:58:05
2023-04-10 09:58:05.475 DEBUG (MainThread) [homeassistant.components.bluetooth.manager] ac-1-etasje (c0:49:ef:f0:1c:88) [connectable]: DA:62:01:72:CB:1A AdvertisementData(manufacturer_data={1972: b'\x02\x02- \x00\x00'}, service_uuids=['669a9001-0008-968f-e311-6050405558b3'], tx_power=-127, rssi=-95) match: set()
04/10/2023 09:58:41
2023-04-10 09:58:41.007 DEBUG (MainThread) [homeassistant.components.bluetooth.manager] ac-1-etasje (c0:49:ef:f0:1c:88) [connectable]: DA:62:01:72:CB:1A AdvertisementData(manufacturer_data={1972: b'\x13\xc8\x00\x00\x00\x00\x00\x00\x00\xef\xbb\xaf\xa9\xd1\xa7;\x04'}, service_uuids=['669a9001-0008-968f-e311-6050405558b3'], tx_power=-127, rssi=-96) match: set()
04/10/2023 09:58:43
2023-04-10 09:58:43.468 DEBUG (MainThread) [homeassistant.components.bluetooth.manager] ac-1-etasje (c0:49:ef:f0:1c:88) [connectable]: DA:62:01:72:CB:1A AdvertisementData(manufacturer_data={1972: b'\x02\x02- \x00\x00'}, service_uuids=['669a9001-0008-968f-e311-6050405558b3'], tx_power=-127, rssi=-93) match: set()
04/10/2023 10:00:54
2023-04-10 10:00:54.128 DEBUG (MainThread) [homeassistant.components.bluetooth.manager] ac-1-etasje (c0:49:ef:f0:1c:88) [connectable]: DA:62:01:72:CB:1A AdvertisementData(manufacturer_data={1972: b'\x13\xc8\x00\x00\x00\x00\x00\x00\x00\xef\xbb\xaf\xa9\xd1\xa7;\x04'}, service_uuids=['669a9001-0008-968f-e311-6050405558b3'], tx_power=-127, rssi=-96) match: set()
04/10/2023 10:00:54
2023-04-10 10:00:54.647 DEBUG (MainThread) [homeassistant.components.bluetooth.manager] ac-1-etasje (c0:49:ef:f0:1c:88) [connectable]: DA:62:01:72:CB:1A AdvertisementData(manufacturer_data={1972: b'\x02\x02- \x00\x00'}, service_uuids=['669a9001-0008-968f-e311-6050405558b3'], tx_power=-127, rssi=-96) match: set()
04/10/2023 10:01:25
2023-04-10 10:01:25.261 DEBUG (MainThread) [homeassistant.components.bluetooth.manager] ac-1-etasje (c0:49:ef:f0:1c:88) [connectable]: DA:62:01:72:CB:1A AdvertisementData(manufacturer_data={1972: b'\x02\x02m \x00\x00'}, service_uuids=['669a9001-0008-968f-e311-6050405558b3'], tx_power=-127, rssi=-94) match: set()
04/10/2023 10:01:27
2023-04-10 10:01:27.819 DEBUG (MainThread) [homeassistant.components.bluetooth.manager] ac-1-etasje (c0:49:ef:f0:1c:88) [connectable]: DA:62:01:72:CB:1A AdvertisementData(manufacturer_data={1972: b'\x13\xa6\x00\x00\x00\x00\x00\x00\x00\xef\xbb\xaf\xa9\xd1\xa7;\x04'}, service_uuids=['669a9001-0008-968f-e311-6050405558b3'], tx_power=-127, rssi=-91) match: set()
04/10/2023 10:01:28
2023-04-10 10:01:28.229 DEBUG (MainThread) [homeassistant.components.bluetooth.manager] ac-1-etasje (c0:49:ef:f0:1c:88) [connectable]: DA:62:01:72:CB:1A AdvertisementData(manufacturer_data={1972: b'\x02\x02m \x00\x00'}, service_uuids=['669a9001-0008-968f-e311-6050405558b3'], tx_power=-127, rssi=-93) match: set()
04/10/2023 10:01:28
2023-04-10 10:01:28.640 DEBUG (MainThread) [homeassistant.components.bluetooth.manager] ac-1-etasje (c0:49:ef:f0:1c:88) [connectable]: DA:62:01:72:CB:1A AdvertisementData(manufacturer_data={1972: b'\x13\x9e\x00\x00\x00\x00\x00\x00\x00\xef\xbb\xaf\xa9\xd1\xa7;\x04'}, service_uuids=['669a9001-0008-968f-e311-6050405558b3'], tx_power=-127, rssi=-93) match: set()
04/10/2023 10:01:29
2023-04-10 10:01:29.662 DEBUG (MainThread) [homeassistant.components.bluetooth.manager] ac-1-etasje (c0:49:ef:f0:1c:88) [connectable]: DA:62:01:72:CB:1A AdvertisementData(manufacturer_data={1972: b'\x02\x02m \x00\x00'}, service_uuids=['669a9001-0008-968f-e311-6050405558b3'], tx_power=-127, rssi=-91) match: set()
04/10/2023 10:01:30
2023-04-10 10:01:30.071 DEBUG (MainThread) [homeassistant.components.bluetooth.manager] ac-1-etasje (c0:49:ef:f0:1c:88) [connectable]: DA:62:01:72:CB:1A AdvertisementData(manufacturer_data={1972: b'\x13\x90\x00\x00\x00\x00\x00\x00\x00\xef\xbb\xaf\xa9\xd1\xa7;\x04'}, service_uuids=['669a9001-0008-968f-e311-6050405558b3'], tx_power=-127, rssi=-95) match: set()
04/10/2023 10:01:30
2023-04-10 10:01:30.378 DEBUG (MainThread) [homeassistant.components.bluetooth.manager] ac-1-etasje (c0:49:ef:f0:1c:88) [connectable]: DA:62:01:72:CB:1A AdvertisementData(manufacturer_data={1972: b'\x13\x8e\x00\x00\x00\x00\x00\x00\x00\xef\xbb\xaf\xa9\xd1\xa7;\x04'}, service_uuids=['669a9001-0008-968f-e311-6050405558b3'], tx_power=-127, rssi=-95) match: set()
04/10/2023 10:01:30
2023-04-10 10:01:30.890 DEBUG (MainThread) [homeassistant.components.bluetooth.manager] ac-1-etasje (c0:49:ef:f0:1c:88) [connectable]: DA:62:01:72:CB:1A AdvertisementData(manufacturer_data={1972: b'\x02\x02m \x00\x00'}, service_uuids=['669a9001-0008-968f-e311-6050405558b3'], tx_power=-127, rssi=-93) match: set()
04/10/2023 10:01:32
2023-04-10 10:01:32.632 DEBUG (MainThread) [homeassistant.components.bluetooth.manager] ac-1-etasje (c0:49:ef:f0:1c:88) [connectable]: DA:62:01:72:CB:1A AdvertisementData(manufacturer_data={1972: b'\x13x\x00\x00\x00\x00\x00\x00\x00\xef\xbb\xaf\xa9\xd1\xa7;\x04'}, service_uuids=['669a9001-0008-968f-e311-6050405558b3'], tx_power=-127, rssi=-92) match: set()
04/10/2023 10:01:32
2023-04-10 10:01:32.836 DEBUG (MainThread) [homeassistant.components.bluetooth.manager] ac-1-etasje (c0:49:ef:f0:1c:88) [connectable]: DA:62:01:72:CB:1A AdvertisementData(manufacturer_data={1972: b'\x13v\x00\x00\x00\x00\x00\x00\x00\xef\xbb\xaf\xa9\xd1\xa7;\x04'}, service_uuids=['669a9001-0008-968f-e311-6050405558b3'], tx_power=-127, rssi=-92) match: set()
04/10/2023 10:01:37
2023-04-10 10:01:37.137 DEBUG (MainThread) [homeassistant.components.bluetooth.manager] ac-1-etasje (c0:49:ef:f0:1c:88) [connectable]: DA:62:01:72:CB:1A AdvertisementData(manufacturer_data={1972: b'\x02\x02m \x00\x00'}, service_uuids=['669a9001-0008-968f-e311-6050405558b3'], tx_power=-127, rssi=-94) match: set()
04/10/2023 10:01:37
2023-04-10 10:01:37.854 DEBUG (MainThread) [homeassistant.components.bluetooth.manager] ac-1-etasje (c0:49:ef:f0:1c:88) [connectable]: DA:62:01:72:CB:1A AdvertisementData(manufacturer_data={1972: b'\x13D\x00\x00\x00\x00\x00\x00\x00\xef\xbb\xaf\xa9\xd1\xa7;\x04'}, service_uuids=['669a9001-0008-968f-e311-6050405558b3'], tx_power=-127, rssi=-93) match: set()
04/10/2023 10:01:38
2023-04-10 10:01:38.365 DEBUG (MainThread) [homeassistant.components.bluetooth.manager] ac-1-etasje (c0:49:ef:f0:1c:88) [connectable]: DA:62:01:72:CB:1A AdvertisementData(manufacturer_data={1972: b'\x02\x02m \x00\x00'}, service_uuids=['669a9001-0008-968f-e311-6050405558b3'], tx_power=-127, rssi=-93) match: set()
04/10/2023 10:01:47
2023-04-10 10:01:47.480 DEBUG (MainThread) [homeassistant.components.bluetooth.manager] ac-1-etasje (c0:49:ef:f0:1c:88) [connectable]: DA:62:01:72:CB:1A AdvertisementData(manufacturer_data={1972: b'\x13\x00\x00\x00\x00\x00\x00\x00\x00\xef\xbb\xaf\xa9\xd1\xa7;\x04'}, service_uuids=['669a9001-0008-968f-e311-6050405558b3'], tx_power=-127, rssi=-94) match: set()
04/10/2023 10:01:47
2023-04-10 10:01:47.789 DEBUG (MainThread) [homeassistant.components.bluetooth.manager] ac-1-etasje (c0:49:ef:f0:1c:88) [connectable]: DA:62:01:72:CB:1A AdvertisementData(manufacturer_data={1972: b'\x02\x02m \x00\x00'}, service_uuids=['669a9001-0008-968f-e311-6050405558b3'], tx_power=-127, rssi=-96) match: set()
04/10/2023 10:01:49
2023-04-10 10:01:49.527 DEBUG (MainThread) [homeassistant.components.bluetooth.manager] ac-1-etasje (c0:49:ef:f0:1c:88) [connectable]: DA:62:01:72:CB:1A AdvertisementData(manufacturer_data={1972: b'\x02\x02- \x00\x00'}, service_uuids=['669a9001-0008-968f-e311-6050405558b3'], tx_power=-127, rssi=-97) match: set()
Hi @jkaberg. First, you have to make a decision, do you want to implement it in BLE monitor, or as an official HA integration?
If you want to implement it in BLE monitor, you will first have to add it to the ble_parser folder, where the data is being translated from bytes to readable data. A standalone version of bleparser can be found here https://github.com/Ernst79/bleparser You can use that for testing/development. You can get the data with one of the methods I described here https://custom-components.github.io/ble_monitor/sensor_request
I can give you some hints how I would normally do things.
If you look at this data, it is only part of the raw data. Also with the method above, you will get part of the data.
0201061107B3585540506011E38F96080001909A6609FFB40701022D20000014FFB4071400000000000000006722D81075F42A04
To get the full data, you can do two things, fix it manually, or add a line of code in the ble_parser/init.py file. Something like
_LOGGER.error("data received %s", data.hex())
If you want to fix it manually, you will have to add two part to the message, the header and the RSSI value. The header contains data length and the MAC address in reversed order. You will need to change the 3rd byte 40
, this is the total length (64 bytes (after converting hex to decimals). You will also need to change the 14th byte 34
, this is the length of the part that follows (52 bytes).
The RSSI
is added at the end, one byte, e.g. CC
= -52
In the example in the OP, you will get
043e4002010201da060f38c1a434 0201061107B3585540506011E38F96080001909A6609FFB40701022D20000014FFB4071400000000000000006722D81075F42A04 CC
you can split it up in
020106
= length type = 2, Flags (we don't use this part)
1107B3585540506011E38F96080001909A66
= 11 = length (17 bytes), 07 = 128 bit UUID (https://www.bluetooth.com/specifications/assigned-numbers/)
09FFB40701022D200000
= 9 = length (9 bytes), FF = manufacturer specific data, B407 = company id 0x07B4. Use this in __init__.py
to filter your data and forward it to your new brand specific parser. 01022D200000
is the actual data
14FFB4071400000000000000006722D81075F42A04
14 = length (20 bytes), FF = manufacturer specific data, B407 = company id 0x07B4. Same company id as the previous, so make sure you forward both messages to your brand specific parser.
Next, you will have to write something that translates the data from the last two messages to whatever it reports (garage door open/closed, etc). Just copy one of the other sensors (a short one) to have an idea.
If the parser works ok, you will have to add the device to const.py
and assign the sensors to the device (either use automatic detection, or assign them manually).
I can help if you want, no problem.
Have some first (not functional) draft for the parser ready. will add the device and sensor later.
https://github.com/custom-components/ble_monitor/tree/Hormann
I noticed on the HA forum that one of you had the following code
g_state = man_spec_data[4] & 0x0F
g_opening_percentage = man_spec_data[5] / 2
if g_state == 0x03:
g_state = 'open'
elif g_state == 0x04:
g_gstate = 'closed'
elif g_state == 0x05:
g_state = 'partially open'
else:
g_state = 'unknown'
In the second BLE message in the opening post (partially opened garage door), I get 0x07 for g_state
, so I'm not sure the above is 100% correct.
For now, I'm thinking about making an binary opening sensor (open or closed) and a percentage sensor.
I had a look at the data, but I can't follow the g_state
.
The third message of @jkaberg is a bit strange, `0x04 should be closed, but the percentage is 90%???
In between the 2nd and 3rd message, there is 19 seconds, so the door went from closed (1st two messages, to 90% open (in 19 seconds) and than to fully open.
So, The 3rd message is strange with regards to the g_state in the code above. I also don't see the partially open g_state (perhaps it only reports that if it is not moving). And in the messages from @smeersma I see a g_state = 0x07, which is not in the code above.
Is one of you able to figure out the logic of the byte before the percentage byte? It is the first byte in the long manufacturer_data. You can read 14 as 0x04
, 13 as 0x03
, etc.
140000000000000000efbbafa9d1a73b04 g_state = 0x04 0% open (closed)
140000000000000000efbbafa9d1a73b04 g_state = 0x04 0% open (closed)
14b400000000000000efbbafa9d1a73b04 g_state = 0x04 90% open ?????
13c800000000000000efbbafa9d1a73b04 g_state = 0x03 100% open
13c800000000000000efbbafa9d1a73b04 g_state = 0x03 100% open
13c800000000000000efbbafa9d1a73b04 g_state = 0x03 100% open
13c800000000000000efbbafa9d1a73b04 g_state = 0x03 100% open
13a600000000000000efbbafa9d1a73b04 g_state = 0x03 83% open
139e00000000000000efbbafa9d1a73b04 g_state = 0x03 79% open
139000000000000000efbbafa9d1a73b04 g_state = 0x03 72% open
138e00000000000000efbbafa9d1a73b04 g_state = 0x03 71% open
137800000000000000efbbafa9d1a73b04 g_state = 0x03 60% open
137600000000000000efbbafa9d1a73b04 g_state = 0x03 59% open
134400000000000000efbbafa9d1a73b04 g_state = 0x03 34% open
130000000000000000efbbafa9d1a73b04 g_state = 0x03 0% open
1400000000000000006722D81075F42A04 g_state = 0x04 0% open (closed)
173E000000000000006722D81075F42A04 g_state = 0x07 31% open
13C8000000000000006722D81075F42A04 g_state = 0x03 100% open
I have created a beta version (11.9.0-beta), for you to try. Please let me know if it works OK.
I now only use the percentage byte, I have not used the g_state byte. In case you figure out what that byte means, let me know.
@Ernst79 Awesome, I'll try as soon as I get home again (away for a few days)
Is one of you able to figure out the logic of the byte before the percentage byte? It is the first byte in the long manufacturer_data. You can read 14 as
0x04
, 13 as0x03
, etc.
Seems like there are two values for the intermediate positions: 0x07
and 0x05
; in my case I have 0x07
:
0x0201061107B3585540506011E38F96080001909A6609FFB40701022D20000014FFB40714000000000000E6F432147C9B00003504 # Fully closed
0x0201061107B3585540506011E38F96080001909A6609FFB40701026D20000014FFB407170200000000000000E6F432147C9B3504 # Closing
0x0201061107B3585540506011E38F96080001909A6609FFB40701022D20000014FFB40713C80000000000E6F432147C9B00003504 # Fully opened
I will make some further tests to better understand how the packet changes. Anyway for now the integration seems to work!
@Ernst79 So I'm back home giving this a shot, however I'm not seeing anything. Using latest beta (11.9.0-beta). also restared HASS after upgrade. Is this because I'm using esp32's and Bluetooth proxy? Maybe the integration doesn't support that? I've ran the port up and down a few times and I can see both in the Hörmann app and in the logs that advertisements are coming inn
See screenshots,
Setting the homeassistant.components.bluetooth: debug
in configuration.yaml show's me a lot of bluetooth traffic (Advertisements and others, as shown above in the logs)
BLE monitor is not working with Bluetooth Proxy. Bluetooth proxy is forwarding data to the Bluetooth integration, which on his turn forwards is to HA BLE integrations.
BLE monitor is using a different mechanism to collect the data and isn't using the Bluetooth integration. So, a Bluetooth proxy data is not forwading data to BLE monitor.
There is an alternative, ESPHome BLE gateway, which is working similar as Bluetooth proxy, but forwards the data to BLE monitor. https://custom-components.github.io/ble_monitor/parse_data (actually ESPHome BLE gateway is used as basis for Bluetooth Proxy)
Thanks for pointing that out, it wasn't very obvious (maybe make it clear in the README.md?) :-)
So with a few adaptions on my side it now gives me two sensors (percentage and state).
Thanks a lot @Ernst79
I will make some further tests to better understand how the packet changes.
I made the tests and on the diagram below I summarized the results of the two bytes (on the left of the hypen the status, on the right the percentage).
So:
0x15
(as I read around) but 0x17
with my Supramatic 4. I don't know if other types of garage openers will use 0x15
.0x14
becomes 0x04
(as you correctly did).0x14
0x14
when opening and 0x13
or 0x17
when closing0x14
vs 0x17
)Strangely no sensors are created for my garage door. This is what I can see in the logs when enabling reporting of unknown BLE advertisements in HA logs for Hormann:
2023-04-15 20:42:55.746 INFO (Thread-103) [custom_components.ble_monitor.ble_parser.hormann] BLE ADV from UNKNOWN Hormann DEVICE: RSSI: -61, MAC: F8:49:32:22:34:CB, DEVICE TYPE: None, ADV: 09ffb40701022d200000
2023-04-15 20:42:55.749 DEBUG (MainThread) [custom_components.ble_monitor.sensor] Data measuring sensor received: {'type': 'iBeacon', 'packet': 'no packet id', 'firmware': 'iBeacon', 'data': True, 'rssi': -80, 'mac': 'F211A98B869D', 'uuid': 'ecb0583ad71b43d2a4fdd5367063032d', 'tracker_id': b'\xec\xb0X:\xd7\x1bC\xd2\xa4\xfd\xd56pc\x03-', 'major': 5890, 'minor': 267, 'measured power': -56, 'cypress temperature': -39.29953125, 'cypress humidity': -5.51171875}
My Hormann MAC starts with F7:30
, while yours F8:49
. Is that a known MAC?
@smeersma Your data (09ffb40701022d200000
now looks much shorter than in the opening post. Can you check if you can find longer messages?
@virtualdj Thanks for creating the diagram. Doesn't seem very useful than to do something with this byte, according to your analysis.
I though it could be useful to display the status also with "Closing", "Opening" and "Partially opened" strings, as at the moment you have to rely on the percentage value alone. This way you know it's actually moving or stopped, too.
Yes, but from your analysis, I did understand this isn't possible. e.g. in the left branch,
You're right, but there's always the possibility to compare the actual percentage with the previous percentage (last state).
@smeersma Your data (
09ffb40701022d200000
now looks much shorter than in the opening post. Can you check if you can find longer messages?
In my opening post the data is the full raw data obtained through a BLE sniffer on my mobile phone. In the later post, it is the debug data through the integration. As such, the Manufacturer data where you can find the port opening % is the same between them "09ffb40701022d200000"
I did some more research whiile I was adapting virtualdj's findings (thanks virtualdj!) and here is a breakdown of the whole data stream I get from my Supramatic E4 door.
The main issue I found when I was putting this in my ESPHome's logic was that if you try to use the esp32_ble_tracker component and more precisely the on_ble_manufacturer_data_advertise event only returns the first of the manufacturer data packets in the BLE stream. And it only contains some information about which buttons are used to activate the door so you can't really get as much from it. The second manufacturer packet is the one you care about which is indeed the longer one. I found out that if I use the on_ble_advertise event instead I get access to all packets and therefore to the data I want.
Since I also have the UAP1 breakout board I created this board for me to be able to control the door https://github.com/julianpas/esphome-supramatic
I’m going to merge it as it is now. Unfortunately, I have decided to not add the states “opening” or “closing”, as this is info not being send directly by the device. It would therefore require me to store the previous state, compare it with the new state, etc. This is not how the other sensors are now programmed, so would require changing the code significantly. However, the same can be achieved by making a template sensor in HA. I hope you understand my decision.
About controlling the device, this isn’t possible with BLE monitor, BLE monitor can only listen to BLE messages, not send anything.
@smeersma Your data (
09ffb40701022d200000
now looks much shorter than in the opening post. Can you check if you can find longer messages?In my opening post the data is the full raw data obtained through a BLE sniffer on my mobile phone. In the later post, it is the debug data through the integration. As such, the Manufacturer data where you can find the port opening % is the same between them "09ffb40701022d200000"
Any advice on how I should debug to detect why the sensor does not show up on my side?
Try to get some BLE data, like you did in the opening post. Install a version prior to the version that we included the Hormann sensor, such that you can collect the raw data.
Try to get some BLE data, like you did in the opening post. Install a version prior to the version that we included the Hormann sensor, such that you can collect the raw data.
Thanks, I got following with 11.8.0:
2023-05-02 11:39:37.076 INFO (Thread-103) [custom_components.ble_monitor.ble_parser] Unknown advertisement received for mac: F8:49:32:22:34:CBservice data: []manufacturer specific data: [b'\t\xff\xb4\x07\x01\x02- \x00\x00']local name: UUID16: None,UUID128: None
Hmm, that message only contains the first manufacturer specific data (09ffb40701022d200000
). In the opening post, you showed the full raw message, which also contains a second manufacturer specific data part (14ffb4071400000000000000006722d81075f42a04
). We need this second part. Can you try to get the raw messages, like you have in the opening post?
With a BLE sniffer on my phone I see the full data as in the opening post, very strange
That is probably the logger in BLe monitor, only showing the first manufacturer specific data part. Just post a printscreen from your phone
That message should work just fine. Are you sure the sensor isn't showing up. ? Can you update to the latest version and show the debug logging?
2023-05-02 13:25:04.695 INFO (Thread-104) [custom_components.ble_monitor.ble_parser.hormann] BLE ADV from UNKNOWN Hormann DEVICE: RSSI: -48, MAC: F8:49:32:22:34:CB, DEVICE TYPE: None, ADV: 09ffb40701022d200000
I have allowed to create sensors automatically and even tried to "Add device..." manually, but above keeps the same.
Ok. can you do the following, in the file custom_components/ble_monitor/ble_parser/__init__.py
. change the following lines
elif comp_id == 0x07B4:
# Hörmann
if len(man_spec_data_list) == 2:
man_spec_data = b"".join(man_spec_data_list)
sensor_data = parse_hormann(self, man_spec_data, mac, rssi)
break
to
elif comp_id == 0x07B4:
# Hörmann
_LOGGER.error("incoming hormann data %s", data.hex())
if len(man_spec_data_list) == 2:
man_spec_data = b"".join(man_spec_data_list)
sensor_data = parse_hormann(self, man_spec_data, mac, rssi)
break
After that, restart HA and after a few minutes, check your HA logs. It should be filled with error messages with the full incoming data.
I get the following:
2023-05-02 14:19:13.354 ERROR (Thread-2) [homeassistant] Error doing job: Fatal error: protocol.data_received() call failed. Traceback (most recent call last): File "/usr/local/lib/python3.10/asyncio/selector_events.py", line 876, in _read_readydata_received self._protocol.data_received(data) File "/usr/local/lib/python3.10/site-packages/aioblescan/aioblescan.py", line 1855, in data_received self.process(packet) File "/config/custom_components/ble_monitor/init.py", line 662, in process_hci_events sensor_msg, tracker_msg = self.ble_parser.parse_raw_data(data) File "/config/custom_components/ble_monitor/ble_parser/init.py", line 156, in parse_raw_data sensor_data, tracker_data = self.parse_advertisement( File "/config/custom_components/ble_monitor/ble_parser/init__.py", line 317, in parse_advertisement _LOGGER.error("incoming hormann data %s", data.hex()) NameError: name 'data' is not defined
ah, sorry, replace data.hex()
with man_spec_data_list
in the 3d line
Seems the second part is dropped somewhere:
2023-05-02 16:09:59.072 ERROR (Thread-2) [custom_components.ble_monitor.ble_parser] incoming hormann data [b'\t\xff\xb4\x07\x01\x02- \x00\x00']
Ok, we are getting somewhere. Lets look further up in the code.
Can you change the following in the same file (around line 144)
elif adstuct_type == 0xFF:
# AD type 'Manufacturer Specific Data'
man_spec_data_list.append(adstruct)
# https://www.bluetooth.com/specifications/assigned-numbers/company-identifiers/
Change this to
elif adstuct_type == 0xFF:
# AD type 'Manufacturer Specific Data'
_LOGGER.error("incoming manufacturer specific data %s", data.hex())
man_spec_data_list.append(adstruct)
_LOGGER.error("manufacturer specific data list %s", man_spec_data_list)
# https://www.bluetooth.com/specifications/assigned-numbers/company-identifiers/
This will collect errors for each packet is manufacturer specific data, not only for Hormann. But we can filter it later based on the mac, Please post some message again.
2023-05-02 17:11:17.496 ERROR (Thread-3) [custom_components.ble_monitor.ble_parser] incoming manufacturer specific data 043e2102010401cb34223249f81514ffb4071400000000000000006722d81075f42a04bf
2023-05-02 17:11:17.504 ERROR (Thread-3) [custom_components.ble_monitor.ble_parser] manufacturer specific data list [b'\x14\xff\xb4\x07\x14\x00\x00\x00\x00\x00\x00\x00\x00g"\xd8\x10u\xf4*\x04']
2023-05-02 17:11:22.797 ERROR (Thread-3) [custom_components.ble_monitor.ble_parser] incoming manufacturer specific data 043e2b020100016a13670da7e71f020104030307fe10ffa705051001000000000000022200ca03190000020a00b5
2023-05-02 17:11:22.801 ERROR (Thread-3) [custom_components.ble_monitor.ble_parser] manufacturer specific data list [b'\x10\xff\xa7\x05\x05\x10\x01\x00\x00\x00\x00\x00\x00\x02"\x00\xca']
2023-05-02 17:11:22.822 ERROR (Thread-3) [custom_components.ble_monitor.ble_parser] incoming manufacturer specific data 043e2702010000d8e922c4cd281b02010606ff0600030080100948502055323720344b205736383842d0
2023-05-02 17:11:22.827 ERROR (Thread-3) [custom_components.ble_monitor.ble_parser] manufacturer specific data list [b'\x06\xff\x06\x00\x03\x00\x80']
2023-05-02 17:11:22.852 ERROR (Thread-3) [custom_components.ble_monitor.ble_parser] incoming manufacturer specific data 043e2b02010001cb34223249f81f0201061107b3585540506011e38f96080001909a6609ffb40701022d200000cf
2023-05-02 17:11:22.866 ERROR (Thread-3) [custom_components.ble_monitor.ble_parser] manufacturer specific data list [b'\t\xff\xb4\x07\x01\x02- \x00\x00']
2023-05-02 17:11:22.879 ERROR (Thread-3) [custom_components.ble_monitor.ble_parser] incoming manufacturer specific data 043e2b02010301605c5ad4fc3a1f1eff0600010920228aef177ce89f95d355c4ca3a47973c9d15e9029766757cd2
2023-05-02 17:11:22.884 ERROR (Thread-3) [custom_components.ble_monitor.ble_parser] manufacturer specific data list [b'\x1e\xff\x06\x00\x01\t "\x8a\xef\x17|\xe8\x9f\x95\xd3U\xc4\xca:G\x97<\x9d\x15\xe9\x02\x97fu|']
2023-05-02 17:11:22.893 ERROR (Thread-3) [custom_components.ble_monitor.ble_parser] incoming manufacturer specific data 043e2b0201030129ae8a8da40c1f1eff0600010f2002fd1615c74e72b410270ff9022c39463fd0068b0517d2a9d2
2023-05-02 17:11:22.898 ERROR (Thread-3) [custom_components.ble_monitor.ble_parser] manufacturer specific data list [b"\x1e\xff\x06\x00\x01\x0f \x02\xfd\x16\x15\xc7Nr\xb4\x10'\x0f\xf9\x02,9F?\xd0\x06\x8b\x05\x17\xd2\xa9"]
2023-05-02 17:11:22.913 ERROR (Thread-3) [custom_components.ble_monitor.ble_parser] incoming manufacturer specific data 043e2a020100019d868ba911f21e0201061aff4c000215ecb0583ad71b43d2a4fdd5367063032d1702010bc8bb
2023-05-02 17:11:22.916 ERROR (Thread-3) [custom_components.ble_monitor.ble_parser] manufacturer specific data list [b'\x1a\xffL\x00\x02\x15\xec\xb0X:\xd7\x1bC\xd2\xa4\xfd\xd56pc\x03-\x17\x02\x01\x0b\xc8']
2023-05-02 17:11:33.293 ERROR (Thread-3) [custom_components.ble_monitor.ble_parser] incoming manufacturer specific data 043e2b02010301605c5ad4fc3a1f1eff0600010920228aef177ce89f95d355c4ca3a47973c9d15e9029766757ccd
2023-05-02 17:11:33.297 ERROR (Thread-3) [custom_components.ble_monitor.ble_parser] manufacturer specific data list [b'\x1e\xff\x06\x00\x01\t "\x8a\xef\x17|\xe8\x9f\x95\xd3U\xc4\xca:G\x97<\x9d\x15\xe9\x02\x97fu|']
2023-05-02 17:11:33.301 ERROR (Thread-3) [custom_components.ble_monitor.ble_parser] incoming manufacturer specific data 043e2b02010001cb34223249f81f0201061107b3585540506011e38f96080001909a6609ffb40701022d200000cb
2023-05-02 17:11:33.303 ERROR (Thread-3) [custom_components.ble_monitor.ble_parser] manufacturer specific data list [b'\t\xff\xb4\x07\x01\x02- \x00\x00']
2023-05-02 17:11:33.367 ERROR (Thread-3) [custom_components.ble_monitor.ble_parser] incoming manufacturer specific data 043e2b0201030129ae8a8da40c1f1eff0600010f2002fd1615c74e72b410270ff9022c39463fd0068b0517d2a9ce
2023-05-02 17:11:33.373 ERROR (Thread-3) [custom_components.ble_monitor.ble_parser] manufacturer specific data list [b"\x1e\xff\x06\x00\x01\x0f \x02\xfd\x16\x15\xc7Nr\xb4\x10'\x0f\xf9\x02,9F?\xd0\x06\x8b\x05\x17\xd2\xa9"]
2023-05-02 17:11:33.412 ERROR (Thread-3) [custom_components.ble_monitor.ble_parser] incoming manufacturer specific data 043e2b020100016a13670da7e71f020104030307fe10ffa705051001000000000000022200ca03190000020a00b8
2023-05-02 17:11:33.416 ERROR (Thread-3) [custom_components.ble_monitor.ble_parser] manufacturer specific data list [b'\x10\xff\xa7\x05\x05\x10\x01\x00\x00\x00\x00\x00\x00\x02"\x00\xca']
2023-05-02 17:11:33.961 ERROR (Thread-3) [custom_components.ble_monitor.ble_parser] incoming manufacturer specific data 043e2a020100019d868ba911f21e0201061aff4c000215ecb0583ad71b43d2a4fdd5367063032d1702010bc8c4
2023-05-02 17:11:33.967 ERROR (Thread-3) [custom_components.ble_monitor.ble_parser] manufacturer specific data list [b'\x1a\xffL\x00\x02\x15\xec\xb0X:\xd7\x1bC\xd2\xa4\xfd\xd56pc\x03-\x17\x02\x01\x0b\xc8']
Seems there is 1 hit with the 2nd part AND the sensor has been created. But no further updates after that...
hmmm, I have to do some really hard thinking, the first message seems to contain the second part. The other two with b'\t\xff\xb4\x07
only the first part. Question is why does it only contain one part.
Lets try to add another log line (keep the ones you have now as well, such that we can see what happens along the code.
Change the following
def parse_raw_data(self, data):
"""Parse the raw data."""
# check if packet is Extended scan result
to
def parse_raw_data(self, data):
"""Parse the raw data."""
_LOGGER.error("data recieved %s", data.hex())
# check if packet is Extended scan result
This is the first part where the raw data enters the code.
I can only force a collection of the 2nd part if I disable and enable the integration a few times it seems, I will try to find the exact condition. Logs as below
2023-05-02 20:37:31.190 ERROR (Thread-102) [custom_components.ble_monitor.ble_parser] data recieved 043e2102010401cb34223249f81514ffb4071400000000000000006722d81075f42a04bf
2023-05-02 20:37:31.193 ERROR (Thread-102) [custom_components.ble_monitor.ble_parser] incoming manufacturer specific data 043e2102010401cb34223249f81514ffb4071400000000000000006722d81075f42a04bf
2023-05-02 20:37:31.197 ERROR (Thread-102) [custom_components.ble_monitor.ble_parser] manufacturer specific data list [b'\x14\xff\xb4\x07\x14\x00\x00\x00\x00\x00\x00\x00\x00g"\xd8\x10u\xf4*\x04']
2023-05-02 20:37:31.201 ERROR (Thread-102) [custom_components.ble_monitor.ble_parser] incoming hormann data [b'\x14\xff\xb4\x07\x14\x00\x00\x00\x00\x00\x00\x00\x00g"\xd8\x10u\xf4*\x04']
2023-05-02 20:37:31.346 ERROR (Thread-102) [custom_components.ble_monitor.ble_parser] data recieved 043e0c02010400d8e922c4cd2800bc
2023-05-02 20:37:31.552 ERROR (Thread-102) [custom_components.ble_monitor.ble_parser] data recieved 043e20020104016a13670da7e7141309393845373832413444394234334241444539aa
2023-05-02 20:37:31.706 ERROR (Thread-102) [custom_components.ble_monitor.ble_parser] data recieved 043e2b02010001cb34223249f81f0201061107b3585540506011e38f96080001909a6609ffb40701022d200000bf
2023-05-02 20:37:31.710 ERROR (Thread-102) [custom_components.ble_monitor.ble_parser] incoming manufacturer specific data 043e2b02010001cb34223249f81f0201061107b3585540506011e38f96080001909a6609ffb40701022d200000bf
2023-05-02 20:37:31.713 ERROR (Thread-102) [custom_components.ble_monitor.ble_parser] manufacturer specific data list [b'\t\xff\xb4\x07\x01\x02- \x00\x00']
2023-05-02 20:37:31.716 ERROR (Thread-102) [custom_components.ble_monitor.ble_parser] incoming hormann data [b'\t\xff\xb4\x07\x01\x02- \x00\x00']
2023-05-02 20:37:31.719 ERROR (Thread-102) [custom_components.ble_monitor.ble_parser] data recieved 043e2102010401cb34223249f81514ffb4071400000000000000006722d81075f42a04bf
2023-05-02 20:37:31.722 ERROR (Thread-102) [custom_components.ble_monitor.ble_parser] incoming manufacturer specific data 043e2102010401cb34223249f81514ffb4071400000000000000006722d81075f42a04bf
2023-05-02 20:37:31.723 ERROR (Thread-102) [custom_components.ble_monitor.ble_parser] manufacturer specific data list [b'\x14\xff\xb4\x07\x14\x00\x00\x00\x00\x00\x00\x00\x00g"\xd8\x10u\xf4*\x04']
2023-05-02 20:37:31.725 ERROR (Thread-102) [custom_components.ble_monitor.ble_parser] incoming hormann data [b'\x14\xff\xb4\x07\x14\x00\x00\x00\x00\x00\x00\x00\x00g"\xd8\x10u\xf4*\x04']
2023-05-02 20:37:31.787 ERROR (Thread-102) [custom_components.ble_monitor.ble_parser] data recieved 043e2b02010301cadd8dd47c2f1f1eff0600010f2002c4eba7b4be811a962490df5b92c1a2cdc205cd58359ec5c4
2023-05-02 20:37:31.791 ERROR (Thread-102) [custom_components.ble_monitor.ble_parser] incoming manufacturer specific data 043e2b02010301cadd8dd47c2f1f1eff0600010f2002c4eba7b4be811a962490df5b92c1a2cdc205cd58359ec5c4
2023-05-02 20:37:31.795 ERROR (Thread-102) [custom_components.ble_monitor.ble_parser] manufacturer specific data list [b'\x1e\xff\x06\x00\x01\x0f \x02\xc4\xeb\xa7\xb4\xbe\x81\x1a\x96$\x90\xdf[\x92\xc1\xa2\xcd\xc2\x05\xcdX5\x9e\xc5']
2023-05-02 20:37:31.858 ERROR (Thread-102) [custom_components.ble_monitor.ble_parser] data recieved 043e2702010000d8e922c4cd281b02010606ff0600030080100948502055323720344b205736383842bd
2023-05-02 20:37:31.861 ERROR (Thread-102) [custom_components.ble_monitor.ble_parser] incoming manufacturer specific data 043e2702010000d8e922c4cd281b02010606ff0600030080100948502055323720344b205736383842bd
2023-05-02 20:37:31.865 ERROR (Thread-102) [custom_components.ble_monitor.ble_parser] manufacturer specific data list [b'\x06\xff\x06\x00\x03\x00\x80']
2023-05-02 20:37:31.868 ERROR (Thread-102) [custom_components.ble_monitor.ble_parser] data recieved 043e0c02010400d8e922c4cd2800bd
2023-05-02 20:37:31.980 ERROR (Thread-102) [custom_components.ble_monitor.ble_parser] data recieved 043e2b020100016a13670da7e71f020104030307fe10ffa705051001000000000000022200ca03190000020a00aa
2023-05-02 20:37:31.985 ERROR (Thread-102) [custom_components.ble_monitor.ble_parser] incoming manufacturer specific data 043e2b020100016a13670da7e71f020104030307fe10ffa705051001000000000000022200ca03190000020a00aa
2023-05-02 20:37:31.988 ERROR (Thread-102) [custom_components.ble_monitor.ble_parser] manufacturer specific data list [b'\x10\xff\xa7\x05\x05\x10\x01\x00\x00\x00\x00\x00\x00\x02"\x00\xca']
2023-05-02 20:37:31.992 ERROR (Thread-102) [custom_components.ble_monitor.ble_parser] data recieved 043e20020104016a13670da7e7141309393845373832413444394234334241444539a7
2023-05-02 20:37:32.007 ERROR (Thread-102) [custom_components.ble_monitor.ble_parser] data recieved 043e100201020109f85e2c836f040303f3fea5
2023-05-02 20:37:32.010 ERROR (Thread-102) [custom_components.ble_monitor.ble_parser] data recieved 043e2b0201040109f85e2c836f1f1e16f3fe4a1723345058351132feb8d39fd68ec7dced86d955755e60fb6872a6
2023-05-02 20:37:32.045 ERROR (Thread-102) [custom_components.ble_monitor.ble_parser] data recieved 043e2a020100019d868ba911f21e0201061aff4c000215ecb0583ad71b43d2a4fdd5367063032d1702010bc8ae
2023-05-02 20:37:32.047 ERROR (Thread-102) [custom_components.ble_monitor.ble_parser] incoming manufacturer specific data 043e2a020100019d868ba911f21e0201061aff4c000215ecb0583ad71b43d2a4fdd5367063032d1702010bc8ae
2023-05-02 20:37:32.050 ERROR (Thread-102) [custom_components.ble_monitor.ble_parser] manufacturer specific data list [b'\x1a\xffL\x00\x02\x15\xec\xb0X:\xd7\x1bC\xd2\xa4\xfd\xd56pc\x03-\x17\x02\x01\x0b\xc8']
2023-05-02 20:37:32.054 ERROR (Thread-102) [custom_components.ble_monitor.ble_parser] data recieved 043e2a020104019d868ba911f21e07094d6f625245441521c0755f04a8b4b5880642fb956a4147fd1702010bad
2023-05-02 20:37:42.207 ERROR (Thread-102) [custom_components.ble_monitor.ble_parser] data recieved 043e2b02010001cb34223249f81f0201061107b3585540506011e38f96080001909a6609ffb40701022d200000d2
2023-05-02 20:37:42.210 ERROR (Thread-102) [custom_components.ble_monitor.ble_parser] incoming manufacturer specific data 043e2b02010001cb34223249f81f0201061107b3585540506011e38f96080001909a6609ffb40701022d200000d2
2023-05-02 20:37:42.212 ERROR (Thread-102) [custom_components.ble_monitor.ble_parser] manufacturer specific data list [b'\t\xff\xb4\x07\x01\x02- \x00\x00']
2023-05-02 20:37:42.215 ERROR (Thread-102) [custom_components.ble_monitor.ble_parser] incoming hormann data [b'\t\xff\xb4\x07\x01\x02- \x00\x00']
The first message should update your sensor just fine. Strange thing is though that you now receive messages with one manufacturer specific data part (starts with ff
), while in your opening post, you received to manufacturer specific data parts in one message. But that should not matter, as long as you receive the parts that start with 14ffb407
. I'm not sure why you don't receive these parts anymore. All data collecting is done by a pypi package called aioblescan. Perhaps we have to ask it on his github what can be wrong.
The first message should update your sensor just fine. Strange thing is though that you now receive messages with one manufacturer specific data part (starts with
ff
), while in your opening post, you received to manufacturer specific data parts in one message. But that should not matter, as long as you receive the parts that start with14ffb407
. I'm not sure why you don't receive these parts anymore. All data collecting is done by a pypi package called aioblescan. Perhaps we have to ask it on his github what can be wrong.
Thanks for your support today. I figured out I can only force a collection of the data if I disable and then enable the Bluetooth integration (not the Passive BLE integration)
Possibly the Bluetooth integration is interfering with BLE monitor. Try to see if it works when the Bluetooth integration is disabled.
Sensor Description
Hörmann Supramatic E4 Garage Door Opener
Additional information
https://www.garagedeur-onderdelen.nl/p/supramatic-e-bs-serie-4-met-bluetooth-artnr-4510311
In the BLE advertisement, the % on how much the garage door is opened is given. It would be interesting to have the garage door opening % as a sensor.
The % is given on a scale of 200 (so should be divided by 2 to get the actual %) in the positions as below
0x0201061107B3585540506011E38F96080001909A6609FFB40701022D20000014FFB4071400000000000000006722D81075F42A04 --> 0x00 / 2 = 0% open 0x0201061107B3585540506011E38F96080001909A6609FFB40701022D20000014FFB407173E000000000000006722D81075F42A04 --> 0x3E / 2 = 31% open 0x0201061107B3585540506011E38F96080001909A6609FFB40701022D20000014FFB40713C8000000000000006722D81075F42A04 --> 0xC8 / 2 = 100% open
BLE advertisements