Transfer the URL via automation

Hi there,

I have living area fan. I can control this by calling a URL.
Eg “192.168.0.100/?power=on” switches on such a device.

How can I incorporate this command into an automation (preferably via the user interface)? If possible, the URL should only be called in the background, so I don’t have to close it. The call is sufficient to execute the switching command.

LG Werner

Hallo,

ich habe dezentrale Wohnraumlüfter. Diese kann ich per URL-Aufruf steuern.
Z.B. schaltet “192.168.0.100/?power=on” so ein Gerät ein.

Wie kann ich diesen Befehl in eine Automation einbauen (am liebsten per Benutzeroberfläche)? Die URL soll möglichst nur im Hintergrund aufgerufen werden, so muss ich diese nicht schließen. Zum ausführen des Schaltbefehls genügt der Aufruf.

LG Werner

I would create a command line switch and have it curl the URL: Command line Switch - Home Assistant

You could also create RESTful command, which your can then call from your automation using the rest.your_command service: RESTful Command - Home Assistant

1 Like

Vielen Dank.
Das werde ich bald testen und melde mich dann wieder.

Thanks very much.
I’ll test that soon and then get back to you.

Hi there,

I have now tried to create the code and insert it into configuration.yaml.
My code now looks like this:

switch:
  - platform: command_line
    switches:
      arest_pin_four:
        command_on: "/usr/bin/curl -X GET http://192.168.178.72/?power=on"
        command_off: "/usr/bin/curl -X GET http://192.168.178.72/?power=off"
        value_template: '{{ value == "1" }}'
        friendly_name: Lüfter

Unfortunately, the following message appears in the file editor:

duplicated mapping key at line 89, column -297:
    switch:
    ^

Am a beginner.
Hope for help where the error lies.

Greetings Werner

Hallo,

ich habe jetzt versucht den Code zu erstellen und in configuration.yaml einzufügen.
Mein Code sieht nun so aus:

switch:
  - platform: command_line
    switches:
      arest_pin_four:
        command_on: "/usr/bin/curl -X GET http://192.168.178.72/?power=on"
        command_off: "/usr/bin/curl -X GET http://192.168.178.72/?power=off"
        value_template: '{{ value == "1" }}'
        friendly_name: Lüfter

Leider kommt im Fileeditor folgende Meldung:

duplicated mapping key at line 89, column -297:
    switch:
    ^

Bin Anfänger.
Hoffe auf Hilfe wo der Fehler liegt.

Gruss Werner

That error suggests that you have switch: twice in your configuration.yaml. You should only have one section that starts with switch:, combine them or delete the other one if it is empty.

1 Like

Hi there,

Thanks alot. That was the mistake.
Now it works fine.
I am looking forward to your help.

Thanks.

Greetings Werner

Hallo,

vielen, vielen Dank. Das war der Fehler.
Jetzt funktioniert es einwandfrei.
Ich freue mich über Deine Hilfe.

Danke.

Gruß Werner

hi folks, i have a similar problem:

i am running my HA in a docker container on a synology.
on a raspi í am running a wiring pi + aircontrol installation for my warema blinds.

i can move my blinds via http:

http://xxx.xxx.xxx.xxx:8083/JS/Run/system(‘sudo aircontrol -t w0_1u’) for down
http://xxx.xxx.xxx.xxx:8083/JS/Run/system('sudo aircontrol -t w0_1o‘) for up
http://xxx.xxx.xxx.xxx:8083/JS/Run/system('sudo aircontrol -t w0_1s‘) for stop

everything is running fine.

now i want to integrate my blinds into HA.

i tried the COMMAND_LINE switch, but it didn´t work. nothing happens, also nothing in the log:

  - platform: command_line
    switches:
      raffstore:
        command_on: "/usr/bin/curl -X GET http://xxx.xxx.xxx.xxx:8083/JS/Run/system('sudo aircontrol -t w0_1u')"
        command_off: "/usr/bin/curl -X GET http://xxx.xxx.xxx.xxx:8083/JS/Run/system('sudo aircontrol -t w0_1o')"
        friendly_name: Raffstore Küche

where is my mistake or is there a different approach to success?

greetings

iflowmac

Try running the command from terminal (if you are running HA in a container, use the terminal for the HA container). You may get error messages that give you useful information.

I would assume that you can probably just use curl, instead of usr/bin/curl, but this will obviously depend on your setup.

thanks for yor advice, i´m gonna try…