# How to use Device::onSettings()?

**URL:** <https://community.homey.app/t/how-to-use-device-onsettings/122093>\
**Category:** Developers\
**Tags:** app\
**Created:** [November 29, 2024, 11:13pm UTC](https://community.homey.app/t/how-to-use-device-onsettings/122093 "2024-11-29T23:13:08Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jarl](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/jarl/32/16576_2.png) [@Jarl](https://community.homey.app/u/Jarl)\
**Post date:** [November 29, 2024, 11:13pm UTC](https://community.homey.app/t/how-to-use-device-onsettings/122093/1 "2024-11-29T23:13:08Z")

</div>

Hi,  
I’m looking for a code example on how to read a settings value from the newSettings object parameter in the Device::onSettings() function. I have defined a “checkbox” type setting in the driver.settings.compose.json file. I can see that the settings key+value are in the newSettings object (using “this.log(newSettings)”), but I can’t figure out how to read the actual value from the object in my device code. Probably because I don’t fully get TypeScript…

Do I need to change the onSettings() function definition (compared to the code in [Settings | Homey Apps SDK](https://apps.developer.homey.app/the-basics/devices/settings)) in my project to indicate object type of the newSettings parameter?

“homey app build” just fails with:  
_error TS2339: Property ‘abc’ does not exist on type ‘{}’._  
when I in my onSettings() try to call  
_this.log(newSettings.abc)"_

Thanks!

---

<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 30, 2024, 5:51am UTC](https://community.homey.app/t/how-to-use-device-onsettings/122093/2 "2024-11-30T05:51:46Z")

</div>

This is how the method is defined if you use `homey app driver create`:

```auto
  async onSettings({
    oldSettings,
    newSettings,
    changedKeys,
  }: {
    oldSettings: { [key: string]: boolean | string | number | undefined | null };
    newSettings: { [key: string]: boolean | string | number | undefined | null };
    changedKeys: string[];
  }): Promise<string | void> {
    this.log("MyDevice settings where changed");
  }

```

---

<div class="post-metadata">

**Author:** ![Jarl](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/jarl/32/16576_2.png) [@Jarl](https://community.homey.app/u/Jarl)\
**Post date:** [November 30, 2024, 3:56pm UTC](https://community.homey.app/t/how-to-use-device-onsettings/122093/3 "2024-11-30T15:56:44Z")

</div>

Thanks for the info, Robert!  
Turns out the onSettings method definition in my app was incomplete (parameter types were missing). I made it equal to the autogenerated (which you shared), and now “newSettings.abc” works.
