Switch current state

Hi! I have a device based on ESPeasy, which I control through “simple” URL such as:
http://192.168.0.10/control?cmd=GPIO,13,1 (switch on)
It works like a charm with many environment (Apple command, domoticz, ifttt, …)

The only problem I have is with HA (installed on a Raspberry) because I cannot get the current status. For example if I switch it on with domoticz, on HA it should be set as ON.

This is the portion of the configuration.yaml

  • platform: command_line
    switches:
    lampada:
    command_on: ‘curl -k “http://192.168.0.10/control?cmd=GPIO,13,1”’
    command_off: ‘curl -k “…GPIO,13,0”’
    command_state: ‘./test.sh’
    value_template: ‘{{ value == “1” }}’
    friendly_name: Lampada

where test.sh is simply:
curl -k --silent “http://192.168.0.10/control?cmd=Status,GPIO,13” | grep ‘state’ | sed 's/^.: //’*

I used grep and sed because otherwise the output will be:
{
“log”: “”,
“plugin”: 1,
“pin”: 13,
“mode”: “output”,
“state”: 1
}

Now, the state will be 1 (ON) or 0 (OFF) if I grep and sed.
I thought it was perfect!
I was wrong…

the icon is a “slide”, I switch it ON but it goes back to off (the state is still 1, the lamp is still on) and however the current status cannot be retrieved at all

do you have any suggestion?
thanks!

solved in this way:

- platform: command_line
    switches:
      lampada:
        command_on: 'curl -k "http://192.168.0.10/control?cmd=GPIO,13,1"'
        command_off: 'curl -k "http://192.168.0.10/control?cmd=GPIO,13,0"'
        command_state: 'curl -k "http://192.168.0.10/control?cmd=Status,GPIO,13" '
        value_template: "{{ '\"state\": 1' in value }}"
        friendly_name: Lampada