Passing parameters to call_service

Hi,

I’m currently using a Home Assistant automation to start zoned cleaning for my vacuum. This works well, but as complexity of my automation has increased, I’m looking at moving the automation to AppDaemon. However, I have problems starting the zoned cleaning from AppDaemon.

My Home Assistant automation looks like this:

- id: '1606947922478'
  alias: Vaskehjelpa - entrance
  description: ''
  trigger: []
  condition: []
  action:
  - service: vacuum.send_command
    data:
      command: zoned_cleanup
      entity_id: vacuum.vaskehjelpa
      params:
        zone_ids:
        - entrance
    entity_id: vacuum.vaskehjelpa
  mode: single

The AppDaemon code to start zoned cleanup looks like this:

self.call_service("vacuum/send_command", command="zoned_cleanup", entity_id="vacuum.vaskehjelpa")

I’ve tried several versions of the params part of the, but I always get some kind of errors. Like this version:

     self.call_service("vacuum/send_command", command="zoned_cleanup", entity_id="vacuum.vaskehjelpa", params='{"zone_ids": ["entrance"]}')

which throws the following error message:

2020-12-06 16:56:26.034563 WARNING HASS: Error calling Home Assistant service default/vacuum/send_command
2020-12-06 16:56:26.035620 WARNING HASS: Code: 500, error: 500 Internal Server Error
Server got itself in trouble

Can anyone help me write this correctly?

Thanks!

Hi @frankiboy1,

This is how I would do it:

self.call_service(
    "vacuum/send_command",
    entity_id="vacuum.vaskehjelpa",
    command="zoned_cleanup",
    params={
      "zone_ids": ["entrance"]
    }
)

Regards,
Xavi M.

Thanks a lot, @xaviml!

Not sure why I didn’t find the solution. I thought I tried exactly this, but I obviously did something wrong. It’s working as I expected now. :+1:

1 Like