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GACpB,MAAb,EAAmB,EAAI,EAClC,CAIA,qBAAM,GAEF,GADA,KAAK,IAAI,MAAM,iCACG,MAAd,KAAK,MACL,OAAO,KAAK,MAEhB,IAAI,QAAY,KAAK,QAAQ,KAAK,KAAK,OACvC,OAAK,GAGL,KAAK,MAAQ,EACb,KAAK,IAAI,KAAK,UAAY,KAAK,OACxB,KAAK,OAJD,SAKf,CAEA,4BAAM,GAEF,GADA,KAAK,IAAI,MAAM,wCACU,MAArB,KAAK,aACL,OAAO,KAAK,aAEhB,IAAI,QAAY,KAAK,QAAQ,KAAK,KAAK,eACvC,OAAK,GAGL,KAAK,aAAe,EACpB,KAAK,IAAI,KAAK,kBAAoB,KAAK,cAChC,KAAK,cAJD,SAKf,CAEA,2BAAM,GAEF,GADA,KAAK,IAAI,MAAM,uCACS,MAApB,KAAK,YACL,OAAO,KAAK,YAEhB,IAAI,QAAY,KAAK,QAAQ,KAAK,KAAK,cACvC,OAAK,GAGL,KAAK,YAAc,EACnB,KAAK,IAAI,KAAK,kBAAoB,KAAK,aAChC,KAAK,aAJD,SAKf","file":"/npm/homebridge-apc-snmp@1.2.3/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/homebridge-apc-snmp@1.2.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","let snmp = require(\"net-snmp\");\n\nmodule.exports = (api) => {\n    api.registerAccessory('ups', UPS);\n};\n\n\nclass UPS {\n    services = []\n\n    getServices() {\n        return this.services;\n    }\n\n    configureAccessory(accessory) {\n        console.log(accessory)\n    }\n\n    constructor(log, config, api) {\n        this.model = null;\n        this.serialNumber = null;\n        this.firmwareRev = null;\n        this.cached_battery_level = 0;\n        this.cached_charging_state = false;\n        this.cached_low_battery = 0;\n        this.cached_temperature = 0;\n        this.updateInterval = 20000;\n\n        this.log = log;\n        this.config = config;\n        this.api = api;\n        this.session = snmp.createSession(this.config.address, this.config.community);\n        this.oids = {\n            \"model\": \"1.3.6.1.4.1.318.1.1.1.1.1.1.0\",\n            \"serial_number\": \"1.3.6.1.4.1.318.1.1.1.1.2.3.0\",\n            \"firmware_rev\": \"1.3.6.1.4.1.318.1.1.1.1.2.1.0\",\n            \"out_volt\": \"1.3.6.1.4.1.318.1.1.1.4.2.1.0\",\n            \"bat_capacity\": \"1.3.6.1.4.1.318.1.1.1.2.2.1.0\",\n            \"bat_status\": \"1.3.6.1.4.1.318.1.1.1.2.1.1.0\",\n            \"time_on_bat\": \"1.3.6.1.4.1.318.1.1.1.2.1.2.0\",\n            \"alarm_state\": \"1.3.6.1.4.1.318.1.1.1.5.2.4.0\",\n            \"self_test_state\": \"1.3.6.1.4.1.318.1.1.1.7.2.3.0\",\n            \"temp\": \"1.3.6.1.4.1.318.1.1.1.2.2.2.0\",\n            \"turn_on\": {\"oid\": \"1.3.6.1.4.1.318.1.1.1.6.2.6.0\", \"type\": snmp.ObjectType.INTEGER, \"value\": 2},\n            \"turn_off\": {\"oid\": \"1.3.6.1.4.1.318.1.1.1.6.2.1.0\", \"type\": snmp.ObjectType.INTEGER, \"value\": 2},\n            \"turn_off_graceful\": {\"oid\": \"1.3.6.1.4.1.318.1.1.1.6.2.1.0\", \"type\": snmp.ObjectType.INTEGER, \"value\": 3},\n            \"alarm_on\": {\"oid\": \"1.3.6.1.4.1.318.1.1.1.5.2.4.0\", \"type\": snmp.ObjectType.INTEGER, \"value\": 1},\n            \"alarm_off\": {\"oid\": \"1.3.6.1.4.1.318.1.1.1.5.2.4.0\", \"type\": snmp.ObjectType.INTEGER, \"value\": 3},\n            \"start_self_test\": {\"oid\": \"1.3.6.1.4.1.318.1.1.1.7.2.2.0\", \"type\": snmp.ObjectType.INTEGER, \"value\": 2}\n        };\n\n        this.Service = this.api.hap.Service;\n        this.Characteristic = this.api.hap.Characteristic;\n        this.name = this.config.name;\n\n        this.informationService = new this.Service.AccessoryInformation()\n        this.informationService.setCharacteristic(this.Characteristic.Manufacturer, \"APC\");\n        this.informationService.getCharacteristic(this.Characteristic.Model).onGet(\n            this.getModelHandler.bind(this)\n        );\n        this.informationService.getCharacteristic(this.Characteristic.SerialNumber).onGet(\n            this.getSerialNumberHandler.bind(this)\n        );\n        this.informationService.getCharacteristic(this.Characteristic.FirmwareRevision).onGet(\n            this.getFirmwareRevHandler.bind(this)\n        );\n\n        this.batteryService = new this.Service.BatteryService(this.name);\n        this.batteryService.getCharacteristic(this.Characteristic.StatusLowBattery).onGet(\n            this.getLowBatteryHandler.bind(this)\n        );\n        this.batteryService.getCharacteristic(this.Characteristic.BatteryLevel).onGet(\n            this.getBatteryLevelHandler.bind(this)\n        );\n        this.batteryService.getCharacteristic(this.Characteristic.ChargingState).onGet(\n            this.getBatteryChargingStateHandler.bind(this)\n        );\n\n        this.switchService = new this.Service.Switch(this.name);\n        this.switchService.getCharacteristic(this.Characteristic.On).onGet(\n            this.getPowerStateHandler.bind(this)\n        ).onSet(\n            this.setPowerStateHandler.bind(this)\n        );\n\n        this.gracefulSwitchService = new this.Service.Switch(this.name + \" (Graceful)\", \"Graceful\");\n        this.gracefulSwitchService.getCharacteristic(this.Characteristic.On).onGet(\n            this.getPowerStateHandler.bind(this)\n        ).onSet(\n            this.setGracefulPowerStateHandler.bind(this)\n        );\n\n        this.alarmSwitchService = new this.Service.Switch(this.name + \" Alarm\", \"Alarm\");\n        this.alarmSwitchService.getCharacteristic(this.Characteristic.On).onGet(\n            this.getAlarmStateHandler.bind(this)\n        ).onSet(\n            this.setAlarmStateHandler.bind(this)\n        );\n\n        this.selfTestSwitchService = new this.Service.Switch(this.name + \" Self-Test\", \"Self-Test\");\n        this.selfTestSwitchService.getCharacteristic(this.Characteristic.On).onGet(\n            this.getSelfTestHandler.bind(this)\n        ).onSet(\n            this.setSelfTestHandler.bind(this)\n        );\n\n        this.tempService = new this.Service.TemperatureSensor(this.name + \" Temperature\");\n        this.tempService.getCharacteristic(this.Characteristic.CurrentTemperature).onGet(\n            this.getTempHandler.bind(this)\n        );\n\n        this.services.push(this.informationService);\n        if (this.config.enable_non_graceful || this.config.enable_non_graceful === undefined) {\n            this.services.push(this.switchService);\n        }\n        if (this.config.enable_graceful || this.config.enable_graceful === undefined) {\n            this.services.push(this.gracefulSwitchService)\n        }\n        if (this.config.enable_alarm || this.config.enable_alarm === undefined) {\n            this.services.push(this.alarmSwitchService)\n        }\n        if (this.config.enable_self_test || this.config.enable_self_test === undefined) {\n            this.services.push(this.selfTestSwitchService)\n        }\n        if (this.config.enable_temp || this.config.enable_temp === undefined) {\n            this.services.push(this.tempService)\n        }\n        if (this.config.enable_battery || this.config.enable_battery === undefined) {\n            this.services.push(this.batteryService)\n        }\n\n        let configUpdateInterval = this.config.update_interval;\n        if (configUpdateInterval !== undefined) {\n            if (Number.isInteger(configUpdateInterval)) {\n                if (configUpdateInterval < 5) {\n                    this.log.error(\"Minimum update interval value is 5 seconds!\");\n                } else {\n                    this.updateInterval = configUpdateInterval * 1000;\n                }\n            } else {\n                this.log.error(\"Update interval is not a number!\");\n            }\n\n        }\n\n        this.getModelHandler();\n        this.getSerialNumberHandler();\n        this.getFirmwareRevHandler();\n        this.updateLoop();\n    }\n\n    // Helper\n\n    async updateLoop() {\n        setInterval(function() {this.update()}.bind(this), this.updateInterval)\n    };\n\n    async update() {\n        this.log.debug(\"Updating values...\")\n        this.tempService.getCharacteristic(this.Characteristic.CurrentTemperature).updateValue(\n            await this.getTempHandler()\n        );\n        this.batteryService.getCharacteristic(this.Characteristic.StatusLowBattery).updateValue(\n            await this.getLowBatteryHandler()\n        );\n        this.batteryService.getCharacteristic(this.Characteristic.BatteryLevel).updateValue(\n            await this.getBatteryLevelHandler()\n        );\n        this.batteryService.getCharacteristic(this.Characteristic.ChargingState).updateValue(\n            await this.getBatteryChargingStateHandler()\n        );\n    }\n\n    setSNMP(oid, type, value) {\n        let logging = this.log;\n        this.session.set([{oid, type, value}], function (error, varbinds) {\n            if (error) {\n                logging.debug(error.toString());\n                return null;\n            }\n            for (let i = 0; i < varbinds.length; i++) {\n                if (snmp.isVarbindError(varbinds[i])) {\n                    logging.debug(snmp.varbindError(varbinds[i]));\n                } else {\n                    logging.debug(\"Set \" + varbinds[i].oid + \" to value \" + varbinds[i].value);\n                }\n            }\n        });\n    }\n\n    async getSNMP(oid) {\n        let logging = this.log;\n        let session = this.session;\n        let timeoutPromise = new Promise((resolve, reject) => {\n            setTimeout(() => {\n                reject(new Error('timeout'));\n            }, 1800);\n        });\n\n        let snmpPromise = new Promise(function (resolve, reject) {\n            try {\n                session.get([oid], function (error, varbinds) {\n                    if (error) {\n                        logging.debug(error);\n                        reject(error.toString());\n                    } else if (snmp.isVarbindError(varbinds[0])) {\n                        logging.debug(snmp.varbindError(varbinds[0]));\n                        reject(snmp.varbindError(varbinds[0]).toString());\n                    } else {\n                        logging.debug(\"Got \" + oid + \" value \" + varbinds[0].value);\n                        resolve(varbinds[0].value.toString());\n                    }\n                })\n            } catch (RequestFailedError) {\n                logging.warn(\"Device not reachable or operation not supported\")\n            }\n        });\n\n        return Promise.race([snmpPromise, timeoutPromise])\n            .then(result => {\n                return result;\n            })\n            .catch(error => {\n                return null;\n            });\n    }\n\n    // Self-Test\n\n    async getSelfTestHandler() {\n        this.log.debug('Triggered GET setSelfTestHandler');\n        return await this.getSNMP(this.oids.self_test_state) > 3;\n    }\n\n    async setSelfTestHandler(value) {\n        this.log.debug('Triggered SET setSelfTestHandler');\n        this.log.info('Starting UPS self-test...')\n        this.log.info('After the self-test is completed, the UPS will be unavailable for a few seconds.')\n        value ? this.setSNMP(\n            this.oids.start_self_test.oid,\n            this.oids.start_self_test.type,\n            this.oids.start_self_test.value\n        ) : null;\n    }\n\n    // Power\n\n    async getPowerStateHandler() {\n        this.log.debug('Triggered GET getPowerStateHandler');\n        return await this.getSNMP(this.oids.out_volt) >= 10;\n    }\n\n    async setPowerStateHandler(value) {\n        this.log.debug('Triggered SET setPowerStateHandler');\n        let cmd = value ? this.oids.turn_on : this.oids.turn_off;\n        this.setSNMP(cmd.oid, cmd.type, cmd.value);\n    }\n\n    async setGracefulPowerStateHandler(value) {\n        this.log.debug('Triggered SET setGracefulPowerStateHandler');\n        let cmd = value ? this.oids.turn_on : this.oids.turn_off_graceful;\n        this.setSNMP(cmd.oid, cmd.type, cmd.value);\n    }\n\n    // Alarm\n\n    async getAlarmStateHandler() {\n        this.log.debug('Triggered GET getAlarmStateHandler');\n        return await this.getSNMP(this.oids.alarm_state) <= 2;\n    }\n\n    async setAlarmStateHandler(value) {\n        this.log.debug('Triggered SET setAlarmStateHandler');\n        let cmd = value ? this.oids.alarm_on : this.oids.alarm_off;\n        this.setSNMP(cmd.oid, cmd.type, cmd.value);\n    }\n\n    // Temp\n\n    async getTempHandler() {\n        this.log.debug('Triggered GET getTempHandler')\n        let temp = await this.getSNMP(this.oids.temp);\n        temp ? this.cached_temperature = temp : null;\n        return temp ? temp : this.cached_temperature;\n    }\n\n    // Battery\n\n    async getBatteryLevelHandler() {\n        this.log.debug('Triggered GET getBatteryLevelHandler');\n        let level = await this.getSNMP(this.oids.bat_capacity);\n        level ? this.cached_battery_level = level : null;\n        return level ? level : this.cached_battery_level;\n    }\n\n    async getLowBatteryHandler() {\n        this.log.debug('Triggered GET getLowBatteryHandler');\n        let status = await this.getSNMP(this.oids.bat_status);\n        if (status === null) {\n            return this.cached_low_battery;\n        }\n        status ? this.cached_low_battery = status === 3 : null;\n        return status === 3 ? 1 : 0;\n    }\n\n\n    async getBatteryChargingStateHandler() {\n        this.log.debug('Triggered GET getBatteryChargingStateHandler');\n        let charging = await this.getSNMP(this.oids.time_on_bat);\n        if (charging === null) {\n            return this.cached_charging_state;\n        }\n        charging ? this.cached_charging_state = charging : null;\n        return charging === \"0\" ? 1 : 0;\n    }\n\n    // Stuff for information service\n\n    async getModelHandler() {\n        this.log.debug('Triggered GET getModelHandler');\n        if (this.model != null) {\n            return this.model;\n        }\n        let val = await this.getSNMP(this.oids.model);\n        if (!val) {\n            return \"Unknown\"\n        }\n        this.model = val;\n        this.log.info(\"Model: \" + this.model);\n        return this.model;\n    }\n\n    async getSerialNumberHandler() {\n        this.log.debug('Triggered GET getSerialNumberHandler');\n        if (this.serialNumber != null) {\n            return this.serialNumber;\n        }\n        let val = await this.getSNMP(this.oids.serial_number);\n        if (!val) {\n            return \"Unknown\"\n        }\n        this.serialNumber = val;\n        this.log.info(\"Serial Number: \" + this.serialNumber);\n        return this.serialNumber;\n    }\n\n    async getFirmwareRevHandler() {\n        this.log.debug('Triggered GET getFirmwareRevHandler');\n        if (this.firmwareRev != null) {\n            return this.firmwareRev;\n        }\n        let val = await this.getSNMP(this.oids.firmware_rev);\n        if (!val) {\n            return \"Unknown\"\n        }\n        this.firmwareRev = val;\n        this.log.info(\"Firmware Rev.: \" + this.firmwareRev);\n        return this.firmwareRev;\n    }\n}"]}