Integration with C# application

Hi All,
I have my own home automation made on Arduino modules and computer with C# application.
In my home automation I don’t have an extensive UI, so I wanted to use Home Assistant as the UI.

At first I wanted to create a switch that would control one of the lights. Based on the video
Use the REST Component to Add A Shelly Switch To Home Assistant
I created a server that accepts the command http://192.168.1.11:9000/Light?turn=on. Using the web browser or Postman everything works fine in my app - the light goes on and off. Unfortunately, I have a problem with the configuration on the HA side.

In the /config/configuration.yaml file I add:

switch:
  - platform: rest
    name: "Test_Lamp1"
    scan_interval: 4
    resource: http://192.168.1.11:9000/Light
    body_on: 'turn=on'
    body_off: 'turn=off'
    is_on_template: '{{ value_json.ison == true}}'
    headers:
     content-type: application/x-www-form-urlencoded

light:
 - platform: switch
   name: Lampa pierwsza
   entity_id: switch.Test_Lamp1

When I add this entity to daschboard the switch is inactive.
image
What I am doing wrong?

Entity names are always lowercase, and will be converted that way from the name, so try “switch.test_lamp1” (check that’s what it is in Dev Tools). Note sure if that’s the issue though - maybe have a look in the logs.

However, the UI can now change a switch to a light - under “Settings > Devices & Services > Helpers > Create Helper > Change device type of a switch”. Therefore you wouldn’t need this definition in config.

It does not help me.
In my C# application (server) now I responds for request http://192.168.1.11:9000/Light. My response for this request contain json node

{
   "ison": true
}

Now my switch is active and show correct state of light.

The problem is when I want to change the state of light using switch on HA UI.
My server get the same request like in case of scan. I was hope that the request will be like:
http://192.168.1.11:9000/Light?turn=on
or
http://192.168.1.11:9000/Light?turn=off
Instead of above I get the http://192.168.1.11:9000/Light independently if I switch on or off.

Works!
Switch HA sends a POST request with body_on content as a Stream. After I read the InputStream i have got a string “turn=on”.