Error running service from Automation


I’m trying to call a certain service from automation and it doesn’t work.

My Automation:

- id: '1597432951135'
  alias: New TEST Automation
  description: ''
  - entity_id: input_number.boiler_timer
    from: '0.0'
    platform: state
  condition: []
  - data:
      message: Boiler on
    service: notify.mobile_app_mi_a1
  - data_template:
      entity_id: 'switch.switcher_kis_boiler'
      timer_minutes: '{{states(''input_number.boiler_timer'')|int}}'
    service: switcher_kis.turn_on_with_timer

Im getting that error in the Log:

Logger: homeassistant.components.automation
Source: helpers/
Integration: Automation ([documentation](, [issues](
First occurred: 2:37:13 PM (2 occurrences)
Last logged: 2:39:11 PM

New TEST Automation: Error executing script. Unauthorized for call_service at pos 2: UnknownUser

Running HassOS 4.8

When running in automation actions other services that comes with HA such as “switch.turn_on” all works fine.

What am I missing?

This is not a home assistant service:

    service: switcher_kis.turn_on_with_timer

Thanks Tom,

Is there a way to run it from an automation?


Run what?

It isn’t a thing.

If you go to developer tools, services, select switcher_kis.turn_on_with_timer from the list, and click ‘call service’. What do you get ?

1 Like

Huh. Well there you go. Learn something new every day.

Hi Francis,

When calling the service from the developer tab, all works as expected.

Also, when adding it to a script, it does run as expected, but, when calling this script from automation it still doesn’t work from the same reason…

Any ideas?

Try it like this:

  - service: switcher_kis.turn_on_with_timer
    entity_id: switch.switcher_kis_boiler
      timer_minutes: "{{states('input_number.boiler_timer')|int}}"

Thanks Tom,

Now I’m getting that error:
New TEST Automation: Error executing script. Invalid data for call_service at pos 2: value should be a string for dictionary value @ data['entity_id']
tried to add quotes but still same error

now my automation action looks like this:

  - service: switcher_kis.turn_on_with_timer
    entity_id: 'switch.switcher_kis_boiler'
      timer_minutes: "{{states('input_number.boiler_timer')|int}}"

Thanks for the help so far

I don’t think it should matter but try taking the single quotes from around the entity_id.

  - service: switcher_kis.turn_on_with_timer
    entity_id: switch.switcher_kis_boiler
      timer_minutes: "{{states('input_number.boiler_timer')|int}}"

Hi Tom,

That didn’t help.
Maybe that error log will help to figure out:

## Log Details (ERROR)

Logger: homeassistant.components.automation.new_test_automation
Source: components/switcher_kis/
Integration: Automation ([documentation](, [issues](
First occurred: 12:08:41 PM (1 occurrences)
Last logged: 12:08:41 PM

While executing automation automation.new_test_automation

Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/components/automation/", line 430, in async_trigger await self.action_script.async_run(variables, trigger_context) File "/usr/src/homeassistant/homeassistant/helpers/", line 802, in async_run await asyncio.shield(run.async_run()) File "/usr/src/homeassistant/homeassistant/helpers/", line 183, in async_run await self._async_step(log_exceptions=False) File "/usr/src/homeassistant/homeassistant/helpers/", line 191, in _async_step await getattr( File "/usr/src/homeassistant/homeassistant/helpers/", line 380, in _async_call_service_step await service_task File "/usr/src/homeassistant/homeassistant/", line 1308, in async_call task.result() File "/usr/src/homeassistant/homeassistant/", line 1343, in _execute_service await handler.func(service_call) File "/usr/src/homeassistant/homeassistant/components/switcher_kis/", line 143, in async_turn_on_with_timer_service await _validate_edit_permission( File "/usr/src/homeassistant/homeassistant/components/switcher_kis/", line 91, in _validate_edit_permission raise UnknownUser(context=context, entity_id=entity_id, permission=POLICY_EDIT) homeassistant.exceptions.UnknownUser: UnknownUser

Hi Ran,
There is a validation in the code that is preventing from a script to run the switcher_kis services.
I have created a pull request with a code change to allow turn_on_with_timer from a script and hope it will be approved soon

Hi Yinonco,

Thanks a lot.
I will follow-up on that.


Ran, @rans
Did you solve this? How?

I happen to have the same issue with switch.switcher_kis_boiler.
The script is running perfectly from the UI but fails with the same error when I run it from the automation.

I’m tired of cold showers, it will be a great help if you can share your solution :snowflake:


You mention that there is a validation in the code preventing from a script to run the switcher_kis service.
The thing is, that it does run from a script when I execute the script from the UI, but it fails if automation is trying to execute the script.

Is it the same issue that you pull request solves?

Can you please update if the PR is approved?
Can you please share a link to the PR?


Here is the PR link
I’m still tracking it as well…
Hope it will be merged soon. :crossed_fingers:

Thanks, Ran!
It seems that this issue was solved in a different manner by @thecode and was approved 4 days ago.
This is the PR link:

It is now in home-assistant:dev branch, I’m not sure what is the deployment cycle, I guess it is a short way to master.

Thanks, Ran @yinonco @thecode your contribution is highly appreciated!

It will be in the next Home Assistant version, 2021.2.0, planned to be released on 03-FEB.

1 Like

That’s great news, thanks!

1 Like