CASAMBI BLE Light Support

there are as far as i know 2 lightsources that can be managed completely seperatly. will get mine in 2 weeks and i am wondering how i will be able to integrate it into HA.

Other users have tried to control the lights separately through the cloud api without succeeding, so using the official api will not work if casambi has not added support for it.

Hi,

Which smart home “solution” has the most features at the moment? Olof’s home_assistant_casambi or the more “unofficial” casambi-bt-hass (or casambi-bt? What’s the difference?). Or the Casambi Controller app on Homey Pro? Or a MQTT bridge solution?

Is every normal control possible with all these solutions? Can I for example put on a certain Casambi light point, after a Zigbee water sensor detect a leak? Can I do the same things as with Zigbee? Or is it way too limited (yet)?

It seems Casambi on broader smart home platforms is indeed a PITA! It seems to work, but it’s either unofficial (and reverse engineered, prone to errors and changes), either official but “feature wise limited, not free and not guaranteed to always have a dev key” (which should be renewed every 3 months by the way…).

Thank you!

The Casambi-bt-hass integration gives you full local control (Casambi-bt is just the library used in the casambi-ht-hass integration). I’m using it with 10 lights and an ESP bluetooth proxy (connected and powered via PoE) that’s in a cupboard somewhere. It works very well: I can change brightness, color temperature,…

And, indeed, this can be automated in Home Assistant, triggered by e.g. a water leak.

The only issue I have with casambi lights is that if the lights lose power (when they are turned off with a regular light switch) they become unavailable in Home Assistant as well. They usually become available again 20 seconds after they regain power. But not always: sometimes one has to reload the casambi-ht integration.

What does the casambi-bt package need the private casambi api for, when it talks directly bluetooth?

Because it grabs information from the private api, like network information: casambi-bt/src/CasambiBt/_network.py at bdf197bdb5fea957db9aa57e5391a798174f7959 · lkempf/casambi-bt · GitHub

From Casambi support: “Unfortunately we can not currently offer API key access to our Beta program”.
Is that a dead stop for the usage of the BT integration?

You can’t use the old integration (the one I am the maintainer of), but you can use the Bluetooth based integration long as it’s not legacy network. The new integration uses the same api as the apps

I got a problem that the lights keep getting unavailable. Only integration reloading helps.
Additionally i’ve been getting the error:
unexpected error creating network [eps32 BLE proxy address]

Here the logs to that:

Logger: homeassistant.config_entries
Source: config_entries.py:584
First occurred: July 15, 2024 at 7:10:47 PM (5 occurrences)
Last logged: 2:57:37 AM

Error setting up entry [Casambi home]  for casambi_bt: Unexpected error creating network ED:64:87:A7:21:C0
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/bleak_esphome/backend/client.py", line 77, in _async_wrap_bluetooth_operation
    return await func(self, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/bleak_esphome/backend/client.py", line 551, in read_gatt_char
    return await self._client.bluetooth_gatt_read(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aioesphomeapi/client.py", line 763, in bluetooth_gatt_read
    return await self._bluetooth_gatt_read(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aioesphomeapi/client.py", line 794, in _bluetooth_gatt_read
    resp = await self._send_bluetooth_message_await_response(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aioesphomeapi/client.py", line 477, in _send_bluetooth_message_await_response
    self._raise_for_ble_connection_change(address, resp, msg_types)
  File "/usr/local/lib/python3.12/site-packages/aioesphomeapi/client.py", line 705, in _raise_for_ble_connection_change
    raise BluetoothConnectionDroppedError(
aioesphomeapi.core.BluetoothConnectionDroppedError: Peripheral ED:64:87:A7:21:C0 changed connection status while waiting for BluetoothGATTReadResponse, BluetoothGATTErrorResponse: Insufficient authorization (8)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/config/custom_components/casambi_bt/__init__.py", line 103, in connect
    await self.casa.connect(device, self.password)
  File "/usr/local/lib/python3.12/site-packages/CasambiBt/_casambi.py", line 147, in connect
    await self._connectClient()
  File "/usr/local/lib/python3.12/site-packages/CasambiBt/_casambi.py", line 154, in _connectClient
    await self._casaClient.exchangeKey(self._casaNetwork.getKeyStore())  # type: ignore[union-attr]
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/CasambiBt/_client.py", line 152, in exchangeKey
    firstResp = await self._gattClient.read_gatt_char(CASA_AUTH_CHAR_UUID)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/bleak/__init__.py", line 711, in read_gatt_char
    return await self._backend.read_gatt_char(char_specifier, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/bleak_esphome/backend/client.py", line 87, in _async_wrap_bluetooth_operation
    raise BleakError(str(ex)) from ex
bleak.exc.BleakError: Peripheral ED:64:87:A7:21:C0 changed connection status while waiting for BluetoothGATTReadResponse, BluetoothGATTErrorResponse: Insufficient authorization (8)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 584, in async_setup
    result = await component.async_setup_entry(hass, self)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/casambi_bt/__init__.py", line 32, in async_setup_entry
    await api.connect()
  File "/config/custom_components/casambi_bt/__init__.py", line 116, in connect
    raise ConfigEntryError(
homeassistant.exceptions.ConfigEntryError: Unexpected error creating network ED:64:87:A7:21:C0

Basically i need to reload the integration all few hours manually due to these two problems, Automations dont work.

Help would be appreciated since i really wanna use my Casambi lights with Home assistant

Hi, starting to use Casambi for Occhio product here.
Same issue, the BLE integration shows everything unavailable unless I reload the integration manually.
I could get how often I should to so, i started yestarday, and I was hoping to get an automation or something to reload the integration hourly.

Would be really good have an help

Hi, I see you use my same configuration, however I have to reload the casambi bluetooth integration every few hours because lights became unavailable.
I understood you get the same behaviour when your lights lose power. My lights are always powered but it happens regardelss.

@Frapp did you enable the passive mode on the Bluetooth adapter?

@Xilviu Could you please clarify: is passive mode expected to be enabled here, or should it be disabled?

In my setup, by default the “passive search” (or passive scan?) option was disabled. I had frequent periods of 3-4 minutes where all the Casambi lights became unavailble, maybe once an hour or more often.

This completely stopped happening after I enabled the “passive search” option. No idea what it actually does :slight_smile: but it was the solution for me.

Also no idea if this is specific to my hardware - built-in bluetooth adapter of the Raspberry Pi 4 recognized as “Raspberry Pi Trading Ltd bcm43438-bt”.

Hi, sorry I didn’t see your answer. Where should I find the passive mode? on ESP Home add-on or where? I don’t recall what I selected, I do know the issue is still here :smiley:

@Frapp this is in the Blutooth integration settings

Settings → Devices → Bluetooth → Configure → enable Passive Scan

The names are translated from French, it could be different in English

HI thanks, I use the Olimex POE board for bluetooth integrated via ESP Home and I do not see this option. The bluetooth you mean is the one onboard my nuc but it is far from where the lamps are, that’s why I went for the Olimex board.
In the config of this one I see no Enable passive scan option :frowning:

@Frapp apparently there is something in the doc

I have some troubles with the devices showing up in de Bluetooth integration. I can see al my devices just fine. The dimmers and functions on my meanwell power supplys work flawlessly. But i have a few Liga Air devices that the device status is a bit buggy. I can turn them on or off when going into the switch in the home assitant dashboard, but the bulb status does not change to on or off with them. I have the same problem with the group function. Wich results in a bit of a buggy mess after a few on or off commands.
And a small side question: is there anything going on in the developtment to integrate the Casambi motion sensors?
Thanks for al the great work!

Hi thanks, apparently is false by default so there is nothing I could do :frowning: