If you want to look up a variable by name instead of id, you can use lodash like:
const vars = await Homey.logic.getVariables();
const myVar = _.find(vars, (o) => o.name === "Variable name");
log(`Changed switch is ${myVar.value}`)
await Homey.logic.updateVariable({id: myVar.id, variable: {value: "foo"}})