Lovelace entity-button to restart HASS - what's wrong?

I want to have entity-button in Lovelace that restarts the HASS. I have created a script like this:

script:
  hass_restart:
    alias: Restart Home Assistant
    sequence:
    - service: homeassistant.restart

And in ui-lovelace.yaml I have added:

  - type: glance
    show_state: false
    entities:
      - script.hass_restart

  - type: entity-button
    tap_action: call_service
    entity: script.hass_restart
    service: script.turn_on
    icon: mdi:restart 

The glance is working as intended: it shows info and allows me to press execute to restart the HASS instance. The entity-button is doing absolutely nothing. I have compared it to some examples from the Web but nothing helped me solve this problem. What’s wrong?

Edit: Changed service: script.run to service: script.turn_on as this is what I have in my config. It still does not work.

I think the service should be script.turn_on

  - type: entity-button
    tap_action: call_service
    entity: script.hass_restart
    service: script.turn_on
    icon: mdi:restart 

or

  - type: entity-button
    tap_action: call_service
    entity: script.hass_restart
    service: script.hass_restart
    icon: mdi:restart 

@martamoonpie @petro my bad, I had script.turn_on from the beginning, I just pasted one of my attempts to fix it.
@petro script.hass_restart is not working as well :frowning:

Try just turn_on for the service. I’m using toggle for the tap action on a light and just having toggle worked while light.toggle did not.

then try the actual service: homeassistant.restart

This did not work:

  - type: entity-button
    tap_action: call_service
    entity: script.hass_restart
    service: turn_on
    icon: mdi:restart

Unfortunately, it does not work: Entity not available homeassistant.restart.

@petro @martamoonpie Thank you very much for your help. I have just realized that I had underscore instead of a dash in call-service. I was pretty sure that I copied the syntax, guess I was wrong. Sorry for trouble :blush:

Whelp, that explains why none of these methods worked. BTW they all should have worked.

1 Like

In case someone is looking, my working configuration for this looks like below

  - type: entity-button
    name: Restart Homeassistant
    tap_action: 
      action: call-service
      service: script.toggle
      service_data:
        entity_id: script.hass_restart
    entity: script.hass_restart
    color: auto
    icon: mdi:restart

Yes, this whole thread is outdated. Around 0.84 - 0.85, the configuration of tap_action changed. This whole thread is the configuration prior to that change.

Hi petro, so do you have any idea how this would work now, in the current version?

yeah,

  - type: entity-button
    entity_id: script.hass_restart
    tap_action: 
      action: call-service
      service: script.hass_restart
    icon: mdi:restart 
1 Like

Thanks, petro, I created a working one in the mean time too. Just adding it as a reference for others. I used a glance card for it.

entities:
  - entity: zone.home
    icon: 'mdi:restart'
    name: Lovelace
    tap_action:
      action: call-service
      service: frontend.reload_themes
  - entity: zone.home
    icon: 'mdi:restart'
    name: Home Assistant
    tap_action:
      action: call-service
      service: homeassistant.restart
  - entity: zone.home
    icon: 'mdi:restart'
    name: Server
    tap_action:
      action: call-service
      service: hassio.host_reboot
show_name: true
show_state: false
type: glance

Result:
image
The entity is actually something random, because it is required, but it doesn’t seem to matter (except for the icon, but this is adjustable anyway).

7 Likes