Wemo Light Switch Issues

Lately my Wemo Light Switches wouldn’t update it’s state after I turn it on or off. After digging into the code, found an issue in the parse() function:

    else if (body?.Body?.SetBinaryStateResponse?.BinaryState?.text())
    {
    	log.trace "Got SetBinaryStateResponse = ${body?.Body?.SetBinaryStateResponse?.BinaryState?.text()}"
    }

should be:

    else if (body?.Body?.SetBinaryStateResponse?.BinaryState?.text())
    {
        def value = body?.Body?.SetBinaryStateResponse?.BinaryState?.text().toInteger() == 1 ? "on" : "off"
    	log.trace "Got SetBinaryStateResponse = ${value}"
        result << createEvent(name: "switch", value: value)
    }

Essentially what happens is that if you do a set (i.e. turn the light on or off), it goes into that particular else and then won’t do anything. The fix is to do a createEvent based on the response. After this my light switches update their state correctly.