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AkB,QAAE,GAGhC,KAAK,sBAAsB,EAAQ,EAAQ,QAAQ,KAAM,IAAK,EAAW,EAE7E,CACA,IAAK,IAAI,KAAa,EAAiB,OAAG,CACtC,IAAI,EAAQ,EAAiB,OAAE,GAG/B,KAAK,sBAAsB,EAAQ,EAAQ,QAAQ,KAAM,IAAK,EAAW,EAE7E,CACJ,CACJ,CAER,EAEA,sBAAsB,UAAU,sBAAwB,SAAU,EAAQ,EAAS,EAAW,EAAQ,MAClG,IAAI,EAAY,KAAK,sBAAsB,EAAQ,GAE/C,GACA,EAAU,OAAO,EAAS,EAAW,EAE7C,EAEA,sBAAsB,UAAU,sBAAwB,SAAU,EAAI,EAAK,MACvE,IAAK,IAAI,EAAI,EAAG,EAAI,KAAK,iBAAiB,OAAQ,IAC9C,GAAI,KAAK,iBAAiB,GAAG,QAAU,EAAI,CACvC,IAAK,IAAO,KAAK,iBAAiB,GAAG,QACjC,OAAO,KAAK,iBAAiB,GAEjC,GAAI,GAAM,KAAK,iBAAiB,GAAG,SAAW,KAAK,iBAAiB,GAAG,SAAW,EAC9E,OAAO,KAAK,iBAAiB,EAErC,CAGJ,OAAO,IACX,EAEA,sBAAsB,UAAU,iBAAmB,SAAU,GACzD,OAAQ,EAAQ,MACZ,IAAK,QACD,KAAK,IAAI,MAAM,EAAQ,OAAO,SAC9B,MACJ,IAAK,SACD,KAAK,eAAe,GACpB,MACJ,IAAK,aACG,EAAQ,OACR,KAAK,eAAe,CAAE,KAAQ,SAAU,OAAU,KAAK,IAAI,kBAE3D,KAAK,IAAI,MAAM,0CAEnB,MACJ,QACI,KAAK,IAAI,KAAK,kCAAoC,EAAQ,MAEtE","file":"/npm/homebridge-freeathome-local-kdljns@3.0.1-2/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/homebridge-freeathome-local-kdljns@3.0.1-2/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","'use strict';\n\nconst path = require('path');\n\nvar Service, Characteristic, Hap, PlatformAccessory\n\nvar APICLOUD = require('freeathome-api');\nvar APILOCAL = require(path.join(__dirname, 'dist', 'local-api'));\n//var APILOCAL;\nvar API;\n\nmodule.exports = function (homebridge) {\n    console.log(\"homebridge API version: \" + homebridge.version);\n\n    // Service and Characteristic are from hap-nodejs\n    Service = homebridge.hap.Service;\n    Characteristic = homebridge.hap.Characteristic;\n    Hap = homebridge.hap;\n    PlatformAccessory = homebridge.platformAccessory;\n\n    // For platform plugin to be considered as dynamic platform plugin,\n    // registerPlatform(pluginName, platformName, constructor, dynamic), dynamic must be true\n    homebridge.registerPlatform(\"homebridge-freeathome\", \"free@home\", BuschJaegerApPlatform, true);\n\n}\n\n// Platform constructor\n// config may be null\n// api may be null if launched from old homebridge version\nfunction BuschJaegerApPlatform(log, config, api) {\n    this.log = log;\n    this.hap = Hap;\n    this.hApi = api;\n    this.platformAccessory = PlatformAccessory;\n\n    this.log('Initialising BuschJaeger Plugin');\n\n    this.mappings = config.mappings;\n\n    this.log('Will try to connect to the SysAP at %s', config.sysIP);\n\n    if (config.isLocalAPI == true) {\n        API = APILOCAL;\n    } else {\n        API = APICLOUD;\n    }\n\n    this.configuration = new API.ClientConfiguration(config.sysIP, config.username, config.password);\n\n    this.accessoryCallback = null;\n    this.accessoryCallbackSet = false;\n\n    this.actuatorInfo = {};\n\n    this.scheduler = null;\n\n    this.connect();\n\n    this.foundAccessories = [];\n\n    this.config = config;\n}\n\nBuschJaegerApPlatform.prototype.accessories = function (callback) {\n    this.accessoryCallback = callback;\n    this.accessoryCallbackSet = true;\n}\n\nBuschJaegerApPlatform.prototype.transformAccessories = function (actuators) {\n    let acc = [];\n\n    for (let serial in actuators) {\n        let mapping = {};\n        if (this.mappings) {\n            mapping = this.mappings.filter(obj => {\n                return obj.actuatorID === serial\n            })?.shift()\n        }\n\n        let actuator = actuators[serial];\n\n        if (mapping!==undefined && mapping['blacklist']?.find(o => {return o.channelID === '*' })?.channelID!==undefined ) {\n            this.log('Ignoring blacklisted accessory ' + actuator['typeName'] + ' with serial ' + serial);\n            continue;\n        }\n\n        if (Object.keys(actuator['channels']).length > 0) {\n            for (let channelNo in actuator['channels']) {\n                let channel = actuator['channels'][channelNo];\n\n                let accessory = this.initializeAccessory(channelNo, actuator, channel, serial, mapping);\n\n                if (accessory != null) {\n                    acc.push(accessory);\n                }\n            }\n            // some actuators do not expose their channels\n        } else {\n            let accessory = this.initializeAccessory(null, actuator, {}, serial, mapping);\n\n            if (accessory != null) {\n                acc.push(accessory);\n            }\n        }\n    }\n\n    this.foundAccessories = acc;\n\n}\n\nBuschJaegerApPlatform.prototype.initializeAccessory = function (channelNo, actuator, channel, serial, mapping) {\n\n    actuator['serialNumber'] = serial;  // local API\n    actuator['typeName'] = actuator['typeName'] ?? actuator['displayName'];\n    let [accessoryClass, forcedChannel] = this.getAccessoryClass(actuator['deviceId'], channelNo, channel['functionId'] ?? channel['functionID'], channel['iconId'], channel['floor'] ?? actuator['floor'], channel['room'] ?? actuator['room'], mapping);\n\n    if (channelNo == null) {\n        channelNo = forcedChannel;\n    }\n\n    if (mapping!==undefined && mapping['blacklist']?.find(o => {return o.channelID === channelNo })?.channelID!==undefined ) {\n        this.log('Ignoring blacklisted accessory ' + actuator['typeName'] + '/' + channel['displayName'] + ' with serial ' + serial + ' and channel ' + channelNo);\n        return;\n    }\n\n    if (accessoryClass == null) {\n        this.log.debug('Ignoring non-supported accessory ' + actuator['typeName'] + '/' + channel['displayName'] + ' with serial ' + serial + ' and channel ' + channelNo);\n        return;\n    }\n\n    if (channelNo != null) {\n        let service = require(path.join(__dirname, 'dist/accessories', accessoryClass));\n\n        return new service(this, Service, Characteristic, actuator, channelNo, mapping);\n    }\n}\n\nBuschJaegerApPlatform.prototype.getAccessoryClass = function (deviceId, channel, functionId, iconId, floor, room, mapping) {\n    if (!floor || !room) {\n        return [null, null];\n    }\n\n    switch (deviceId) {\n        case '1008': // Bewegungsmelder\n        case '100A': // Bewegungsmelder/Schaltaktor 1-fach\n            return ['BuschJaegerMotionSensorAccessory', 'ch0000'];\n    }\n\n    if (!iconId) {\n        //return [null, null];\n    }\n\n    if (mapping!==undefined && 'doorbell' in mapping && channel in mapping['doorbell']) {\n        let doorbell = mapping['doorbell'][channel];\n\n        if (doorbell['video']) {\n            return ['BuschJaegerVideoDoorBellAccessory', null];\n        } else {\n            return ['BuschJaegerDoorBellAccessory', null];\n        }\n    } else if (mapping!==undefined && 'garagedoor' in mapping && channel in mapping['garagedoor']) {\n        return ['BuschJaegerGarageDoorAccessory', null];\n    }\n\n    switch (functionId) {\n        case '4':\n            return ['BuschJaegerBinarySensorAccessory', null];\n        case '7':\n            return ['BuschJaegerSchaltAktorAccessory', null];\n        case '9':\n        case '61':\n            return ['BuschJaegerJalousieAccessory', null];\n        case '11':\n            return ['BuschJaegerMotionSensorAccessory', null];\n        case '12':\n            return ['BuschJaegerDimmAktorAccessory', null];\n        case 'f':\n            return ['BuschJaegerContactSensorAccessory', null];\n        case '23':\n            return ['BuschJaegerThermostatAccessory', null];\n        case '1a':\n            return ['BuschJaegerDoorLockAccessory', null];\n        case '5a':\n            return ['BuschJaegerMediaPlayerAccessory', null];\n        case '7d':\n            return ['BuschJaegerSmokeSensorAccessory', null];\n\n        default:\n            return [null, null];\n    }\n}\n\nBuschJaegerApPlatform.prototype.setDatapoint = function (serial, channelNo, datapoint, value = null) {\n    if ('debug' in this.config && this.config.debug) {\n        this.log.warn(\"setDatapoint(): \" + [serial, channelNo, datapoint, value.toString()].join('/'));\n    }\n\n    this.api.setDatapoint(serial, channelNo, datapoint, value.toString());\n}\n\nBuschJaegerApPlatform.prototype.connect = async function () {\n    this.log('Trying to connect to SysAP');\n    const that = this;\n\n    this.api = new API.SystemAccessPoint(this.configuration, this, class {\n        static log(...messages) {\n            for (let message of messages) {\n                that.log.info(message);\n            }\n        }\n\n        static warn(...messages) {\n            for (let message of messages) {\n                that.log.warn(message);\n            }\n        }\n\n        static error(...messages) {\n            for (let message of messages) {\n                that.log.error(message);\n            }\n        }\n\n        static debug(...messages) {\n            for (let message of messages) {\n                that.log.debug(message);\n            }\n        }\n    });\n\n    try {\n        await this.api.connect();\n    } catch (e) {\n        this.log.error(e.message);\n    }\n}\n\nBuschJaegerApPlatform.prototype.processMessage = function (jsonData) {\n    if ('debug' in this.config && this.config.debug) {\n        this.log.warn(\"processMessage(): \" + JSON.stringify(jsonData));\n    }\n\n    if (!('result' in jsonData)) {\n        this.log.warn('Invalid message received.');\n        return;\n    }\n\n    var isUpdate = false;\n\n    if ('type' in jsonData && jsonData['type'] == 'update') {\n        this.processUpdate(jsonData['result']);\n        isUpdate = true;\n    } else {\n        // Full data received\n        this.actuatorInfo = jsonData['result'];\n    }\n\n    if (this.accessoryCallbackSet && !isUpdate) {\n        this.transformAccessories(jsonData['result']);\n\n        /*\n        There may be an edge case where the connection to the SysAP Node Plugin\n        is established successfully but the SysAP Node Plugin can not authenticate against\n        the SysAP and therefore returns no accessories. This will remove all devices from the\n        HomeKit database.\n        */\n        if (this.foundAccessories.length >= 1) {\n            // Only expose if accessory has more than one service (first is informationService)\n            let filteredAccessories = this.foundAccessories.filter(accessory => accessory.getServices().length > 1);\n            this.accessoryCallback(filteredAccessories);\n            this.accessoryCallback = null;\n            this.accessoryCallbackSet = false;\n        }\n    }\n}\n\nBuschJaegerApPlatform.prototype.processUpdate = function (actuators) {\n    for (let serial in actuators) {\n        for (let channel in actuators[serial]['channels']) {\n            let channels = actuators[serial]['channels'][channel];\n            if (this.actuatorInfo[serial]) {\n                for (let datapoint in channels['datapoints']) {\n\n                    if (!this.actuatorInfo[serial]['channels'][channel]) {\n                        this.actuatorInfo[serial]['channels'][channel] = { 'datapoints': {} };\n                    }\n\n                    let value = channels['datapoints'][datapoint];\n                    this.actuatorInfo[serial]['channels'][channel]['datapoints'][datapoint] = value;\n                    this.sendUpdateToAccessory(serial, channel.replace('ch', ''), datapoint, value);\n                }\n                for (let datapoint in channels['outputs']) {\n                    let value = channels['outputs'][datapoint];\n                    // value is somehow a referenz to *['outputs'][datapoint] so we don't need to assign it here\n                    //this.actuatorInfo[serial]['channels'][channel]['outputs'][datapoint] = value;\n                    this.sendUpdateToAccessory(serial, channel.replace('ch', ''), datapoint, value);\n\n                }\n                for (let datapoint in channels['inputs']) {\n                    let value = channels['inputs'][datapoint];\n                    // value is somehow a referenz to *['outputs'][datapoint] so we don't need to assign it here              \n                    //this.actuatorInfo[serial]['channels'][channel]['inputs'][datapoint] = value;\n                    this.sendUpdateToAccessory(serial, channel.replace('ch', ''), datapoint, value);\n\n                }\n            }\n        }\n    }\n}\n\nBuschJaegerApPlatform.prototype.sendUpdateToAccessory = function (serial, channel, datapoint, value = null) {\n    let accessory = this.findAccessoryBySerial(serial, channel);\n\n    if (accessory) {\n        accessory.update(channel, datapoint, value);\n    }\n}\n\nBuschJaegerApPlatform.prototype.findAccessoryBySerial = function (sn, ch = null) {\n    for (let i = 0; i < this.foundAccessories.length; i++) {\n        if (this.foundAccessories[i].serial == sn) {\n            if (!ch && !this.foundAccessories[i].channel) {\n                return this.foundAccessories[i];\n            }\n            if (ch && this.foundAccessories[i].channel && this.foundAccessories[i].channel == ch) {\n                return this.foundAccessories[i];\n            }\n        }\n    }\n\n    return null;\n}\n\nBuschJaegerApPlatform.prototype.broadcastMessage = function (message) {\n    switch (message.type) {\n        case 'error':\n            this.log.error(message.result.message);\n            break;\n        case 'update':\n            this.processMessage(message);\n            break;\n        case 'subscribed':\n            if (message.result) {\n                this.processMessage({ 'type': 'result', 'result': this.api.getDeviceData() });\n            } else {\n                this.log.error(\"Unsubscribed from System Access Point!\");\n            }\n            break;\n        default:\n            this.log.warn(\"Unknown message type received: \" + message.type);\n    }\n}\n"]}