Help with value template for RESTful sensor

I’m attempting to connect another Raspberry Pi (HASS is on Pi #1). Pi #2 is running webiopi as a previous garage automation system. I have REST set up on Pi#2, and I’m able to pull the data, but webiopi REST only returns a value of 1/0 for pin state, not JSON.
I’m able to pull the value in using value_template: ‘{{ value }}’`, but the value is inverted (because the pin pulls low to turn on the attached devices, so returns a “0” for on). I’ve tried multiple attempts to template the value to flip 1 to 0 and 0 to 1, but have had no success. I also attempted to template a sensor using the primary REST sensor as the source, but it the template sensor ignores the first. I’d live some help if anyone has ideas. Alternatively, does anyone have better ideas on how to connect webiopi to HA? pi-aREST is a pain in the but for what I’m trying to do (no covers), and requires a second service to be running, whereas webiopi has REST built in, with authentication.

Code block:

  • platform: rest
    resource: http://:8000/garage/frontlight
    authentication: basic
    method: GET
    name: GarageFrontLightREST
    password: nope
    sensor_class: light
    value_template: ‘{{ value }}’
    username: nope

  • platform: rest
    resource: http://:8000/garage/backlight
    authentication: basic
    method: GET
    name: GarageBackLightREST
    password: nope
    sensor_class: light
    value_template: ‘{{ value }}’
    username: nope

  • platform: template
    sensors:
    garage_front_light:
    entity_id: binary_sensor.garagefrontlightrest
    sensor_class: light
    value_template: ‘{% if is_state(“binary_sensor.garagefrontlightrest”, “off”) %}on{% else %}off{% endif %}’
    garage_back_light:
    entity_id: binary_sensor.garagebacklightrest
    sensor_class: light
    value_template: ‘{% if is_state(“binary_sensor.garagebacklightrest”, “off”) %}on{% else %}off{% endif %}’