Coder Social home page Coder Social logo

pysnooz's People

Contributors

actions-user avatar allcontributors[bot] avatar austinbrunkhorst avatar epenet avatar mweinelt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

epenet mweinelt

pysnooz's Issues

Test failure with bleak 0.20+

Describe the bug
API changes in bleak 0.20 make the test suite fail against pysnooz 0.8.3

The general failure looks like this:

>       device = BLEDevice("AA:BB:CC:DD:EE:FF", "Snooz-EEFF")
E       TypeError: BLEDevice.__init__() missing 2 required positional arguments: 'details' and 'rssi'

To Reproduce
Upgrade bleak to the version used in home-assistant and run the testsuite

Additional context

ERROR tests/test_api.py::test_properties - TypeError: BLEDevice.__init__() missing 2 required positional arguments: 'd...
ERROR tests/test_api.py::test_retries_write_errors - TypeError: BLEDevice.__init__() missing 2 required positional arguments: 'd...
ERROR tests/test_api.py::test_raises_write_errors_after_retries_exhausted - TypeError: BLEDevice.__init__() missing 2 required positional arguments: 'd...
ERROR tests/test_api.py::test_raises_unknown_write_errors - TypeError: BLEDevice.__init__() missing 2 required positional arguments: 'd...
ERROR tests/test_device.py::test_display_name - TypeError: BLEDevice.__init__() missing 2 required positional arguments: 'd...
ERROR tests/test_device.py::test_basic_commands - TypeError: BLEDevice.__init__() missing 2 required positional arguments: 'd...
ERROR tests/test_device.py::test_auto_reconnect - TypeError: BLEDevice.__init__() missing 2 required positional arguments: 'd...
ERROR tests/test_device.py::test_auto_reconnect_device_unavailable - TypeError: BLEDevice.__init__() missing 2 required positional arguments: 'd...
ERROR tests/test_device.py::test_manual_disconnect - TypeError: BLEDevice.__init__() missing 2 required positional arguments: 'd...
ERROR tests/test_device.py::test_establish_connection_exceptions - TypeError: BLEDevice.__init__() missing 2 required positional arguments: 'd...
ERROR tests/test_device.py::test_write_exception_during_reconnection - TypeError: BLEDevice.__init__() missing 2 required positional arguments: 'd...
ERROR tests/test_device.py::test_manual_disconnect_during_reconnect - TypeError: BLEDevice.__init__() missing 2 required positional arguments: 'd...
ERROR tests/test_device.py::test_disconnect_before_ready - TypeError: BLEDevice.__init__() missing 2 required positional arguments: 'd...
ERROR tests/test_device.py::test_unexpected_error_before_ready - TypeError: BLEDevice.__init__() missing 2 required positional arguments: 'd...
ERROR tests/test_device.py::test_unexpected_error_during_execution - TypeError: BLEDevice.__init__() missing 2 required positional arguments: 'd...
ERROR tests/test_device.py::test_disconnect_before_ready_then_reconnects - TypeError: BLEDevice.__init__() missing 2 required positional arguments: 'd...
ERROR tests/test_device.py::test_manual_disconnect_before_ready - TypeError: BLEDevice.__init__() missing 2 required positional arguments: 'd...
ERROR tests/test_device.py::test_disconnect_while_reconnecting_before_ready - TypeError: BLEDevice.__init__() missing 2 required positional arguments: 'd...
ERROR tests/test_device.py::test_device_disconnects_during_transition - TypeError: BLEDevice.__init__() missing 2 required positional arguments: 'd...
ERROR tests/test_device.py::test_user_disconnects_during_transition - TypeError: BLEDevice.__init__() missing 2 required positional arguments: 'd...
ERROR tests/test_device.py::test_device_unavailable_during_transition - TypeError: BLEDevice.__init__() missing 2 required positional arguments: 'd...
ERROR tests/test_device.py::test_manual_disconnect_during_transition - TypeError: BLEDevice.__init__() missing 2 required positional arguments: 'd...
ERROR tests/test_device.py::test_new_commands_cancel_existing - TypeError: BLEDevice.__init__() missing 2 required positional arguments: 'd...

No longer works on HA 2022.0.9

I had the following problem after updating from HA 2022.8.7 (working great) to HA 2022.9.0.

Logger: homeassistant.util.package
Source: util/package.py:98
First occurred: 7 septembre 2022 à 23:40:56 (3 occurrences)
Last logged: 7 septembre 2022 à 23:41:11

Unable to install package pysnooz==0.7.3: ERROR: Cannot install pysnooz==0.7.3 because these package versions have conflicting dependencies. ERROR: ResolutionImpossible: for help visit https://pip.pypa.io/en/latest/topics/dependency-resolution/#dealing-with-dependency-conflicts

Thanks for your great work.

Uncaught exception

Is there an existing issue for this?

  • I have searched the existing issues

Stack trace

Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/esphome/bluetooth/client.py", line 96, in _async_wrap_bluetooth_operation
return await func(self, *args, **kwargs)
File "/usr/src/homeassistant/homeassistant/components/esphome/bluetooth/client.py", line 540, in write_gatt_char
await self._client.bluetooth_gatt_write(
File "/usr/local/lib/python3.10/site-packages/aioesphomeapi/client.py", line 667, in bluetooth_gatt_write
await self._send_bluetooth_message_await_response(
File "/usr/local/lib/python3.10/site-packages/aioesphomeapi/client.py", line 440, in _send_bluetooth_message_await_response
raise BluetoothGATTAPIError(BluetoothGATTError.from_pb(resp[0]))
aioesphomeapi.core.BluetoothGATTAPIError: Bluetooth GATT Error address=90:38:0C:61:82:42 handle=21 error=-1 description=Not connected

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/local/lib/python3.10/site-packages/pysnooz/commands.py", line 171, in _async_execute_wrapper
await self._async_execute(api)
File "/usr/local/lib/python3.10/site-packages/pysnooz/commands.py", line 261, in _async_execute
await api.async_set_power(self.command.on)
File "/usr/local/lib/python3.10/site-packages/pysnooz/api.py", line 86, in async_set_power
await self._async_write_command(CommandId.SET_POWER, b"\x01" if on else b"\x00")
File "/usr/local/lib/python3.10/site-packages/pysnooz/api.py", line 129, in _async_write_command
await self._client.write_gatt_char(
File "/usr/local/lib/python3.10/site-packages/bleak/init.py", line 593, in write_gatt_char
await self._backend.write_gatt_char(char_specifier, data, response)
File "/usr/src/homeassistant/homeassistant/components/esphome/bluetooth/client.py", line 79, in _async_wrap_bluetooth_connected_operation
await task
File "/usr/src/homeassistant/homeassistant/components/esphome/bluetooth/client.py", line 117, in _async_wrap_bluetooth_operation
self._async_ble_device_disconnected()
File "/usr/src/homeassistant/homeassistant/components/esphome/bluetooth/client.py", line 197, in _async_ble_device_disconnected
self._async_disconnected_cleanup()
File "/usr/src/homeassistant/homeassistant/components/esphome/bluetooth/client.py", line 192, in _async_disconnected_cleanup
self._unsubscribe_connection_state()
File "/usr/src/homeassistant/homeassistant/components/esphome/bluetooth/client.py", line 168, in _unsubscribe_connection_state
self._cancel_connection_state()
File "/usr/local/lib/python3.10/site-packages/aioesphomeapi/client.py", line 534, in unsub
self._connection.remove_message_callback(on_msg, msg_types)
File "/usr/local/lib/python3.10/site-packages/aioesphomeapi/connection.py", line 455, in remove_message_callback
self._message_handlers[msg_type].remove(on_message)
KeyError: <class 'api_pb2.BluetoothDeviceConnectionResponse'>

Environment

Home Assistant Component

Additional details

Home Assistant 2023.1.7
Supervisor 2022.12.1
Operating System 9.4
Frontend 20230110.0 - latest

Using ESPHome bluetooth proxy. Snooz stops working randomly unless I restart Home Assistant.

Supported models

Which models are supported? The home assistant documentation only mentions the SNOOZ White Noise Machine. What about the SNOOZ Button and SNOOZ Pro? Both are controlled using the app, the latter also has a physical fan.

Uncaught exception

Is there an existing issue for this?

  • I have searched the existing issues

Stack trace

copy the trace and paste in the issue ⬇
Traceback (most recent call last):
File "/usr/local/lib/python3.11/site-packages/aioesphomeapi/connection.py", line 670, in send_message_await_response_complex
await fut
TimeoutError
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/esphome/bluetooth/client.py", line 100, in _async_wrap_bluetooth_operation
return await func(self, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/esphome/bluetooth/client.py", line 645, in write_gatt_char
await self._client.bluetooth_gatt_write(
File "/usr/local/lib/python3.11/site-packages/aioesphomeapi/client.py", line 882, in bluetooth_gatt_write
await self._send_bluetooth_message_await_response(
File "/usr/local/lib/python3.11/site-packages/aioesphomeapi/client.py", line 505, in _send_bluetooth_message_await_response
resp = await self._connection.send_message_await_response_complex(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/aioesphomeapi/connection.py", line 673, in send_message_await_response_complex
raise TimeoutAPIError(
aioesphomeapi.core.TimeoutAPIError: Timeout waiting for response for after 30.0s
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/local/lib/python3.11/site-packages/pysnooz/commands.py", line 171, in _async_execute_wrapper
await self._async_execute(api)
File "/usr/local/lib/python3.11/site-packages/pysnooz/commands.py", line 261, in _async_execute
await api.async_set_power(self.command.on)
File "/usr/local/lib/python3.11/site-packages/pysnooz/api.py", line 89, in async_set_power
await self._async_write_command(CommandId.SET_POWER, b"\x01" if on else b"\x00")
File "/usr/local/lib/python3.11/site-packages/pysnooz/api.py", line 132, in _async_write_command
await self._client.write_gatt_char(
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 86, in _async_wrap_bluetooth_connected_operation
return await func(self, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/esphome/bluetooth/client.py", line 102, in _async_wrap_bluetooth_operation
raise asyncio.TimeoutError(str(err)) from err
TimeoutError: Timeout waiting for response for after 30.0s
2023-10-19 14:26:53.350 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [140028220891456] Command TurnOn failed with status UNEXPECTED_ERROR after 0:00:30.004355
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 226, in handle_call_service
await hass.services.async_call(
File "/usr/src/homeassistant/homeassistant/core.py", line 2012, in async_call
response_data = await coro
^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/core.py", line 2049, in _execute_service
return await target(service_call)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 235, in handle_service
return await service.entity_service_call(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 876, in entity_service_call
response_data = await _handle_entity_call(
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 948, in _handle_entity_call
result = await task
^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/snooz/fan.py", line 136, in async_turn_on
await self._async_execute_command(turn_on(percentage))
File "/usr/src/homeassistant/homeassistant/components/snooz/fan.py", line 166, in _async_execute_command
raise HomeAssistantError(
homeassistant.exceptions.HomeAssistantError: Command TurnOn failed with status UNEXPECTED_ERROR after 0:00:30.004355
2023-10-19 14:26:53.877 WARNING (MainThread) [aioesphomeapi.connection] esp32-bluetooth-proxy-94e700 @ 10.10.61.247: Connection error occurred: [Errno 104] Connection reset by peer
2023-10-19 14:26:53.878 WARNING (MainThread) [homeassistant.components.esphome.manager] Error getting initial data for 10.10.61.247: Read failed
2023-10-19 14:26:53.878 ERROR (MainThread) [pysnooz.commands] [Snooz 2C40] Unexpected error while executing TurnOff
1️⃣ Report this issue: https://github.com/AustinBrunkhorst/pysnooz/issues/new?labels=bug&template=log-unexpected-error.yaml&title=Uncaught+exception
2️⃣ ⬇ copy the trace and paste in the issue ⬇
Traceback (most recent call last):
File "/usr/local/lib/python3.11/asyncio/selector_events.py", line 989, in _read_ready__data_received
data = self._sock.recv(self.max_size)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ConnectionResetError: [Errno 104] Connection reset by peer
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/esphome/bluetooth/client.py", line 100, in _async_wrap_bluetooth_operation
return await func(self, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/esphome/bluetooth/client.py", line 645, in write_gatt_char
await self._client.bluetooth_gatt_write(
File "/usr/local/lib/python3.11/site-packages/aioesphomeapi/client.py", line 882, in bluetooth_gatt_write
await self._send_bluetooth_message_await_response(
File "/usr/local/lib/python3.11/site-packages/aioesphomeapi/client.py", line 505, in _send_bluetooth_message_await_response
resp = await self._connection.send_message_await_response_complex(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/aioesphomeapi/connection.py", line 670, in send_message_await_response_complex
await fut
aioesphomeapi.core.ReadFailedAPIError: Read failed
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/local/lib/python3.11/site-packages/pysnooz/commands.py", line 171, in _async_execute_wrapper
await self._async_execute(api)
File "/usr/local/lib/python3.11/site-packages/pysnooz/commands.py", line 261, in _async_execute
await api.async_set_power(self.command.on)
File "/usr/local/lib/python3.11/site-packages/pysnooz/api.py", line 89, in async_set_power
await self._async_write_command(CommandId.SET_POWER, b"\x01" if on else b"\x00")
File "/usr/local/lib/python3.11/site-packages/pysnooz/api.py", line 132, in _async_write_command
await self._client.write_gatt_char(
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 86, in _async_wrap_bluetooth_connected_operation
return await func(self, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/esphome/bluetooth/client.py", line 124, in _async_wrap_bluetooth_operation
raise BleakError(str(err)) from err
bleak.exc.BleakError: Read failed
2023-10-19 14:26:53.891 INFO (MainThread) [aioesphomeapi.reconnect_logic] Processing unexpected disconnect from ESPHome API for esp32-bluetooth-proxy-94e700 @ 10.10.61.247
2023-10-19 14:26:53.894 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [140028220891456] Command TurnOff failed with status UNEXPECTED_ERROR after 0:00:29.758217
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 226, in handle_call_service
await hass.services.async_call(
File "/usr/src/homeassistant/homeassistant/core.py", line 2012, in async_call
response_data = await coro
^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/core.py", line 2049, in _execute_service
return await target(service_call)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 235, in handle_service
return await service.entity_service_call(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 876, in entity_service_call
response_data = await _handle_entity_call(
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 948, in _handle_entity_call
result = await task
^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/snooz/fan.py", line 140, in async_turn_off
await self._async_execute_command(turn_off())
File "/usr/src/homeassistant/homeassistant/components/snooz/fan.py", line 166, in _async_execute_command
raise HomeAssistantError(
homeassistant.exceptions.HomeAssistantError: Command TurnOff failed with status UNEXPECTED_ERROR after 0:00:29.758217

Environment

Home Assistant Component

Additional details

One of my two snooz units, which has been working great for at least a couple of months, stopped responding to home assistant. I am using ESPHome bluetooth proxy on ESP32s. I captured this error by enabling debug logging for the Snooz integration and then attempting to turn the snooz on/off. Please let me know what else I can provide to help! Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.