Multiple command on switch using curl?

Hi,
I’m using heater controller (Ouman EH-800) that can be controlled using http-commands. It requires authentication using http, but it doesn’t use common
http://username:[email protected]?and then some commands ,
instead one must send first command like below for authentication:
http://192.168.1.80/login?uid=username;pwd=password;
and after that one can send actual commands using separate http-commands. For example, water mixing valve is set to manual control at position 10 using command
http://192.168.1.80/update?S_59_85=6;S_92_85=10

Of course, it will timeout after certain amount of time. Settings and values don’t need to be accessed often, so timeout is not problem.

I’m thinking about making switch, using curl, and including first authentication http and after that, actual http-command for parameters I want adjust. Is it possible to make switch, that has always two line for on and off functions, namely authentication first and after that, actual on/off? Or should I pipe authentication and control commands?

And yet another question, EH-800 controller sends responses in file I’m not interested in. Authentication response, for example is simple text file containing OK for succesful authentication. Can these response files just be discarded by sending them to /dev/null ? Normallym when accessing using web browser, browser automatically suggests saving those files, depending on file settings of course.

And of course, if there’s better way, I’m always interested in implementing it. Most of my hardware does MQTT and some of these functions of EH-800 could be controlled using relays (eg. MQTT+Tasmota), but that seems bit excessive measure, when there is already software for it.

I did check out REST-api, but didn’t find out anything suitable for this two command situation.

I don’t think I follow what you want to achieve with the switch, but for the rest you can create a shell command to send your commands. Create a shell script to do the auth etc. and call that script from HA.

If you want to read things, you can use a command line sensor (again creating a shell script that you invoke here).

Thanks,
I created shell commands in my config.yaml and they seem to work. One for authentication, and then separate commands for reading and setting values. Still one problem…

Contrary to what I wrote earlier, device sends values always in file, not as webpage. How can I save this file for reading values? If I can specify its location (name is always same), file-integration could be used for creating sensor (with template, if required)? Scraping is not possible, since there is no webpage to access.

Current shell scripts are:
shell_command:
ouman_logon: 'curl "http://192.168.1.211:8090/login?uid=user;pwd=password;"' #logon
ouman_ltp_kotona: 'curl "http://192.168.1.211:8090/update?S_135_85=0;"' #home, set default temp
ouman_ltp_poissa: 'curl "http://192.168.1.211:8090/update?S_135_85=2;"' #away, set temp drop
ouman_menovesi_kierto: 'curl "http://192.168.1.211:8090/request?S_259_85"' #current water temp
ouman_menovesi_pyynto: 'curl "http://192.168.1.211:8090/request?S_275_85"' #requested water temp`

Do you mean that when you open a URL in your browser you get a file? In HTTP world, there’s really no difference between getting HTML, JSON, XML or CSV as a file, stream or simple response (I’m simplifying). There’s typically just a header that tells the browser to save it as a file (or whatever else to do with it), but the requestor doesn’t need to respect that. Using curl you need to tell it to save a file, or you will redirect the output to a file (curl -o ..., or curl ... > /some/file.json). My point is: Using one of the REST platforms will probably still work (if the parsing of the output isn’t too complex) and you don’t need to go via an intermediary file, but you could if you want to. What does this output typically look like?