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,EAAQ,EAAO,GAAM,KAC/C,EAAI,KAAK,2CAA6C,GACtD,GAAU,GACZ,IAEN,KAAK,mBAAmB,kBAAkB,IAAI,eAAe,mBACxD,GAAG,OAAkB,IACtB,EAAI,KAAK,mDACT,KAAK,UAAU,QAAQ,GAAM,IACzB,MAAM,EAAO,KAAK,6BAA6B,GAC/C,EAAI,KAAK,uDAAyD,GAClE,OAAS,EAAW,EAAK,GAC3B,IAED,GAAG,OAAiB,CAAC,EAAO,KAC7B,EAAI,KAAK,mDACT,KAAK,UAAU,SAAS,EAAM,KAAK,6BAA6B,IAAQ,KACpE,EAAI,KAAK,kDAAoD,GAC7D,GAAU,GACZ,IAEN,KAAK,mBAAmB,kBAAkB,IAAI,eAAe,eACxD,GAAG,OAAkB,IACtB,EAAI,KAAK,+CACT,KAAK,UAAU,QAAQ,GAAM,IACzB,MAAM,EAAO,KAAK,6BAA6B,GAC/C,EAAI,KAAK,mDAAqD,GAC9D,OAAS,EAAW,EAAK,GAC3B,IAED,GAAG,OAAiB,CAAC,EAAO,KAC7B,EAAI,KAAK,+CACT,KAAK,UAAU,SAAS,EAAM,KAAK,6BAA6B,IAAQ,KACpE,EAAI,KAAK,8CAAgD,GACzD,GAAU,GACZ,IAEN,KAAK,oBAAqB,IAAI,IAAI,QAAQ,sBACrC,kBAAkB,IAAI,eAAe,aAAc,aACnD,kBAAkB,IAAI,eAAe,MAAO,gBACjD,EAAI,KAAK,8BACb,CAKA,QAAA,GACI,KAAK,IAAI,YACb,CAKA,WAAA,GACI,MAAO,CACH,KAAK,mBACL,KAAK,mBAEb,EAEJ,OAAO,QAAW,IACd,IAAM,EAAI,IACV,EAAI,iBAAiB,cAAe,kBAAkB","file":"/npm/homebridge-panasonic-doas@1.0.3/dist/panasonic-doas-accessory.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/homebridge-panasonic-doas@1.0.3/dist/panasonic-doas-accessory.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\";\nconst rs485_connnector_1 = require(\"./rs485-connnector\");\nconst PLATFORM_NAME = \"panasonic-doas\";\n/*\n * IMPORTANT NOTICE\n *\n * One thing you need to take care of is, that you never ever ever import anything directly from the \"homebridge\" module (or the \"hap-nodejs\" module).\n * The above import block may seem like, that we do exactly that, but actually those imports are only used for types and interfaces\n * and will disappear once the code is compiled to Javascript.\n * In fact you can check that by running `npm run build` and opening the compiled Javascript file in the `dist` folder.\n * You will notice that the file does not contain a `... = require(\"homebridge\");` statement anywhere in the code.\n *\n * The contents of the above import statement MUST ONLY be used for type annotation or accessing things like CONST ENUMS,\n * which is a special case as they get replaced by the actual value and do not remain as a reference in the compiled code.\n * Meaning normal enums are bad, const enums can be used.\n *\n * You MUST NOT import anything else which remains as a reference in the code, as this will result in\n * a `... = require(\"homebridge\");` to be compiled into the final Javascript code.\n * This typically leads to unexpected behavior at runtime, as in many cases it won't be able to find the module\n * or will import another instance of homebridge causing collisions.\n *\n * To mitigate this the {@link API | Homebridge API} exposes the whole suite of HAP-NodeJS inside the `hap` property\n * of the api object, which can be acquired for example in the initializer function. This reference can be stored\n * like this for example and used to access all exported variables and classes from HAP-NodeJS.\n */\nlet hap;\nclass PanasonicPlatform {\n    constructor(log, config, api) {\n        this.log = log;\n        this.config = config;\n        // probably parse config or something here\n        log.info(\"Panasonic platform finished initializing!\");\n    }\n    /*\n     * This method is called to retrieve all accessories exposed by the platform.\n     * The Platform can delay the response my invoking the callback at a later time,\n     * it will delay the bridge startup though, so keep it to a minimum.\n     * The set of exposed accessories CANNOT change over the lifetime of the plugin!\n     */\n    accessories(callback) {\n        const doas = new PanasonicDoas(this.log, this.config.host, this.config.port, this.config.machine_id);\n        callback([doas]);\n    }\n}\nclass PanasonicDoas {\n    constructor(log, host, port, machine_id) {\n        this.homeKitStateToPanasonicState = (d) => {\n            switch (d) {\n                case 0:\n                    return 0;\n                case 1:\n                    return 2;\n            }\n            return 0;\n        };\n        this.panasonicStateToHomeKitState = (d) => {\n            switch (d) {\n                case 0:\n                    return 0;\n                case 2:\n                    return 1;\n                case 5:\n                    return 0;\n            }\n            return 0;\n        };\n        this.homeKitSpeedToPanasonicSpeed = (d) => {\n            if (d <= 30) {\n                return 1;\n            }\n            else if (d < 70) {\n                return 2;\n            }\n            else {\n                return 3;\n            }\n        };\n        this.panasonicSpeedToHomeKitSpeed = (d) => {\n            switch (d) {\n                case 1:\n                    return 5;\n                case 2:\n                    return 50;\n                case 3:\n                    return 100;\n            }\n            return 0;\n        };\n        this.log = log;\n        this.name = 'DOAS';\n        this.connector = new rs485_connnector_1.Rs485Connnector(host, port, machine_id, log);\n        this.airPurifierService = new hap.Service.Fan(this.name);\n        this.airPurifierService.getCharacteristic(hap.Characteristic.On)\n            .on(\"get\" /* GET */, (callback) => {\n            log.info(\"Requesting get On of the air purifier...\");\n            this.connector.readPos(0x01, data => {\n                log.info(\"Current On of the air purifier was returned: \" + !!data);\n                callback(undefined, !!data);\n            });\n        })\n            .on(\"set\" /* SET */, (value, callback) => {\n            log.info(\"Requesting set On of the air purifier...\");\n            this.connector.writePos(0x01, value ? 0x01 : 0x00, () => {\n                log.info(\"Current On of the air purifier was set: \" + value);\n                callback();\n            });\n        });\n        this.airPurifierService.getCharacteristic(hap.Characteristic.RotationDirection)\n            .on(\"get\" /* GET */, (callback) => {\n            log.info(\"Requesting get direction of the air purifier...\");\n            this.connector.readPos(0x02, data => {\n                const mode = this.panasonicStateToHomeKitState(data);\n                log.info(\"Current direction of the air purifier was returned: \" + mode);\n                callback(undefined, mode);\n            });\n        })\n            .on(\"set\" /* SET */, (value, callback) => {\n            log.info(\"Requesting set direction of the air purifier...\");\n            this.connector.writePos(0x02, this.homeKitStateToPanasonicState(value), () => {\n                log.info(\"Current direction of the air purifier was set: \" + value);\n                callback();\n            });\n        });\n        this.airPurifierService.getCharacteristic(hap.Characteristic.RotationSpeed)\n            .on(\"get\" /* GET */, (callback) => {\n            log.info(\"Requesting get speed of the air purifier...\");\n            this.connector.readPos(0x03, data => {\n                const mode = this.panasonicSpeedToHomeKitSpeed(data);\n                log.info(\"Current speed of the air purifier was returned: \" + mode);\n                callback(undefined, mode);\n            });\n        })\n            .on(\"set\" /* SET */, (value, callback) => {\n            log.info(\"Requesting set speed of the air purifier...\");\n            this.connector.writePos(0x03, this.homeKitSpeedToPanasonicSpeed(value), () => {\n                log.info(\"Current speed of the air purifier was set: \" + value);\n                callback();\n            });\n        });\n        this.informationService = new hap.Service.AccessoryInformation()\n            .setCharacteristic(hap.Characteristic.Manufacturer, \"Panasonic\")\n            .setCharacteristic(hap.Characteristic.Model, \"FY-RS15ZDP2C\");\n        log.info(\"DOAS finished initializing!\");\n    }\n    /*\n     * This method is optional to implement. It is called when HomeKit ask to identify the accessory.\n     * Typical this only ever happens at the pairing process.\n     */\n    identify() {\n        this.log(\"Identify!\");\n    }\n    /*\n     * This method is called directly after creation of this instance.\n     * It should return all services which should be added to the accessory.\n     */\n    getServices() {\n        return [\n            this.informationService,\n            this.airPurifierService,\n        ];\n    }\n}\nmodule.exports = (api) => {\n    hap = api.hap;\n    api.registerPlatform(PLATFORM_NAME, PanasonicPlatform);\n};\n"]}