I found that running the status payload was returning binary characters, adjusting cmd_print_plug_relay_state() to the following strips it out (added tr -cd '\11\12\15\40-\176'):
output=send_to_plug $ip $port "$payload_query" | decode | tr -cd '\11\12\15\40-\176' | egrep -o 'relay_state":[0,1]' | egrep -o '[0,1]'