Ludy87 / xplora_watch

Xplora® Watch Home Assistant Integration
MIT License
49 stars 6 forks source link

error message when running service "Read message" #179

Closed Ludy87 closed 1 year ago

Ludy87 commented 1 year ago
    I don't get this to work.

Get the following error message when running service "Read message":

2023-03-XX XX:XX:XX.XXX ERROR (MainThread) [homeassistant.helpers.script.websocket_api_script] websocket_api script: Error executing script. Unexpected error for call_service at pos 1: 'XploraMessageSensorUpdateService' object has no attribute '_gql_handler' Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 451, in _async_step await getattr(self, handler)() File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 684, in _async_call_service_step await service_task File "/usr/src/homeassistant/homeassistant/core.py", line 1808, in async_call task.result() File "/usr/src/homeassistant/homeassistant/core.py", line 1845, in _execute_service await cast(Callable[[ServiceCall], Awaitable[None]], handler.job.target)( File "/config/custom_components/xplora_watch/services.py", line 80, in async_read_message await sensor_update_service.async_read_message(kwargs[ATTR_SERVICE_TARGET]) File "/config/custom_components/xplora_watch/services.py", line 179, in async_read_message await self._fetch_chat_voice(watch, msg_id) File "/config/custom_components/xplora_watch/services.py", line 191, in _fetch_chat_voice voice: Dict[str, Any] = await self._gql_handler.fetchChatVoice_a(watch_id, msg_id) AttributeError: 'XploraMessageSensorUpdateService' object has no attribute '_gql_handler' 2023-03-XX XX:XX:XX.XXX ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [XXXXXXXXXXXXXXX] Error handling message: Unknown error (unknown_error) Username from xxx.xxx.xxx.xxx (Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/110.0) Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/components/websocket_api/decorators.py", line 26, in _handle_async_response await func(hass, connection, msg) File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 640, in handle_execute_script await script_obj.async_run(msg.get("variables"), context=context) File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 1524, in async_run await asyncio.shield(run.async_run()) File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 409, in async_run await self._async_step(log_exceptions=False) File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 453, in _async_step self._handle_exception( File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 476, in _handle_exception raise exception File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 451, in _async_step await getattr(self, handler)() File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 684, in _async_call_service_step await service_task File "/usr/src/homeassistant/homeassistant/core.py", line 1808, in async_call task.result() File "/usr/src/homeassistant/homeassistant/core.py", line 1845, in _execute_service await cast(Callable[[ServiceCall], Awaitable[None]], handler.job.target)( File "/config/custom_components/xplora_watch/services.py", line 80, in async_read_message await sensor_update_service.async_read_message(kwargs[ATTR_SERVICE_TARGET]) File "/config/custom_components/xplora_watch/services.py", line 179, in async_read_message await self._fetch_chat_voice(watch, msg_id) File "/config/custom_components/xplora_watch/services.py", line 191, in _fetch_chat_voice voice: Dict[str, Any] = await self._gql_handler.fetchChatVoice_a(watch_id, msg_id) AttributeError: 'XploraMessageSensorUpdateService' object has no attribute '_gql_handler'

Is it just me or is there a bug somewhere? Same problem for images and videos.

_Originally posted by @bergfalk in https://github.com/Ludy87/xplora_watch/discussions/152#discussioncomment-5205933_

bergfalk commented 1 year ago

Thanks for the quick response. I still get error message but it looks different now:

Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/components/websocket_api/decorators.py", line 26, in _handle_async_response await func(hass, connection, msg) File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 640, in handle_execute_script await script_obj.async_run(msg.get("variables"), context=context) File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 1524, in async_run await asyncio.shield(run.async_run()) File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 409, in async_run await self._async_step(log_exceptions=False) File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 453, in _async_step self._handle_exception( File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 476, in _handle_exception raise exception File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 451, in _async_step await getattr(self, handler)() File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 684, in _async_call_service_step await service_task File "/usr/src/homeassistant/homeassistant/core.py", line 1808, in async_call task.result() File "/usr/src/homeassistant/homeassistant/core.py", line 1845, in _execute_service await cast(Callable[[ServiceCall], Awaitable[None]], handler.job.target)( File "/config/custom_components/xplora_watch/services.py", line 80, in async_read_message await sensor_update_service.async_read_message(kwargs[ATTR_SERVICE_TARGET]) File "/config/custom_components/xplora_watch/services.py", line 183, in async_read_message await self._fetch_chat_image(watch, msg_id) File "/config/custom_components/xplora_watch/services.py", line 202, in _fetch_chat_image encoded_base64_string_to_file(self._hass, image.get("fetchChatImage"), msg_id, "jpeg", "image") File "/config/custom_components/xplora_watch/helper.py", line 53, in encoded_base64_string_to_file with open(f"{media_path}/{file_name}.{file_type}", "wb", encoding="utf8") as f: ValueError: binary mode doesn't take an encoding argument

Ludy87 commented 1 year ago

Thanks for the quick response. I still get error message but it looks different now:

Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/components/websocket_api/decorators.py", line 26, in _handle_async_response await func(hass, connection, msg) File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 640, in handle_execute_script await script_obj.async_run(msg.get("variables"), context=context) File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 1524, in async_run await asyncio.shield(run.async_run()) File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 409, in async_run await self._async_step(log_exceptions=False) File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 453, in _async_step self._handle_exception( File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 476, in _handle_exception raise exception File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 451, in _async_step await getattr(self, handler)() File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 684, in _async_call_service_step await service_task File "/usr/src/homeassistant/homeassistant/core.py", line 1808, in async_call task.result() File "/usr/src/homeassistant/homeassistant/core.py", line 1845, in _execute_service await cast(Callable[[ServiceCall], Awaitable[None]], handler.job.target)( File "/config/custom_components/xplora_watch/services.py", line 80, in async_read_message await sensor_update_service.async_read_message(kwargs[ATTR_SERVICE_TARGET]) File "/config/custom_components/xplora_watch/services.py", line 183, in async_read_message await self._fetch_chat_image(watch, msg_id) File "/config/custom_components/xplora_watch/services.py", line 202, in _fetch_chat_image encoded_base64_string_to_file(self._hass, image.get("fetchChatImage"), msg_id, "jpeg", "image") File "/config/custom_components/xplora_watch/helper.py", line 53, in encoded_base64_string_to_file with open(f"{media_path}/{file_name}.{file_type}", "wb", encoding="utf8") as f: ValueError: binary mode doesn't take an encoding argument

@bergfalk I opened a bug report for this: https://github.com/Ludy87/xplora_watch/issues/181