# How to read and Set the logic variables with HomeyScript?

**URL:** <https://community.homey.app/t/how-to-read-and-set-the-logic-variables-with-homeyscript/14520>\
**Category:** Apps\
**Created:** [June 17, 2019, 2:04pm UTC](https://community.homey.app/t/how-to-read-and-set-the-logic-variables-with-homeyscript/14520 "2019-06-17T14:04:56Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![tfoldi](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/tfoldi/32/78325_2.png) [@tfoldi](https://community.homey.app/u/tfoldi)\
**Post date:** [June 9, 2023, 9:18am UTC](https://community.homey.app/t/how-to-read-and-set-the-logic-variables-with-homeyscript/14520/5 "2023-06-09T09:18:45Z")

</div>

If you want to look up a variable by name instead of id, you can use lodash like:

```auto
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"}}) 

```

---

_[View the full topic](https://community.homey.app/t/how-to-read-and-set-the-logic-variables-with-homeyscript/14520)._
