This is the forum archive of Homey. For more information about Homey, visit the Official Homey website.

The Homey Community has been moved to https://community.athom.com.

This forum is now read-only for archive purposes.

First app. Question!

Hi All,

I'm creating my first Homey app, and i'm now playing with the ManagerSettings, because i need to set some values that persist through reboots/restarts etc. So i did that with : 

Homey.ManagerSettings.set("apikey", "hoi123");

After that i'm able to retrieve the setting again. But if i restart the app (without the .set method again), the value is empty again... how can i make it persistent ?

Regards,
Dennis

Comments

  • On Slack there is a Developers channel. Good chance u can get some help there. It's free to join.
    Here u can see how to join.

  • I think the settings are only permanently saved when the onSettings() function is called, this does not happen automagically when changing settings programmatically (see note at the bottom). Refer to
    https://apps.developer.athom.com/tutorial-Drivers-Settings.html :

    onSettings( oldSettingsObj, newSettingsObj, changedKeysArr, callback ) {
        // run when the user has changed the device's settings in Homey.
        // changedKeysArr contains an array of keys that have been changed
    
        // always fire the callback, or the settings won't change!
        // if the settings must not be saved for whatever reason:
        // callback( "Your error message", null );
        // else
        callback( null, true );
    }

    When changing device settings programmatically using setSettings(), the onSettings() function is not fired.

Sign In or Register to comment.