fix the initial state for gpio toggles when accessing through api

apply the before render function to toggles before returning, otherwise the initial state of toggles is wrong.