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KAAK,YAAa,KAAK,aACvD,CAGA,QAAA,CAAS,GACL,KAAK,IAAI,YACT,GACJ,CAGA,kBAAA,CAAmB,EAAO,EAAU,GAChC,IAAI,EAAS,GAAS,eAAe,gBAAgB,KACtC,OAAS,SACxB,KAAK,IAAI,wBAA0B,EAAO,eAC1C,KAAK,KAAK,mBAAmB,EAAQ,EACzC,CAGA,eAAA,CAAgB,EAAS,GAErB,KAAK,IAAI,qBAAuB,GAChC,MAAM,EAAa,CACf,KAAY,eAAe,iBAAiB,KAC5C,OAAY,eAAe,iBAAiB,OAC5C,QAAY,eAAe,iBAAiB,QAC5C,QAAY,eAAe,iBAAiB,QAC5C,QAAY,eAAe,iBAAiB,SAEhD,KAAK,YAAY,qBAAqB,eAAe,iBACf,EAAW,IAGjD,KAAK,IAAI,2BAA6B,GACtC,MAAM,EAAY,CACd,KAAY,eAAe,gBAAgB,KAC3C,OAAY,eAAe,gBAAgB,QAE/C,KAAK,YAAY,qBAAqB,eAAe,gBACf,EAAU,GACpD,CAGA,UAAA,CAAW,EAAO,EAAU,GACxB,KAAK,IAAI,iBAAmB,EAAQ,KAAO,QAC3C,KAAK,KAAK,WAAW,EAAO,EAChC,CAGA,gBAAA,CAAiB,GACb,KAAK,IAAI,WAAa,EAAK,KAAO,QAClC,KAAK,aAAa,qBAAqB,eAAe,GAAI,EAC9D","file":"/npm/homebridge-garagedoor-iologik@1.0.3/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/homebridge-garagedoor-iologik@1.0.3/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","// Hörmann Supramatic garage door opener plugin for Homebridge\n// Copyright © 2019 Alexander Thoukydides\n\n'use strict';\n\nconst UAP1 = require('./uap1');\n\nlet UUID;\nlet Service, Characteristic;\n\n// Platform identifiers\nconst PLUGIN_NAME       = 'homebridge-garagedoor-iologik';\nconst ACCESSORY_NAME    = 'Garagedoor-ioLogik';\n\n// Accessory defaults\nconst DEFAULT_NAME      = 'Garage Door';\nconst DEFAULT_HOST      = 'localhost';\n\n// Hardcoded accessory information (hostname is used as serial number)\nconst INFO_MANUFACT     = 'Hörmann / Moxa';\nconst INFO_MODEL        = 'Supramatic / ioLogik E1214';\nconst INFO_FIRMWARE     = require('./package.json').version;\n\n// Register as a provider of Garagedoor-ioLogik accessories\nmodule.exports = homebridge => {\n    Service = homebridge.hap.Service;\n    Characteristic = homebridge.hap.Characteristic;\n    homebridge.registerAccessory(PLUGIN_NAME, ACCESSORY_NAME,\n                                 GarageDoorOpenerAccessory);\n}\n\n// A Garagedoor-ioLogik accessory\nclass GarageDoorOpenerAccessory {\n\n    // Constructor\n    constructor(log, config) {\n        this.log = log;\n\n        // Extract the configuration, applying defaults where missing\n        this.name    = config.name || DEFAULT_NAME;\n        this.host    = config.host || DEFAULT_HOST;\n        this.log('New ' + ACCESSORY_NAME + ' accessory on ' + this.host);\n\n        // Create a UAP1 (Universal Adapter Print) interface\n        this.uap1 = new UAP1(this.host, msg => log.debug(msg));\n        this.uap1.on('door',  (...args) => this.updateDoorState(...args));\n        this.uap1.on('light', (...args) => this.updateLightState(...args));\n        this.uap1.on('error', e => this.log.warn(e.message));\n        \n        // Create the GarageDoorOpener service for this accessory\n        this.doorService = new Service.GarageDoorOpener;\n        this.doorService\n            .getCharacteristic(Characteristic.TargetDoorState)\n            .on('set', (...args) => this.setTargetDoorState(...args));\n        this.updateDoorState('closed', 'closed');\n        \n        // Create the Lightbulb service for this accessory\n        this.lightService = new Service.Lightbulb;\n        this.lightService\n            .getCharacteristic(Characteristic.On)\n            .on('set', (...args)  => this.setLightOn(...args));\n    }\n\n    // Return a list of the accessory's services\n    getServices () {\n        // Create a temporary Information Service for this accessory\n        let informationService = new Service.AccessoryInformation;\n        informationService\n            .setCharacteristic(Characteristic.Manufacturer,     INFO_MANUFACT)\n            .setCharacteristic(Characteristic.Model,            INFO_MODEL)\n            .setCharacteristic(Characteristic.SerialNumber,     this.host)\n            .setCharacteristic(Characteristic.FirmwareRevision, INFO_FIRMWARE);\n        \n        // Return all services (Homebridge replaces the AccessoryInformation)\n        return [informationService, this.doorService, this.lightService];\n    }\n\n    // Identify this accessory\n    identify(callback) {\n        this.log('Identify');\n        callback();\n    }\n\n    // Set the target door state\n    setTargetDoorState(value, callback, context) {\n        let target = value == Characteristic.TargetDoorState.OPEN\n                     ? 'open' : 'closed';\n        this.log('Target door position ' + target.toUpperCase());\n        this.uap1.setTargetDoorState(target, callback);\n    }\n\n    // Update the door state\n    updateDoorState(current, target) {\n        // Update the current door state\n        this.log('Door is currently ' + current);\n        const mapCurrent = {\n            open:       Characteristic.CurrentDoorState.OPEN,\n            closed:     Characteristic.CurrentDoorState.CLOSED,\n            opening:    Characteristic.CurrentDoorState.OPENING,\n            closing:    Characteristic.CurrentDoorState.CLOSING,\n            stopped:    Characteristic.CurrentDoorState.STOPPED\n        };\n        this.doorService.updateCharacteristic(Characteristic.CurrentDoorState,\n                                              mapCurrent[current]);\n\n        // Update the target door state\n        this.log('Target door position is ' + target);\n        const mapTarget = {\n            open:       Characteristic.TargetDoorState.OPEN,\n            closed:     Characteristic.TargetDoorState.CLOSED\n        };\n        this.doorService.updateCharacteristic(Characteristic.TargetDoorState,\n                                              mapTarget[target]);\n    }\n    \n    // Set the light state\n    setLightOn(value, callback, context) {\n        this.log('Switch light ' + (value ? 'ON' : 'OFF'));\n        this.uap1.setLightOn(value, callback);\n    }\n\n    // Update the light state\n    updateLightState(on) {\n        this.log('Light: ' + (on ? 'on' : 'off'));\n        this.lightService.updateCharacteristic(Characteristic.On, on);\n    }\n}\n"]}