# Missing\_scopes when using Homey.zigBee.runCommand

**URL:** <https://community.homey.app/t/missing-scopes-when-using-homey-zigbee-runcommand/72211>\
**Category:** Developers\
**Tags:** zigbee, homeyscript\
**Created:** [November 15, 2022, 7:07pm UTC](https://community.homey.app/t/missing-scopes-when-using-homey-zigbee-runcommand/72211 "2022-11-15T19:07:19Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kevin010](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/kevin010/32/9761_2.png) [@Kevin010](https://community.homey.app/u/Kevin010)\
**Post date:** [November 15, 2022, 7:07pm UTC](https://community.homey.app/t/missing-scopes-when-using-homey-zigbee-runcommand/72211/1 "2022-11-15T19:07:19Z")

</div>

I want to have a HomeyScript running every x minutes, that will check if all Router devices in my zigbee mesh are still online. Some smart bulbs still have a standard wallswitch in place that just cuts the power. Until they’re all replaced by smart switches, my better half sometimes forgets not to use them… and gone is my Router…😃

So i created this HomeyScript that will send me a push notification when a router device is no longer online. However, this only works after i manually refresh the ZigBee network from the developer/zigbee tools page. That way, the status changes to online = false in the Homey.zigBee.getState() result.

So, to refresh the network from script, i tried using:  
`await Homey.zigBee.runCommand({command: 'UPDATE_NODES', opts: undefined})`

But that throws me a missing\_scopes error, telling me not enough permissions to do this…

Any ideas on how to make this work? Can i elevate permissions or is there another way to refresh the zigbee mesh state?

---

<div class="post-metadata">

**Author:** ![Caseda](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/caseda/32/138695_2.png) [@Caseda](https://community.homey.app/u/Caseda)\
**Post date:** [November 15, 2022, 7:18pm UTC](https://community.homey.app/t/missing-scopes-when-using-homey-zigbee-runcommand/72211/2 "2022-11-15T19:18:34Z")

</div>

> [@Kevin010](#):
>
> Any ideas on how to make this work? Can i elevate permissions or is there another way to refresh the zigbee mesh state?

With the current permissions HomeyScript has this will never work, and I think Athom won’t add any additional either, you can always try to ask them of course, but I only give it a very very small chance to it happening.

---

<div class="post-metadata">

**Author:** ![Peter\_Kawa](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/peter_kawa/32/173848_2.png) [@Peter\_Kawa](https://community.homey.app/u/Peter_Kawa)\
**Post date:** [November 15, 2022, 10:30pm UTC](https://community.homey.app/t/missing-scopes-when-using-homey-zigbee-runcommand/72211/3 "2022-11-15T22:30:06Z")

</div>

Maybe this is of any use

> [@The Flow Exchange(r) - Exchange Your Flows with Others!](https://community.homey.app/t/the-flow-exchange-r-exchange-your-flows-with-others/68981/13):
>
> Sensor (or any device) Connection Check. Sometimes, you’ll discover a sensor or other device doesn’t report it’s status or value anymore, but it does NOT notify you of being offline… Well, this flow checks the, most recent update time of your sensors. You can run the flow every day, twice a day, just add or remove a time triggercard. The ‘inactive time’ can be edited as well (24hrs as default) and you can choose to not send notifications when all sensors did report inside the ‘inactive time…

---

<div class="post-metadata">

**Author:** ![Kevin010](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/kevin010/32/9761_2.png) [@Kevin010](https://community.homey.app/u/Kevin010)\
**Post date:** [November 16, 2022, 7:17pm UTC](https://community.homey.app/t/missing-scopes-when-using-homey-zigbee-runcommand/72211/4 "2022-11-16T19:17:59Z")

</div>

Hej @Peter_Kawa , thanks for your suggestion.  
Although this is very interesting for checking on my sensors, checking the Homey.devices however wont work for this situation, because a zigbee Router device (not a motion sensor, but e.g. a lightbulb) can easily be unused for several hours, so i cannot determine it is offline just by looking at the last reporting datetime. I want to know when the router has been removed from my zigbee mesh network by accidental power cut (from using wallswitch).

The AVD however seems very powerfull. Any idea if i can run HomeyScript with elevated permissions from there maybe?

---

<div class="post-metadata">

**Author:** ![Peter\_Kawa](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/peter_kawa/32/173848_2.png) [@Peter\_Kawa](https://community.homey.app/u/Peter_Kawa)\
**Post date:** [November 17, 2022, 1:51am UTC](https://community.homey.app/t/missing-scopes-when-using-homey-zigbee-runcommand/72211/5 "2022-11-17T01:51:01Z")

</div>

YW!  
Yeah the script is aimed at sensors which ‘at random’ stop sending changes.  
I think HomeyScript has the same permissions on Homey, where-ever you use it.

The web-api playground however, seems to have more permissions. But that is only useful for manually running some code.

Here’s a ‘bad route’ detection script which might be of any use:

> [@\[Community Survey\] Homey v5 ZigBee Health check and statistics collection (HomeyScript)](https://community.homey.app/t/community-survey-homey-v5-zigbee-health-check-and-statistics-collection-homeyscript/44231):
>
> Hi Guys, With the ZigBee improvements in Homey Firmware v5 and reading about all tips for building and fixing a good ZigBee mesh network I wanted to know how big ZigBee Meshes grow on Homey and how Happy the Homey users are with it. To collect all Data I ask you to run a [HomeyScript](https://homey.app/en-gb/app/com.athom.homeyscript/HomeyScript/) on your Homey V5 and report back some results here. The script is placed on my Github as it is to large for here. For copying the script to HomeyScript you can better open it [RAW here!](https://raw.githubusercontent.com/Dijker/nu.Dijker.UnseenHomeyScripts/master/ZigBeeHealth.js) How to run the script: I…

---

<div class="post-metadata">

**Author:** ![Kevin010](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/kevin010/32/9761_2.png) [@Kevin010](https://community.homey.app/u/Kevin010)\
**Post date:** [November 13, 2023, 3:00pm UTC](https://community.homey.app/t/missing-scopes-when-using-homey-zigbee-runcommand/72211/6 "2023-11-13T15:00:33Z")

</div>

A year has passed, trying to give this a go again.  
Since the HomeyScript doesn’t have enough permissions, my goal is now to build a Homey App.

But the ManagerZigbee isn’t exposing a runCommand method.  
Anyone knows, how to turn this HomeyScript:

`await Homey.zigBee.runCommand({command: 'UPDATE_NODES', opts: undefined});`

into something like this for a homey app?

```auto
import Homey from 'homey';

class MyApp extends Homey.App {

  async onInit() {
    await this.homey.zigbee.runCommand({command: 'UPDATE_NODES', opts: undefined});
  }

}

module.exports = MyApp;

```

Compiler now says NO:  
`error TS2339: Property 'runCommand' does not exist on type 'ManagerZigBee'.`

All i want to do is refresh by Zigbee mesh automatically every 24hours…shouldn’t be that hard

---

<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:** [November 13, 2023, 3:27pm UTC](https://community.homey.app/t/missing-scopes-when-using-homey-zigbee-runcommand/72211/7 "2023-11-13T15:27:21Z")

</div>

> [@Kevin010](#):
>
> into something like this for a homey app?

Won’t do you much good, the app still won’t have the correct scopes:

```auto
CreateClientError: Missing Scopes HomeyAPIError: Missing Scopes

```
