chime_tts icon indicating copy to clipboard operation
chime_tts copied to clipboard

Setting `cache: true` causing 'NoneType' object has no attribute 'get' error

Open hsteckylf opened this issue 9 months ago • 1 comments

System Health details

System Information

version core-2024.5.4
installation_type Home Assistant OS
dev false
hassio true
docker true
user root
virtualenv false
python_version 3.12.2
os_name Linux
os_version 6.6.28-haos-raspi
arch aarch64
timezone America/New_York
config_dir /config
Home Assistant Community Store
GitHub API ok
GitHub Content ok
GitHub Web ok
GitHub API Calls Remaining 5000
Installed Version 1.34.0
Stage running
Available Repositories 1398
Downloaded Repositories 10
HACS Data ok
Home Assistant Cloud
logged_in false
can_reach_cert_server ok
can_reach_cloud_auth ok
can_reach_cloud ok
Home Assistant Supervisor
host_os Home Assistant OS 12.3
update_channel stable
supervisor_version supervisor-2024.05.1
agent_version 1.6.0
docker_version 25.0.5
disk_total 28.5 GB
disk_used 6.0 GB
healthy true
supported true
board rpi4-64
supervisor_api ok
version_api ok
installed_addons Terminal & SSH (9.14.0), Studio Code Server (5.15.0)
Dashboards
dashboards 4
resources 7
views 4
mode storage
Recorder
oldest_recorder_run May 8, 2024 at 5:18 PM
current_recorder_run May 17, 2024 at 11:45 PM
estimated_db_size 34.96 MiB
database_engine sqlite
database_version 3.44.2

Checklist

  • [X] I have enabled debug logging for my installation.
  • [X] I have filled out the issue template to the best of my ability.
  • [X] This issue only contains 1 issue (if you have multiple issues, open one issue for each issue).
  • [X] This issue is not a duplicate issue of currently previous issues..

Describe the issue

chime_tts was erroring for me when using the google_cloud platform when the cache is enabled.

Here is the action step that is part of my automation:

       - service: chime_tts.say
          data:
            cache: true
            chime_path: mario_coin
            message: testing testing one two three
            offset: 450
            tts_platform: google_cloud
          target:
            entity_id: media_player.office_speaker

I debugged on and off for a couple of days before looking at the full chime logs and found that the error occurred right after "Checking Chime TTS audio cache". I commented out the cache line and it all worked.

The following error/traceback is what I see in the logs for the issue:

Error executing script. Unexpected error for parallel at pos 1: 'NoneType' object has no attribute 'get'
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 501, in _async_step
    await getattr(self, handler)()
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 736, in _async_call_service_step
    response_data = await self._async_run_long_action(
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 699, in _async_run_long_action
    return await long_task
           ^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2738, in async_call
    response_data = await coro
                    ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2779, in _execute_service
    return await target(service_call)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/chime_tts/__init__.py", line 116, in async_say
    result = await queue.add_to_queue(async_say_execute, service, is_say_url)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/chime_tts/queue_manager.py", line 33, in async_process_queue
    result = await asyncio.wait_for(
             ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/asyncio/tasks.py", line 520, in wait_for
    return await fut
           ^^^^^^^^^
  File "/config/custom_components/chime_tts/__init__.py", line 138, in async_say_execute
    audio_dict = await async_get_playback_audio_path(params, options)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/chime_tts/__init__.py", line 716, in async_get_playback_audio_path
    audio_dict = await async_get_cached_audio_data(hass, filepath_hash)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/chime_tts/__init__.py", line 1287, in async_get_cached_audio_data
    audio_dict = await async_retrieve_data(hass, filepath_hash)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/chime_tts/__init__.py", line 1267, in async_retrieve_data
    return _data[DATA_STORAGE_KEY].get(key, None)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'get'

I've only really starting working to customize homeassistant for a month now, so it is entirely possible I am missing something as far as where the cache is being stored, but I haven't been able to figure it out from the chime_tts nor general homeassistant docs.

Reproduction steps

  1. Create a script or automation with chime_tts and include the cache: true data property

...

Debug logs

2024-05-18 21:13:01.635 WARNING (SyncWorker_2) [homeassistant.loader] We found a custom integration chime_tts which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2024-05-18 21:13:10.443 DEBUG (ImportExecutor_0) [custom_components.chime_tts.queue_manager] Queue reset
2024-05-18 21:13:10.450 WARNING (MainThread) [homeassistant.util.loop] Detected blocking call to import_module with args ('custom_components.chime_tts',) in /usr/src/homeassistant/homeassistant/loader.py, line 1041: ComponentProtocol, importlib.import_module(self.pkg_path) inside the event loop
2024-05-18 21:13:10.454 DEBUG (MainThread) [custom_components.chime_tts.queue_manager] Queue reset
2024-05-18 21:13:10.456 INFO (MainThread) [custom_components.chime_tts] The Chime TTS integration is set up.
2024-05-18 21:13:10.457 DEBUG (MainThread) [custom_components.chime_tts] Chime TTS Configuration Values:
2024-05-18 21:13:10.457 DEBUG (MainThread) [custom_components.chime_tts] - queue_timeout: 60
2024-05-18 21:13:10.457 DEBUG (MainThread) [custom_components.chime_tts] - tts_platform_key: ''
2024-05-18 21:13:10.457 DEBUG (MainThread) [custom_components.chime_tts] - offset: 0
2024-05-18 21:13:10.458 DEBUG (MainThread) [custom_components.chime_tts] - temp_chimes_path: '/media/sounds/temp/chime_tts/chimes/'
2024-05-18 21:13:10.458 DEBUG (MainThread) [custom_components.chime_tts] - temp_path: '/media/sounds/temp/chime_tts/'
2024-05-18 21:13:10.458 DEBUG (MainThread) [custom_components.chime_tts] - www_path: '/config/www/chime_tts/'
2024-05-18 21:13:10.458 DEBUG (MainThread) [custom_components.chime_tts] - media_dir: 'local'
2024-05-18 21:13:10.458 DEBUG (MainThread) [custom_components.chime_tts] - custom_paths:
2024-05-18 21:13:10.458 DEBUG (MainThread) [custom_components.chime_tts] - custom_chime_path_1:
2024-05-18 21:13:10.458 DEBUG (MainThread) [custom_components.chime_tts] - custom_chime_path_2:
2024-05-18 21:13:10.458 DEBUG (MainThread) [custom_components.chime_tts] - custom_chime_path_3:
2024-05-18 21:13:10.458 DEBUG (MainThread) [custom_components.chime_tts] - custom_chime_path_4:
2024-05-18 21:13:10.458 DEBUG (MainThread) [custom_components.chime_tts] - custom_chime_path_5:
2024-05-18 21:13:10.463 WARNING (MainThread) [py.warnings] /usr/local/lib/python3.12/asyncio/base_events.py:1989: RuntimeWarning: coroutine 'ChimeTTSQueueManager.queue_processor' was never awaited
2024-05-18 21:14:00.408 DEBUG (MainThread) [custom_components.chime_tts] ----- Chime TTS Say Called. Version v1.0.0 -----
2024-05-18 21:14:00.409 DEBUG (MainThread) [custom_components.chime_tts.queue_manager] Adding service call to queue
2024-05-18 21:14:00.447 DEBUG (MainThread) [custom_components.chime_tts.helpers.media_player]  players found: [{'entity_id': 'media_player.office_speaker', 'should_change_volume': False, 'initial_volume_level': 0.07000000029802322, 'group_members_supported': False, 'announce_supported': False, 'resume_media_player': True}]
2024-05-18 21:14:00.448 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] ----- General Parameters -----
2024-05-18 21:14:00.448 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] * entity_ids = ['media_player.office_speaker']
2024-05-18 21:14:00.449 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] * chime_path = mario_coin
2024-05-18 21:14:00.449 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] * cache = True
2024-05-18 21:14:00.449 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] * offset = 450.0
2024-05-18 21:14:00.449 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] * final_delay = 450.0
2024-05-18 21:14:00.450 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] * message = testing testing one two three
2024-05-18 21:14:00.450 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] * tts_platform = google_cloud
2024-05-18 21:14:00.450 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] * tts_speed = 100.0
2024-05-18 21:14:00.450 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] * tts_pitch = 0
2024-05-18 21:14:00.450 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] * announce = False
2024-05-18 21:14:00.451 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] * volume_level = -1.0
2024-05-18 21:14:00.451 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] * join_players = False
2024-05-18 21:14:00.451 DEBUG (MainThread) [custom_components.chime_tts.helpers.helpers] * unjoin_players = False
2024-05-18 21:14:00.452 DEBUG (MainThread) [custom_components.chime_tts] *** Checking Chime TTS audio cache ***
File "/config/custom_components/chime_tts/__init__.py", line 116, in async_say
File "/config/custom_components/chime_tts/queue_manager.py", line 33, in async_process_queue
File "/config/custom_components/chime_tts/__init__.py", line 138, in async_say_execute
File "/config/custom_components/chime_tts/__init__.py", line 716, in async_get_playback_audio_path
File "/config/custom_components/chime_tts/__init__.py", line 1287, in async_get_cached_audio_data
File "/config/custom_components/chime_tts/__init__.py", line 1267, in async_retrieve_data
File "/config/custom_components/chime_tts/__init__.py", line 116, in async_say
File "/config/custom_components/chime_tts/queue_manager.py", line 33, in async_process_queue
File "/config/custom_components/chime_tts/__init__.py", line 138, in async_say_execute
File "/config/custom_components/chime_tts/__init__.py", line 716, in async_get_playback_audio_path
File "/config/custom_components/chime_tts/__init__.py", line 1287, in async_get_cached_audio_data
File "/config/custom_components/chime_tts/__init__.py", line 1267, in async_retrieve_data

Diagnostics dump

No response

hsteckylf avatar May 19 '24 01:05 hsteckylf