Still trying to get my head around all this new api for creating SmartApps (it just seemed so easier with the IDE and groovy…).
With defining the smartapp, I’m attempting to subscribe to subscribeToSecuritySystem and setup my .subscribedSecurityArmStateEventHandler, but things don’t seem to work. In the developer workspace, there is no scope for the security armstate, so I add my .permissions(“r:security:locations:*:armstate”), and also add my .appId, .clientId and .clientSecret, but it just results in an error.
Commenting out the .permissions in defining the SmartApp() allows things to work.
What am I doing wrong, or not understanding? Here is some of my code:
const smartapp = new SmartApp()
.appId(“xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx”)
.clientId(“xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx”)
.clientSecret(“xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx”)
.permissions([
“r:security:locations:*:armstate”
])
.enableEventLogging(2) // Log all lifecycle event requests and responses as pretty printed JSON
.configureI18n() // Use language file in locales folder
.disableCustomDisplayName(true).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") .defaultValue("4025") .required(true) section.passwordSetting("envisalinkPassword") .description("Password for Envisalink device") .defaultValue("user") .required(true) });
// Called for both INSTALLED and UPDATED lifecycle events
.updated(async (context, updateData) => {
await context.api.subscriptions.unsubscribeAll();
await context.api.subscriptions.subscribeToSecuritySystem(“secuirityStateHandler”);
}).subscribedSecurityArmStateEventHandler("securityStateHandler", (context, event) => { const value = event.armState; console.log(value); });