custom-components / grocy

Custom Grocy integration for Home Assistant
Apache License 2.0
162 stars 50 forks source link

service grocy.add_generic can not be used in automation #76

Closed denko81 closed 4 years ago

denko81 commented 4 years ago

When I use the developer tools the following it is ok

entity_type: tasks data: name: This is a task due_date: "2020-08-20" category_id: "1" assigned_to_user_id: "2"

But when I create a new automation with following

It is showing the following eror

Invalid config for [automation]: [entity_type] is an invalid option for [automation]. Check: automation->action->0->entity_type.

isabellaalstrom commented 4 years ago

Try with entity_type beneath data_template.


service: grocy.add_generic
data_template:
  entity_type: tasks
  name: Obrisati prašinu u kuhinji | Damma i köket
  due_date: '{{ now().date() }}'
  category_id: "1"
  assigned_to_user_id: "2"
denko81 commented 4 years ago

then I get this error `Logger: homeassistant.components.automation.dals_morning_weekends Source: custom_components/grocy/init.py:195 Integration: Automation (documentation, issues) First occurred: 23:33:09 (2 occurrences) Last logged: 23:33:09

DALS morning weekends: Error executing script. Unexpected error for call_service at pos 1: 'data' While executing automation automation.dals_morning_weekends Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 191, in _async_step await getattr( File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 380, in _async_call_service_step await service_task File "/usr/src/homeassistant/homeassistant/core.py", line 1308, in async_call task.result() File "/usr/src/homeassistant/homeassistant/core.py", line 1345, in _execute_service handler.func(service_call) File "/config/custom_components/grocy/init.py", line 195, in handle_add_generic data = call.data["data"] KeyError: 'data'`

isabellaalstrom commented 4 years ago

It's the template. The integration seems to not be able to handla data_template. I will look into how to fix that.

denko81 commented 4 years ago

I don't think it is. I have tried with this code : - service: grocy.add_generic data: entity_type: tasks name: Obrisati prašinu u kuhinji | Damma i köket due_date: '2020-08-20' category_id: "1" assigned_to_user_id: "2"

And I'm getting this error :

DALS morning weekends: Error executing script. Unexpected error for call_service at pos 1: 'data' While executing automation automation.dals_morning_weekends Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 191, in _async_step await getattr( File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 380, in _async_call_service_step await service_task File "/usr/src/homeassistant/homeassistant/core.py", line 1308, in async_call task.result() File "/usr/src/homeassistant/homeassistant/core.py", line 1345, in _execute_service handler.func(service_call) File "/config/custom_components/grocy/__init__.py", line 195, in handle_add_generic data = call.data["data"] KeyError: 'data'

isabellaalstrom commented 4 years ago

Beta for 2.0 is out. I would be very happy if you could download it and check if the issue persists, and also if everything else is still working as expected. To download a beta via Hacs, if you haven't before, press the tre dots at the integration and choose reinstall, then you can choose to show beta releases.