bulldog5046 / ha_nespresso_integration

19 stars 4 forks source link

Unable to set caps_number to 0 with nespresso.caps service #11

Open saya6k opened 9 months ago

saya6k commented 9 months ago
스크린샷 2023-12-12 12 22 52

I can't make capsule count to 0 with this service call.

bulldog5046 commented 9 months ago

The valid range is between 1 and 1000. Is there a reason you'd want to set it to 0?

saya6k commented 9 months ago

Oh, it was intended. It's just I have consumed all my capsule today but there was some leftover on sensor. Never Mind.

saya6k commented 9 months ago

But I think this is real trouble. When I call service nespresso.caps capsule to 60 to fill some new, This error occurs. I can call other services like nespresso.coffee.

2023-12-13 08:55:39.778 ERROR (MainThread) [custom_components.nespresso.sensor] Updating caps counter failed: Peripheral EC:E4:50:13:F7:1F changed connection status while waiting for BluetoothGATTWriteResponse, BluetoothGATTErrorResponse: Unknown error (0)
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/esphome/bluetooth/client.py", line 79, in _async_wrap_bluetooth_operation
    return await func(self, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/esphome/bluetooth/client.py", line 579, in write_gatt_char
    await self._client.bluetooth_gatt_write(
  File "/usr/local/lib/python3.11/site-packages/aioesphomeapi/client.py", line 802, in bluetooth_gatt_write
    await self._bluetooth_gatt_write(
  File "/usr/local/lib/python3.11/site-packages/aioesphomeapi/client.py", line 840, in _bluetooth_gatt_write
    await self._send_bluetooth_message_await_response(
  File "/usr/local/lib/python3.11/site-packages/aioesphomeapi/client.py", line 467, in _send_bluetooth_message_await_response
    self._raise_for_ble_connection_change(address, resp, msg_types)
  File "/usr/local/lib/python3.11/site-packages/aioesphomeapi/client.py", line 695, in _raise_for_ble_connection_change
    raise BluetoothConnectionDroppedError(
aioesphomeapi.core.BluetoothConnectionDroppedError: Peripheral EC:E4:50:13:F7:1F changed connection status while waiting for BluetoothGATTWriteResponse, BluetoothGATTErrorResponse: Unknown error (0)
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
  File "/config/custom_components/nespresso/sensor.py", line 179, in caps
    conn_status = await Nespressodetect.connect(ble_device)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/nespresso/nespresso.py", line 103, in connect
    await self.auth(client)
  File "/config/custom_components/nespresso/nespresso.py", line 215, in auth
    await client.write_gatt_char(CHAR_UUID_AUTH, binascii.unhexlify(self.auth_code), response=True)
  File "/usr/local/lib/python3.11/site-packages/bleak/__init__.py", line 776, in write_gatt_char
    await self._backend.write_gatt_char(characteristic, data, response)
  File "/usr/src/homeassistant/homeassistant/components/esphome/bluetooth/client.py", line 89, in _async_wrap_bluetooth_operation
    raise BleakError(str(ex)) from ex
bleak.exc.BleakError: Peripheral EC:E4:50:13:F7:1F changed connection status while waiting for BluetoothGATTWriteResponse, BluetoothGATTErrorResponse: Unknown error (0)
bulldog5046 commented 9 months ago

Are you seeing this often? It's not one i've seen before but I know you're using the bluetooth proxy which i haven't been able to test with.

saya6k commented 8 months ago

I see this some times. After I tried few times, I was able to set capsule number, so I think this is due to connection issue?