Help with Command Line - HTTP Get Request to Phoenix Contact SPS

Hello together,
I am brand new with home assistant and I need some help to understand how it works.
As mentioned above i would like integrate my Phoenix Contact ILC SPS into Home Assistant. I did the same 5 years ago with IP Symcon and some PHP Scripts but now i want change to home assistant.
I think it should not be so complicated because you can easily change or read a value from the SPS with a simple HTTP Get Request.

HTTP Get Request to Read:
“httyp://IP-Adress-SPS/cgi-bin/ReadVal.exe?Variablename”

HTTP Get Request to Write:
“httyp://IP-Adress-SPS/cgi-bin/WriteVal.exe?Variablename+NewValue”

Example Write:
“httyp://192.168.1.152/cgi-bin/WriteVal.exe?WOHNEN.WOH_LICHT_COUCHV+1”
This would switch on the Light “Couch”.

“httyp://192.168.1.152/cgi-bin/WriteVal.exe?WOHNEN.WOH_LICHT_COUCHV+0”
This would switch off the Light “Couch”.

“httyp://192.168.1.152/cgi-bin/ReadVal.exe?WOHNEN.WOH_LICHT_COUCHA”
This would read the actual status of the variable from the SPS.
This is important, because I could also switch the light On/OFF (change the status) with a real hardware push-button.

What would be the right way to switch the light ON/OFF and also get the actual status from the SPS? Is a command_line_switch the right way? How could i get the actual status and how can i set it to the switch in HA? Is it possible to use a template for the variable name, maybe i could use the name or the entity_id?

This is what i did in the configurations.yaml:

switch:
  - platform: command_line
    switches:
      wohnen_licht_couch:
        friendly_name: "Couch-Licht"
        command_on: curl -s http://192.168.1.152/cgi-bin/writeVal.exe?WOHNEN.WOH_LICHT_COUCHV+1
        command_off: curl -s http://192.168.1.152/cgi-bin/writeVal.exe?WOHNEN.WOH_LICHT_COUCHV+0

Wäre dies eine Lösung?

Many thanks for your response and time, I really appreciate this…

Best regards
Daniel