HTTP controlled switch not working

I could really use help here.

I have a HTTP controllable light and I am trying to make it work in home assistant. So I added following in configuration.yaml:

rest_command:    
	sw_toggle:
        url: http://10.39.10.14/api/relay/0?secret=52124E81
	
switch:
  - platform: template
    switches:
      sw_light:
        friendly_name: "XLight"
        value_template: '{{value | int == 1}}'
        turn_on:
          service: rest_command.sw_toggle
        turn_off:
          service: rest_command.sw_toggle

Calling service rest_command.sw_toggle from developer tools does toggles the switch and returns 1 or 0 as response (1 for turned on). However , when I load this config, my switch is always shown as Unavailable.

What am I doing wrong?

Where does the value| int == 1 come from,?

I wrote it, thinking that it would evaluate response from service call and return True or False.
I use similar construct successfully when using rest calls for is_on_template.

Do I use it incorrectly here?

So, to answer my own question, it worked with the following changes:

rest_command:    
	sw_toggle:
        url: http://10.39.10.14/api/relay/0?secret=52124E81&cmd=toggle

sensor:	
    - platform: rest
      name: sw_light_state
      resource: http://10.39.10.14/api/relay/0?secret=52124E81
      value_template: '{{ value | int }}'
      scan_interval: 10  

switch:
  - platform: template
    switches:
      sw_light:
        friendly_name: "XLight"
        value_template: {{ is_state('sensor.sw_light_state', '1') }}"
        turn_on:
          - service: rest_command.sw_toggle
          - service: homeassistant.update_entity
               target:
                  entity_id: sensor.sw_light_state
        turn_off:
          - service: rest_command.sw_toggle
          - service: homeassistant.update_entity
               target:
                  entity_id: sensor.sw_light_state