Using a switch to call a service

Okay, I’m having a bit of a dilemma and I don’t know if it is possible.
I am currently trying to setup a switch to call a specific service, so what I want to do is, setup a switch in home assistant to call the service to reboot my Huawei B618 router.
Is it possible? everything I have tried seems to end in a error of some sorts.

Thanks in advance :slight_smile:

How are you rebooting the router? What service do you have available?

You can put the service into the script and call the service that way.

A template switch could also work

You can use the momentary switch by defining your momentary switch and then you can use it in an automation.

I’m using it

  • to start my car heater (shell command -> HTTP2SMS)
  • to reconnect my router (service call)

Okay, having a look at the integration on the Hassio page it shows that the Service Huawei_LTE.Reboot is used to reboot the router, and if I manually call the service in my HASSIO instance then it works. Just not sure how to add a “switch” to call the service.
With regards to the script route, I will give that a shot and try it, however I am very much a novice a home assistant, but will give it a bash.

Here’s what I use on a Glance Card to call a script:

          - entity: binary_sensor.xbox_one_s
            name: XBox One S
            icon: mdi:xbox-controller
            tap_action:
              action: call-service
              service: script.xbox_one_s_toggle

If you need the switch only in the UI then you can do something like this

entity: zone.home
hold_action:
  action: none
icon: 'mdi:restart'
name: Restart Router
show_icon: true
show_name: true
tap_action:
  action: call-service
  service: xxxxxxxxxxx
type: entity-button

the “zone.home” is only used as dummy (you can use any other entity)

MarH, frikkin brilliant, its exactly what I was looking for :smiley:

1 Like

Also just for interest sake, is it possible to add it to and existing entities card? or will this have to be done on its own card entirely?

not with the entity-button, but with the momentary switch or with the script …

script:
  reboot_router:
    sequence:
      - service: xxxxx

image

Figured as much :slight_smile: will use your solution above for now and play around with the other 2 suggestions a bit. thanx a mil