Check if there is any primary connection available before accessing this connections parameter. Otherwise Plinth will raise an exception because of non existing object.