# How do I use the Driver#ready() method in SDKv3

**URL:** <https://community.homey.app/t/how-do-i-use-the-driver-ready-method-in-sdkv3/71280>\
**Category:** Developers\
**Tags:** homey-pro\
**Created:** [October 27, 2022, 4:58pm UTC](https://community.homey.app/t/how-do-i-use-the-driver-ready-method-in-sdkv3/71280 "2022-10-27T16:58:50Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ChrisG](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/chrisg/32/8825_2.png) [@ChrisG](https://community.homey.app/u/ChrisG)\
**Post date:** [October 27, 2022, 4:58pm UTC](https://community.homey.app/t/how-do-i-use-the-driver-ready-method-in-sdkv3/71280/1 "2022-10-27T16:58:50Z")

</div>

I have come on Slack on no solution, many maybe someone can help me here

I want to use the Driver method [ready()](https://apps-sdk-v3.developer.homey.app/Driver.html#ready), which is executed according to the documentation when onInit() is finished. Unfortunately it does not work as I expect because it is called several times.

Does anyone have a code example for me?

**My test example:**

```auto
module.exports = class Driver extends Homey.Driver {

  onInit(options = {}) {
    this.debug('onInit()');
  }

  ready() {
    return Promise.resolve('Success')
      .then(this.log('Driver ready'));
  }

module.exports = class DingzDriver extends Driver {

  onInit(options = {}) {
    super.onInit(options);
    this.http = new Http(this.homey);
  }

```

**Log:**

```auto
[log] 2022-10-27 07:51:40 [DingzApp] dingzX app - v1.1.3 is running...
[log] 2022-10-27 07:51:41 [DingzApp] DingzDriver > Driver ready
[log] 2022-10-27 07:51:41 [DingzApp] DingzDriver > Driver ready
[log] 2022-10-27 07:51:41 [DingzApp] [DEBUG] DingzDriver > onInit()
[log] 2022-10-27 07:51:41 [DingzApp] [DEBUG] ### > HttpAPI API has been inited - undefined

```

**Expected:**

```auto
[log] 2022-10-27 07:51:40 [DingzApp] dingzX app - v1.1.3 is running...
[log] 2022-10-27 07:51:41 [DingzApp] [DEBUG] DingzDriver > onInit()
[log] 2022-10-27 07:51:41 [DingzApp] [DEBUG] ### > HttpAPI API has been inited - undefined
[log] 2022-10-27 07:51:41 [DingzApp] DingzDriver > Driver ready

```

BDW: This also applies to the Device#ready() method.

THX Chris

---

<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:** [October 27, 2022, 5:52pm UTC](https://community.homey.app/t/how-do-i-use-the-driver-ready-method-in-sdkv3/71280/2 "2022-10-27T17:52:48Z")

</div>

@Jero wrote on Slack: _“you should not override ready() you can await this.ready() somewhere in your code to respond to it”_

Can you explain what exactly you want to achieve? Perhaps there are solutions that don’t require using `ready()` (or at least not in the way you’re trying to use it now).

---

<div class="post-metadata">

**Author:** ![ChrisG](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/chrisg/32/8825_2.png) [@ChrisG](https://community.homey.app/u/ChrisG)\
**Post date:** [October 28, 2022, 6:40am UTC](https://community.homey.app/t/how-do-i-use-the-driver-ready-method-in-sdkv3/71280/3 "2022-10-28T06:40:43Z")

</div>

Good morning,

As I understand it, the ready() method is a hook that is called when the onInit() method has been executed. And that’s how it’s implemented, ready() is not overridden, it’s just defined in the base class.

**Baseclass** :

```auto
  ready() {
    return Promise.resolve(this.deviceReady());
  }

  async deviceReady() {
    try {
      await this.setAvailable();
      await this.getDeviceValues();
      this.log('Device ready');
    } catch {}
  }

```

**Subclass**

```auto
async deviceReady() {
    try {
      super.deviceReady();

      const dingzDevice = await this.getDingzDevice();
      await this.initMotionDetector(dingzDevice);
      await this.initDingzSensors();
      this.updateSettingLabels();
    } catch {}
  }

```

---

<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:** [October 28, 2022, 9:07am UTC](https://community.homey.app/t/how-do-i-use-the-driver-ready-method-in-sdkv3/71280/4 "2022-10-28T09:07:35Z")

</div>

It’s not a hook, it returns a promise that you can use as a sort-of hook. That promise will be resolved when `onInit` has been executed.

Also, you _are_ overriding it because it’s declared in `Homey.Driver` and you’re overriding it in your subclass.

It’s still not clear to me what you’re trying to do though. If you want to call the `deviceReady` method after `onInit` has been run, just call it explicitly:

```auto
async onInit() {
  ...
  await this.deviceReady();
}

```
