# Device CapabilitiesObj in HomeyScript stays the same value when triggered in a flow

**URL:** https://community.homey.app/t/device-capabilitiesobj-in-homeyscript-stays-the-same-value-when-triggered-in-a-flow/14529
**Category:** Developers
**Created:** [June 17, 2019, 5:48pm UTC](https://community.homey.app/t/device-capabilitiesobj-in-homeyscript-stays-the-same-value-when-triggered-in-a-flow/14529 "2019-06-17T17:48:11Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![eelco2k](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/eelco2k/32/12766_2.png) [@eelco2k](https://community.homey.app/u/eelco2k)
#### Post date: [June 17, 2019, 5:48pm UTC](https://community.homey.app/t/device-capabilitiesobj-in-homeyscript-stays-the-same-value-when-triggered-in-a-flow/14529/1 "2019-06-17T17:48:11Z")

</div>

I have a problem with constantly updated values from a device which i’m trying to get in a script.

```
var device_data = await Homey.devices.getDevice({ id: '45f27858-c506-4d3c-a800-1954d803e3e3' });

console.log(device_data);

```

When i “Save & Test” in homeyScript the data is constantly updated, more specific the capabilitiesObj

```
 capabilitiesObj: 
{ measure_power: 
   { value: 498,
    lastUpdated: '2019-06-17T17:41:16.803Z',
    type: 'number',
    getable: true,
    setable: false,
    title: 'Energie',
    desc: 'Vermogen in Watt (W)',
    units: 'W',
    decimals: 2,
    chartType: 'stepLine',
    id: 'measure_power',
    options: {},
    values: undefined },
 meter_offPeak: 

```

etc…

but then i use the script in a flow to execute (flow executes every time the powermeter changes) I constantly get “Cached” values (it looks like it)

so the value: 498 stays every flow execution the same.

Any ideas?

---

<div class="post-metadata">

### Author: ![Rocodamelshekima](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/rocodamelshekima/32/8209_2.png) [@Rocodamelshekima](https://community.homey.app/u/Rocodamelshekima)
#### Post date: [June 17, 2019, 5:57pm UTC](https://community.homey.app/t/device-capabilitiesobj-in-homeyscript-stays-the-same-value-when-triggered-in-a-flow/14529/2 "2019-06-17T17:57:56Z")

</div>

Moved to developers.

---

<div class="post-metadata">

### Author: ![robertklep](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/robertklep/32/160628_2.png) [@robertklep](https://community.homey.app/u/robertklep)
#### Post date: [June 17, 2019, 7:12pm UTC](https://community.homey.app/t/device-capabilitiesobj-in-homeyscript-stays-the-same-value-when-triggered-in-a-flow/14529/3 "2019-06-17T19:12:22Z")

</div>

Looks like you need a workaround:

```auto
const device = await Homey.devices.getDevice({ id: '45f27858-c506-4d3c-a800-1954d803e3e3' });
const cap = device.makeCapabilityInstance('measure_power');

console.log(cap.value);

```

I think it has to do with lazy evaluation, where capability values are only updated when explicitly required.

---

<div class="post-metadata">

### Author: ![eelco2k](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/eelco2k/32/12766_2.png) [@eelco2k](https://community.homey.app/u/eelco2k)
#### Post date: [June 18, 2019, 4:48pm UTC](https://community.homey.app/t/device-capabilitiesobj-in-homeyscript-stays-the-same-value-when-triggered-in-a-flow/14529/4 "2019-06-18T16:48:22Z")

</div>

Thanks! @robertklep, i’ve also found another way: via the insights api. because (luckily) the data is also put into the insights.

I will try this method as well!

---

<div class="post-metadata">

### Author: ![Torch1969](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/torch1969/32/33305_2.png) [@Torch1969](https://community.homey.app/u/Torch1969)
#### Post date: [April 3, 2021, 3:21pm UTC](https://community.homey.app/t/device-capabilitiesobj-in-homeyscript-stays-the-same-value-when-triggered-in-a-flow/14529/5 "2021-04-03T15:21:10Z")

</div>

I guess the solution brought to us here should do the trick also?

> [@Homeyscript functionality](https://community.homey.app/t/homeyscript-functionality/30066/13):
>
> I posted the question on GitHub as well and this is Jeroen Wienk’s answer. I thought good to share here because “there are many ways to do this’ grinning and because as Jeroen mentioned values are cached and he gives the solution to circumvent this. It’s possible with the API but it’s not a very clear solution since the values are cached. But you can do this; await tag('my-tag', false); // value is false console.log(await Homey.flowToken.getFlowToken({ uri: 'homey:app:com.athom.homeysc…

So with **$skipCache: true**  
`const device = await Homey.devices.getDevice({$skipCache: true, id: '45f27858-c506-4d3c-a800-1954d803e3e3' }); console.log(device.capabilitiesObj.measure_power.value); `

---

<div class="post-metadata">

### Author: ![robertklep](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/robertklep/32/160628_2.png) [@robertklep](https://community.homey.app/u/robertklep)
#### Post date: [April 3, 2021, 6:05pm UTC](https://community.homey.app/t/device-capabilitiesobj-in-homeyscript-stays-the-same-value-when-triggered-in-a-flow/14529/6 "2021-04-03T18:05:17Z")

</div>

Possibly.
