Lovelace button - tap_action to call 2 or more services

Hello,

struggling with starting 2 or more services. I want to achieve that when I press a button in lovelace to restart home assistant (not the server but HA) prior in doing that disable my pihole for 5min).
Having a button to do that (pause pihole) already works well, but I want to put it in a sequence/script.

It works when I want to use a button with one service call. But when I want to punt in 2 service call it can’t.

So I decided to use a script but when I call the script is says failed to call service script/name…

This is what I am using:
Lovelace glancecard:

entities:
  - entity: zone.home
    icon: 'mdi:restart'
    name: PiHole 5m - Home Assistant
    tap_action:
      action: call-service
      service: script.restart_ha_incl_pihole_5min
show_name: true
show_state: false
type: glance

Scripts.yaml (which turns green, no errors?)

'restart_ha_incl_pihole_5min':
  sequence:
  - service: pi_hole.disable
    service_data:
     duration: '00:05:00'
  - delay:
      seconds: 1
  -	service: homeassistant.restart
	 service_data:
     entity_id: zone.home

These log errors:
2020-02-13 10:31:44 ERROR (SyncWorker_8) [homeassistant.util.yaml.loader] while scanning for the next token found character ‘\t’ that cannot start any token in “/config/scripts.yaml”, line 8, column 1 2020-02-13 10:31:44 ERROR (MainThread) [homeassistant.components.script] while scanning for the next token found character ‘\t’ that cannot start any token in “/config/scripts.yaml”, line 8, column 1
2020-02-13 10:32:49 ERROR (SyncWorker_3) [homeassistant.util.yaml.loader] while scanning for the next token found character ‘\t’ that cannot start any token in “/config/scripts.yaml”, line 8, column 1 2020-02-13 10:32:49 ERROR (MainThread) [homeassistant.components.script] while scanning for the next token found character ‘\t’ that cannot start any token in “/config/scripts.yaml”, line 8, column 1 2020-02-13 10:34:36 ERROR (SyncWorker_9) [homeassistant.util.yaml.loader] while scanning for the next token found character ‘\t’ that cannot start any token in “/config/scripts.yaml”, line 8, column 1 2020-02-13 10:34:36 ERROR (MainThread) [homeassistant.components.script] while scanning for the next token found character ‘\t’ that cannot start any token in “/config/scripts.yaml”, line 8, column 1 2020-02-13 10:34:43 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection.140468706477072] Error handling message: expected dict for dictionary value @ data[‘service_data’]. Got ‘script.disablepiholefor5minanrestarthass’ 2020-02-13 10:35:00 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection.140468706477072] Error handling message: expected dict for dictionary value @ data[‘service_data’]. Got ‘script.disablepiholefor5minanrestarthass’ 2020-02-13 10:35:04 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection.140468706477072] Error handling message: expected dict for dictionary value @ data[‘service_data’]. Got ‘script.disablepiholefor5minanrestarthass’ 2020-02-13 10:35:08 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection.140468706477072] Error handling message: expected dict for dictionary value @ data[‘service_data’]. Got ‘script.disablepiholefor5minanrestarthass’ 2020-02-13 10:37:04 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved

Your script is wrong in multiple places, the name of of the script shouldn’t be surrounded by quotes. Your indentation is wrong for the last service. You have an entity zone.home in the last service where you restart home assistant, why? Doesn’t make any sense to me.

Your script should look something like this:

restart_ha_incl_pihole_5min:
  sequence:
    - service: pi_hole.disable
      data:
        duration: '00:05:00'
    - delay:
        seconds: 1
    - service: homeassistant.restart

Hi Burningstone,

why? Haha, I tried a lot of things and found multiple place on the forum suggestion quotes there, had tried with and without. I copy-pasted all together to just try if it works…

Now I have:

restart_ha_incl_pihole_5min:
  sequence:
  - service: pi_hole.disable
    data:
     duration: '00:05:00'
  - delay:
      seconds: 1
  -	service: homeassistant.restart

which turns also green :slight_smile:

I get error on reloaD:
Error loading /config/configuration.yaml: while scanning for the next token
found character ‘\t’ that cannot start any token
in “/config/scripts.yaml”, line 8, column 4

But I still get:

image

EDIT: the forum gives that bad indentation, this is mine:
image

In line 8, remove the gap between “-” and “service” and replace it with a space.
The error says that there is a “tab” ("/t") character in there but it should be a normal white space.

Yes!

How could I have ever found out that form myself? :rofl:

Thank you!

The tab probably got there through copying examples from somewhere.

If you take a look at your screenshot, you see that in all other places is a dot between “-” and “service”, except for the last line there it is a line and not a dot, meaning it is a tab and not a whitespace.