Permissions in defining SmartApp()

I don’t know if when the code was formatted here, it lost some symbols, like here:

Anyway, I think that the problem is the permissions list, you only need to include those you selected in the Developer Workspace and the armsate scope (remember to add it back every time you edit the SmartApp from there - change URL, other scopes, name, etc.). Here’s how it works for me:

app.enableEventLogging(2)
.configureI18n() // Language file in ./locales folder
.appId("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx")
.disableCustomDisplayName(true)
.permissions([
    "i:deviceprofiles:*",
    "r:customcapability",
    "r:devices:*",
    "r:locations:*",
    "w:devices:*",
    "x:devices:*",
    "r:security:locations:*:armstate"
])
.page("mainPage", (context, page, configData) => {
    page.section("envisalink", section => {
        section.textSetting("envisalinkIP")
            .description("IP address of Envisalink device")
            .defaultValue("envisalink")
            .required(true)
        section.numberSetting("envisalinkPort")
            .description("Port number for Envisalink device")
            .defaultValue("4025")
            .required(true)
        section.passwordSetting("envisalinkPassword")
            .description("Password for Envisalink device")
            .defaultValue("user")
            .required(true)
    })
})
.updated(async (context, updateData) => {
    await context.api.subscriptions.unsubscribeAll();
    await context.api.subscriptions.subscribeToSecuritySystem("securityStateHandler");
})
.subscribedSecurityArmStateEventHandler("securityStateHandler", (context, event) => {
    const value = event.armState;
    console.log(value);
});

Note: It works correctly using .configureI18n() now.

2 Likes