MycroftAI / skill-homeassistant

Mycroft Skill/Integration for Homeassistant
GNU Lesser General Public License v3.0
115 stars 62 forks source link

Add items to shopping list results in error when HA doesn't have the shopping list integration configured #120

Open Ramblurr opened 1 year ago

Ramblurr commented 1 year ago

Describe the bug

Ask mycroft to add something to the shopping list when connected to an HA instance that doesn't have the Shopping List integration. You will get 'An error occurred while processing a request in Home Assistant Skill'

To Reproduce Steps to reproduce the behavior:

  1. "Add onions to the shopping list
  2. -> 'An error occurred while processing a request in Home Assistant Skill'

Expected behavior

It should report a nice error, perhaps telling me that I need to configure the shopping list integration in HA>

Log files

Dec 25 12:08:58 localhost.localdomain python[2864]: INFO:mycroft.util.log:Padatious match: {'name': 'homeassistant.mark2:add.item.shopping.list.intent', 'sent': ['add', 'onions', 'to', 'the', 'shopping', 'list'], 'matches': {'entity': 'onions', 'utterance': 'add onions to the shopping list'}, 'conf': 1.0}
Dec 25 12:08:58 localhost.localdomain python[2864]: DEBUG:mycroft.util.log:Exit handle utterance
Dec 25 12:08:58 localhost.localdomain python[2929]: DEBUG:homeassistant.mark2:Handling homeassistant.mark2:add.item.shopping.list.intent with skill homeassistant.mark2 (session=67368b6b-6270-49a4-b56e-bfca08d0d01e)
Dec 25 12:08:58 localhost.localdomain python[2929]: DEBUG:homeassistant.mark2:Add onions to the shoping list
Dec 25 12:08:58 localhost.localdomain python[2929]: DEBUG:urllib3.connectionpool:Starting new HTTP connection (1): 10.9.4.25:8123
Dec 25 12:08:58 localhost.localdomain python[2861]: DEBUG:mycroft.util.log:Loading audio file: /opt/mycroft-dinkum/shared/mycroft/res/snd/acknowledge.wav
Dec 25 12:08:58 localhost.localdomain python[2929]: DEBUG:urllib3.connectionpool:http://10.9.4.25:8123 "POST /api/services/shopping_list/add_item HTTP/1.1" 400 16
Dec 25 12:08:58 localhost.localdomain python[2929]: ERROR:mycroft.util.log:Error in intent handler: homeassistant.mark2:add.item.shopping.list.intent
Dec 25 12:08:58 localhost.localdomain python[2929]: Traceback (most recent call last):
Dec 25 12:08:58 localhost.localdomain python[2929]:   File "/opt/mycroft-dinkum/shared/mycroft/skills/mycroft_skill/mycroft_skill.py", line 685, in _handle_intent
Dec 25 12:08:58 localhost.localdomain python[2929]:     result_message = handler(message)
Dec 25 12:08:58 localhost.localdomain python[2929]:   File "/opt/mycroft-dinkum/skills/homeassistant.mark2/__init__.py", line 317, in handle_shopping_list_intent
Dec 25 12:08:58 localhost.localdomain python[2929]:     return self._handle_shopping_list(message)
Dec 25 12:08:58 localhost.localdomain python[2929]:   File "/opt/mycroft-dinkum/skills/homeassistant.mark2/__init__.py", line 477, in _handle_shopping_list
Dec 25 12:08:58 localhost.localdomain python[2929]:     self.ha_client.execute_service("shopping_list", "add_item", ha_data)
Dec 25 12:08:58 localhost.localdomain python[2929]:   File "/opt/mycroft-dinkum/skills/homeassistant.mark2/ha_client.py", line 283, in execute_service
Dec 25 12:08:58 localhost.localdomain python[2929]:     req.raise_for_status()
Dec 25 12:08:58 localhost.localdomain python[2929]:   File "/opt/mycroft-dinkum/.venv/lib/python3.8/site-packages/requests/models.py", line 960, in raise_for_status
Dec 25 12:08:58 localhost.localdomain python[2929]:     raise HTTPError(http_error_msg, response=self)
Dec 25 12:08:58 localhost.localdomain python[2929]: requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: http://10.9.4.25:8123/api/services/shopping_list/add_item
Dec 25 12:08:58 localhost.localdomain python[2929]: WARNING:mycroft.util.log:Missing template file: skill.error
Dec 25 12:08:58 localhost.localdomain python[2861]: INFO:mycroft.util.log:Played sound: file:///opt/mycroft-dinkum/shared/mycroft/res/snd/acknowledge.wav
Dec 25 12:08:58 localhost.localdomain python[2864]: DEBUG:mycroft.util.log:Starting session: b5b1c845-dc32-49a2-823a-83cffab763cf
Dec 25 12:08:58 localhost.localdomain python[2864]: DEBUG:mycroft.util.log:Completed action for session b5b1c845-dc32-49a2-823a-83cffab763cf: SpeakAction(utterance='An error occurred while processing a request in Home Assistant Skill', dialog='skill.error', wait=True)
Dec 25 12:08:58 localhost.localdomain python[2861]: DEBUG:audio:Speak for session 'b5b1c845-dc32-49a2-823a-83cffab763cf': An error occurred while processing a request in Home Assistant Skill (cache=False)
Dec 25 12:08:58 localhost.localdomain python[2864]: DEBUG:mycroft.util.log:Requested session end: 67368b6b-6270-49a4-b56e-bfca08d0d01e
Dec 25 12:08:58 localhost.localdomain python[2861]: DEBUG:audio:Segments: ['An error occurred while processing a request in Home Assistant Skill']

Environment (please complete the following information):