Show pagesourceOld revisionsBacklinksAdd to bookExport to PDFODT exportBack to top Share via Share via... Twitter LinkedIn Facebook Pinterest Telegram WhatsApp Yammer Reddit TeamsRecent ChangesSend via e-MailPrintPermalink × Book Creator Add this page to your book Book Creator Remove this page from your book Manage book(0 page(s)) Help Identity active/inactive Example: Toggle the active state of an identity. led green if active led off if inactive identity_ready.xml <templates> <template name="Toggle identity active"> <keyConfiguration> <lua> <code><![CDATA[local config_path_active = "/identities/identity[" .. identity .."]/active"local active = false -- called on changes to the configuration-- get the active state and set the ledlocal function onConfigChange() active = config.get(config_path_active) == "true" if active then key.setLed("green") else key.setLed("off") endend -- called when the key is pressed-- check the current state and set to the otherfunction onKeyUp() if active then config.set(config_path_active, "false") else config.set(config_path_active, "true") endend config.register(config_path_active, onConfigChange)-- trigger once to get the current stateonConfigChange() ]]></code> <params> <param name="identity"><value/></param> </params> </lua> </keyConfiguration> <parameters> <parameter name="@string/identity"> <path>//param[@name="identity"]/value</path> </parameter> </parameters> </template></templates> Example: Toggle identity active state and set to default if switching to enabled led green if active and default led orange if inactive led off if active but not default identity_ready_default.xml <templates patch="true"> <template name="Toggle identity active with default"> <keyConfiguration> <lua> <code><![CDATA[local config_path_active = "/identities/identity[" .. identity .."]/active"local config_path_current = "/telephony/activeLine" local activelocal current -- called on changes to the configuration-- get the active state and current identity and set the ledlocal function onConfigChange() active = config.get(config_path_active) == "true" current = config.get(config_path_current .. "/id") if active then if current == identity then key.setLed("green") else key.setLed("off") end else key.setLed("orange") endend -- called when the key is pressed-- check the current state and set to the other-- set the default identity also when setting to enabledfunction onKeyUp() if active then config.set(config_path_active, "false") else config.set(config_path_active, "true") config.set(config_path_current .. "/id", identity) endend config.register(config_path_active, onConfigChange)config.register(config_path_current, onConfigChange)-- trigger once to get the current stateonConfigChange() ]]></code> <params> <param name="identity"><value/></param> </params> </lua> </keyConfiguration> <parameters> <parameter name="@string/identity"> <path>//param[@name="identity"]/value</path> </parameter> </parameters> </template></templates> en/products/comfortel-d-series/developer/keys/templates/examples/identity_active.txt Last modified: 22.03.2022 13:16by hoehne