How to implement command_line reboot

HI,

Id like to create a switch or script for rebooting my Zwave hub.
I have plenty switches i can switch on /off through the command_line switch https://home-assistant.io/components/switch.command_line/ but they need on and off commands, and a state.
this is done through:

command_on: >-
        curl -X POST -d '{"seq":1, "method":"object_prop_set", "arguments":{"oid":"7b4d9b1b", "prop":"command", "value":"on"}}' http://192.168.xxx.xxxiungo/api_request

Rebooting is done by calling the method fw_sys_reboot, so would be something like below i guess?:

command_on: >-
curl -X POST -d ‘{“seq”:1, “method”:“fw_sys_reboot” }’ http://192.168.xxx.xxx/iungo/api_request

since this isnt an ‘on’ command in the above sense, i fear it wouldn’t be the correct way of implementing. Could you please help me find the best (and safest) way.

Im thinking of ‘locking’ the switch through customizing it with confirm_controls_show_lock: true and displaying on my developer page, which is only shown when in developer mode.

not sure whether this should be a script or switch, or yet some other tool available in HA.

Thanks,
Marius

yes, i saw that, but couldnt find the translation of the curl command into this?

Or would it be as simple as this?:

shell_command:
  reboot_iungo_zwave_hub: 'curl -X POST -d ‘{“seq”:1, “method”:“fw_sys_reboot” }’ http://192.168.xxx.xxx/iungo/api_request'

or would a restful-command https://home-assistant.io/components/rest_command/ be better (since it uses the method and ip address:

rest_command:
  reboot_iungo_zwave_hub:
    url: ipaddress/iungo/api/request
    method: fw_sys_reboot

Because the command has ' and ", you’ll need to format it a little different.

shell_command:
  reboot_iungo_zwave_hub: >-
    curl -X POST -d '{"seq":1, "method":"object_prop_set", "arguments":{"oid":"7b4d9b1b", "prop":"command", "value":"on"}}' http://192.168.xxx.xxxiungo/api_request

Yes, you could use that too. It’d be something like this:

rest_command:
  reboot_iungo_zwave_hub:
    url: http://192.168.xxx.xxx/iungo/api_request
    method: post
    payload: '{ "seq":1, "method":"fw_sys_reboot" }'
1 Like

please forgive my misunderstanding but wouldn’t it be like this then:

shell_command:
  reboot_iungo_zwave_hub: >-
    curl -X POST -d '{"seq":1, "method":"fw_sys_reboot", }' http://192.168.xxx.xxxiungo/api_request

i ask because the method is no more an object setting or getting, nor for a dedicated object-id, but for the system, called by another method?

your rest_command rewrite does reflect that.

btw, ive been meaning to ask, what does the seq:1 mean? is that an order of commands?

is there any preference for either of them? maybe security or other consideration?

Yeah. I copied the wrong part of your post in my reply.

Not sure. Check with your hub manufacturer for an explanation on that one.

The rest one should perform slightly better because it runs natively in python and doesn’t have to launch curl.

1 Like

lol. i thought you handed that to me in the original search for mqtt sensors and command_line switches… :wink:

created them and put them in a safe place. will see if they do their job safely, thanks