Is it possible to run a http url on the local HA machine (RPi)?

Hi,

I have a webcam server running on my home network. I need to be able to send a local http command on the server to reset the camera server when it stops working. I have a Tap action button set up in the UI which allows me to run the url but only on the client machine where I active the button. This does not work on all clients as I have some firewalll issues when I do that on my work PC.
So ideally im looking to run the command locally from the RPi…any help or advise please.

type: custom:button-card
name: Restart Cam Server
tap_action:
  action: url
  url_path: >-
    http://myDNS:8083/axis-cgi/admin/restart.cgi?&user=<myusername>&pwd=<mypassword>

You’re looking for a RESTfull command

1 Like

A little hijack but really on topic and it might help: I would like to do something similar and have tried this but cannot get it to work.

I have a RPi (not my HA) that I have to reboot sometimes.
If I do that from a browser, this is the URL to do so: http://172.16.0.23/cgi-bin/main.cgi?ACTION=reboot

This is what I tried:

rest_command:
  reboot_rpi:
    url: "http://172.16.0.23/cgi-bin/main.cgi"
    method: put
    content_type: "application/x-www-form-urlencoded"
    payload: "ACTION=reboot"

Also tried:

...
url: "http://172.16.0.23/cgi-bin/main.cgi?ACTION=reboot"
...

Hi Nick,

This is my HA restart automation:

alias: "SYSTEM: Restart Home Assistant"
description: ""
trigger:
  - platform: time
    at: "09:30:00"
  - platform: time
    at: "23:00:00"
condition: []
action:
  - service: homeassistant.restart
    data: {}
mode: single

And from the ui with a custom button card:

type: custom:button-card
name: Restart HA
tap_action:
  action: call-service
  service: homeassistant.restart
icon: mdi:power
color: rgb(255, 0, 0)
lock:
  enabled: true
  color: black

I used a custom button card so that it can have a button lock on it…requires a double tap to actually activate the button and restart the HA

But to get the rest full command to work I made a “reset_webcam_server.yaml” file with this:

rest_command:
  reset_webcam_server:
    url: "http://192.168.100.210:8083/axis-cgi/admin/restart.cgi?&user=admin&pwd=mypassword"

Then I used a time automation to operate it:

alias: "CAMERAS: Reset Webcam Server at 06:00 daily"
description: ""
trigger:
  - platform: time
    at: "06:00:00"
condition: []
action:
  - service: rest_command.reset_webcam_server
    data: {}
mode: single

1 Like