How to make a switch that sends command to a web interface

I apologise in advance if this seems trivial. I have spent several days trying to solve this problem, and I have read various Home Assistant help documents. I have only been using Home Assistant for a week or so, and I have no programming experience.

What I am looking to do is to switch on relays which have a web server built in. I can do this easily by typing into the address bar of Google Chrome eg
if I type xxxx://192.168.1.4/30000/01 it will switch relay1 on
if I type xxxx://192.168.1.4/30000/00 it will switch relay1 off.

(hopefully you can guess what xxxx is - the forum didn’t like me typing it there as I’m a new member)

I have tried writing command line instructions (based on Home Assistant documentation examples), I have tried using telnet similarly - both in the configuration YAML, and I also tried to get a template working. All unsuccessful.

I think I need to put something like this into the configuration YAML:

switch:

but a) I can’t find the switch anywhere to add to the Home Assistant display and b) I don’t think it works. I wondered whether I should be using a template or using a shell commmand, but most of this stuff is beyond my knowledge at the moment. Would be great to be able to get something to work then I could experiment and improve it, but I’m not even off first base!

That is an outdated format that is no longer valid. Please see the example lower down on this page:

configurration.yaml

command_line:
  - switch:
      name: Relay switch
      command_on: "curl -k 'http://192.168.1.4/30000/01'"
      command_off: "curl -k 'http://192.168.1.4/30000/00'"

Also in future please format your pasted config correctly for the forum. See https://community.home-assistant.io/t/how-to-help-us-help-you-or-how-to-ask-a-good-question/114371#oneone-format-it-properly-16 or https://community.home-assistant.io/t/how-to-format-your-code-in-forum-posts/702762

1 Like

Thankyou - all working now!