├── .eslintrc ├── .github ├── ISSUE_TEMPLATE │ ├── bug-report.md │ ├── config.yml │ ├── feature-request.md │ └── support-request.md └── workflows │ └── build.yml ├── .gitignore ├── .npmignore ├── CHANGELOG.md ├── LICENSE ├── README.md ├── config.schema.json ├── nodemon.json ├── package-lock.json ├── package.json ├── src ├── PollingService.ts ├── SynologyAccessory.ts └── syno.d.ts └── tsconfig.json /.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "parser": "@typescript-eslint/parser", 3 | "extends": [ 4 | "eslint:recommended", 5 | "plugin:@typescript-eslint/eslint-recommended", 6 | "plugin:@typescript-eslint/recommended" // uses the recommended rules from the @typescript-eslint/eslint-plugin 7 | ], 8 | "parserOptions": { 9 | "ecmaVersion": 2018, 10 | "sourceType": "module" 11 | }, 12 | "ignorePatterns": [ 13 | "dist" 14 | ], 15 | "rules": { 16 | "quotes": ["warn", "single"], 17 | "indent": ["warn", 2, { "SwitchCase": 1 }], 18 | "semi": ["off"], 19 | "comma-dangle": ["warn", "always-multiline"], 20 | "dot-notation": "off", 21 | "eqeqeq": "warn", 22 | "curly": ["warn", "all"], 23 | "brace-style": ["warn"], 24 | "prefer-arrow-callback": ["warn"], 25 | "max-len": ["warn", 140], 26 | "no-console": ["warn"], // use the provided Homebridge log method instead 27 | "no-non-null-assertion": ["off"], 28 | "comma-spacing": ["error"], 29 | "no-multi-spaces": ["warn", { "ignoreEOLComments": true }], 30 | "no-trailing-spaces": ["warn"], 31 | "lines-between-class-members": ["warn", "always", {"exceptAfterSingleLine": true}], 32 | "@typescript-eslint/explicit-function-return-type": "off", 33 | "@typescript-eslint/no-non-null-assertion": "off", 34 | "@typescript-eslint/explicit-module-boundary-types": "off", 35 | "@typescript-eslint/semi": ["warn"], 36 | "@typescript-eslint/member-delimiter-style": ["warn"] 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug-report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug Report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: bug 6 | assignees: '' 7 | 8 | --- 9 | 10 | 11 | 12 | **Describe The Bug:** 13 | 14 | 15 | **To Reproduce:** 16 | 17 | 18 | **Expected behavior:** 19 | 20 | 21 | **Logs:** 22 | 23 | ``` 24 | Show the Homebridge logs here, remove any sensitive information. 25 | ``` 26 | 27 | **Plugin Config:** 28 | 29 | ```json 30 | Show your Homebridge config.json here, remove any sensitive information. 31 | ``` 32 | 33 | **Screenshots:** 34 | 35 | 36 | **Environment:** 37 | 38 | * **Plugin Version**: 39 | * **Homebridge Version**: 40 | * **Node.js Version**: 41 | * **NPM Version**: 42 | * **Operating System**: 43 | 44 | 45 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | # blank_issues_enabled: false 2 | # contact_links: 3 | # - name: Homebridge Discord Community 4 | # url: https://discord.gg/kqNCe2D 5 | # about: Ask your questions in the #YOUR_CHANNEL_HERE channel -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature-request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature Request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: enhancement 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe:** 11 | 12 | 13 | **Describe the solution you'd like:** 14 | 15 | 16 | **Describe alternatives you've considered:** 17 | 18 | 19 | **Additional context:** 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/support-request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Support Request 3 | about: Need help? 4 | title: '' 5 | labels: question 6 | assignees: '' 7 | 8 | --- 9 | 10 | 11 | 12 | **Describe Your Problem:** 13 | 14 | 15 | **Logs:** 16 | 17 | ``` 18 | Show the Homebridge logs here, remove any sensitive information. 19 | ``` 20 | 21 | **Plugin Config:** 22 | 23 | ```json 24 | Show your Homebridge config.json here, remove any sensitive information. 25 | ``` 26 | 27 | **Screenshots:** 28 | 29 | 30 | **Environment:** 31 | 32 | * **Plugin Version**: 33 | * **Homebridge Version**: 34 | * **Node.js Version**: 35 | * **NPM Version**: 36 | * **Operating System**: 37 | 38 | 39 | -------------------------------------------------------------------------------- /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | name: Build and Lint 2 | 3 | on: [push, pull_request] 4 | 5 | jobs: 6 | build: 7 | runs-on: ubuntu-latest 8 | 9 | strategy: 10 | matrix: 11 | # the Node.js versions to build on 12 | node-version: [10.x, 12.x, 13.x, 14.x, 15.x] 13 | 14 | steps: 15 | - uses: actions/checkout@v2 16 | 17 | - name: Use Node.js ${{ matrix.node-version }} 18 | uses: actions/setup-node@v1 19 | with: 20 | node-version: ${{ matrix.node-version }} 21 | 22 | - name: Install dependencies 23 | run: npm install 24 | 25 | - name: Lint the project 26 | run: npm run lint 27 | 28 | - name: Build the project 29 | run: npm run build 30 | env: 31 | CI: true 32 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore compiled code 2 | dist 3 | 4 | # ------------- Defaults ------------- # 5 | 6 | # Logs 7 | logs 8 | *.log 9 | npm-debug.log* 10 | yarn-debug.log* 11 | yarn-error.log* 12 | lerna-debug.log* 13 | 14 | # Diagnostic reports (https://nodejs.org/api/report.html) 15 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json 16 | 17 | # Runtime data 18 | pids 19 | *.pid 20 | *.seed 21 | *.pid.lock 22 | 23 | # Directory for instrumented libs generated by jscoverage/JSCover 24 | lib-cov 25 | 26 | # Coverage directory used by tools like istanbul 27 | coverage 28 | *.lcov 29 | 30 | # nyc test coverage 31 | .nyc_output 32 | 33 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) 34 | .grunt 35 | 36 | # Bower dependency directory (https://bower.io/) 37 | bower_components 38 | 39 | # node-waf configuration 40 | .lock-wscript 41 | 42 | # Compiled binary addons (https://nodejs.org/api/addons.html) 43 | build/Release 44 | 45 | # Dependency directories 46 | node_modules/ 47 | jspm_packages/ 48 | 49 | # Snowpack dependency directory (https://snowpack.dev/) 50 | web_modules/ 51 | 52 | # TypeScript cache 53 | *.tsbuildinfo 54 | 55 | # Optional npm cache directory 56 | .npm 57 | 58 | # Optional eslint cache 59 | .eslintcache 60 | 61 | # Microbundle cache 62 | .rpt2_cache/ 63 | .rts2_cache_cjs/ 64 | .rts2_cache_es/ 65 | .rts2_cache_umd/ 66 | 67 | # Optional REPL history 68 | .node_repl_history 69 | 70 | # Output of 'npm pack' 71 | *.tgz 72 | 73 | # Yarn Integrity file 74 | .yarn-integrity 75 | 76 | # dotenv environment variables file 77 | .env 78 | .env.test 79 | 80 | # parcel-bundler cache (https://parceljs.org/) 81 | .cache 82 | .parcel-cache 83 | 84 | # Next.js build output 85 | .next 86 | 87 | # Nuxt.js build / generate output 88 | .nuxt 89 | dist 90 | 91 | # Gatsby files 92 | .cache/ 93 | # Comment in the public line in if your project uses Gatsby and not Next.js 94 | # https://nextjs.org/blog/next-9-1#public-directory-support 95 | # public 96 | 97 | # vuepress build output 98 | .vuepress/dist 99 | 100 | # Serverless directories 101 | .serverless/ 102 | 103 | # FuseBox cache 104 | .fusebox/ 105 | 106 | # DynamoDB Local files 107 | .dynamodb/ 108 | 109 | # TernJS port file 110 | .tern-port 111 | 112 | # Stores VSCode versions used for testing VSCode extensions 113 | .vscode-test 114 | 115 | # yarn v2 116 | 117 | .yarn/cache 118 | .yarn/unplugged 119 | .yarn/build-state.yml 120 | .pnp.* -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | # Ignore source code 2 | src 3 | 4 | # ------------- Defaults ------------- # 5 | 6 | # gitHub actions 7 | .github 8 | 9 | # eslint 10 | .eslintrc 11 | 12 | # typescript 13 | tsconfig.json 14 | 15 | # vscode 16 | .vscode 17 | 18 | # nodemon 19 | nodemon.json 20 | 21 | # Logs 22 | logs 23 | *.log 24 | npm-debug.log* 25 | yarn-debug.log* 26 | yarn-error.log* 27 | lerna-debug.log* 28 | 29 | # Diagnostic reports (https://nodejs.org/api/report.html) 30 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json 31 | 32 | # Runtime data 33 | pids 34 | *.pid 35 | *.seed 36 | *.pid.lock 37 | 38 | # Directory for instrumented libs generated by jscoverage/JSCover 39 | lib-cov 40 | 41 | # Coverage directory used by tools like istanbul 42 | coverage 43 | *.lcov 44 | 45 | # nyc test coverage 46 | .nyc_output 47 | 48 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) 49 | .grunt 50 | 51 | # Bower dependency directory (https://bower.io/) 52 | bower_components 53 | 54 | # node-waf configuration 55 | .lock-wscript 56 | 57 | # Compiled binary addons (https://nodejs.org/api/addons.html) 58 | build/Release 59 | 60 | # Dependency directories 61 | node_modules/ 62 | jspm_packages/ 63 | 64 | # Snowpack dependency directory (https://snowpack.dev/) 65 | web_modules/ 66 | 67 | # TypeScript cache 68 | *.tsbuildinfo 69 | 70 | # Optional npm cache directory 71 | .npm 72 | 73 | # Optional eslint cache 74 | .eslintcache 75 | 76 | # Microbundle cache 77 | .rpt2_cache/ 78 | .rts2_cache_cjs/ 79 | .rts2_cache_es/ 80 | .rts2_cache_umd/ 81 | 82 | # Optional REPL history 83 | .node_repl_history 84 | 85 | # Output of 'npm pack' 86 | *.tgz 87 | 88 | # Yarn Integrity file 89 | .yarn-integrity 90 | 91 | # dotenv environment variables file 92 | .env 93 | .env.test 94 | 95 | # parcel-bundler cache (https://parceljs.org/) 96 | .cache 97 | .parcel-cache 98 | 99 | # Next.js build output 100 | .next 101 | 102 | # Nuxt.js build / generate output 103 | .nuxt 104 | dist 105 | 106 | # Gatsby files 107 | .cache/ 108 | # Comment in the public line in if your project uses Gatsby and not Next.js 109 | # https://nextjs.org/blog/next-9-1#public-directory-support 110 | # public 111 | 112 | # vuepress build output 113 | .vuepress/dist 114 | 115 | # Serverless directories 116 | .serverless/ 117 | 118 | # FuseBox cache 119 | .fusebox/ 120 | 121 | # DynamoDB Local files 122 | .dynamodb/ 123 | 124 | # TernJS port file 125 | .tern-port 126 | 127 | # Stores VSCode versions used for testing VSCode extensions 128 | .vscode-test 129 | 130 | # yarn v2 131 | 132 | .yarn/cache 133 | .yarn/unplugged 134 | .yarn/build-state.yml 135 | .pnp.* -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | ## [0.5.0] - 2021-12-16 4 | - added average disk temperature 5 | 6 | ## [0.4.1] - 2021-10-13 7 | - fixed typo in config schema 8 | - fixed protocol configuration 9 | - updated readme 10 | 11 | ## [0.4.0] - 2021-10-12 12 | - totally rewritten in typescript 13 | - added support for 2FA 14 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2021 Stefan Himpler 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |
Follow the instruction in NPM for the homebridge server installation. The plugin is published through NPM and should be installed "globally" by typing:
15 | 16 | ``` 17 | sudo npm install -g homebridge-synology 18 | ``` 19 | 20 | ## 🛠️ Configuration 21 | Edit your `config.json` and add a new accessory. Example: 22 | 23 | ```json 24 | { 25 | "bridge": { 26 | "name": "Homebridge", 27 | "username": "CC:22:3D:E3:CE:51", 28 | "port": 51826, 29 | "pin": "031-45-154" 30 | }, 31 | "description": "This is an example configuration file for the homebridge synology plugin", 32 | "hint": "Always paste into jsonlint.com validation page before starting your homebridge, saves a lot of frustration", 33 | "accessories": [ 34 | { 35 | "accessory": "synology", 36 | "name": "Diskstation", 37 | "host": "192.168.1.1", 38 | "mac": "A1:B2:C3:D4:E5:F6", 39 | "port": 5000, 40 | "protocol": "http", 41 | "username": "your-username", 42 | "password": "your-password", 43 | "version": "6.2.2", 44 | "otp": "otp-code for 2FA", 45 | "startupTime": 60, 46 | "shutdownTime": 60, 47 | "disabled": [], 48 | } 49 | ] 50 | } 51 | ``` 52 | ### Some explanations 53 | - **Version:** Your current DSM Version. **Important:** If you are using DSM version > 6.2.2 or DSM 7, enter `6.2.2` here anyway. 54 | - **OTP (optional):** If you have enabled 2-Factor-Authentication, the code must be entered here. For more information, see https://github.com/iobroker-community-adapters/ioBroker.synology/blob/HEAD/docs/en/template.md 55 | - **Startup and shutdown time (optional):** You can specify a duration for the startup and the shutdown process. During this time, there is no status change due to polling. Both defaults to 60s. 56 | - **disabled (optional):** You can disable features. The services to be deactivated must be specified as an array of strings, such as `["switch", "temperature", "diskTemperature"]`. If you disable the switch functionality, you can't start or stop your diskstation anymore. 57 | 58 | ## 🛡️ License 59 | This project is licensed under the MIT 60 | -------------------------------------------------------------------------------- /config.schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "pluginAlias": "synology", 3 | "pluginType": "accessory", 4 | "singular": false, 5 | "schema": { 6 | "type": "object", 7 | "properties": { 8 | "name": { 9 | "title": "Name", 10 | "type": "string", 11 | "required": true, 12 | "default": "Diskstation" 13 | }, 14 | "host": { 15 | "title": "Host", 16 | "type": "string", 17 | "required": true, 18 | "default": "" 19 | }, 20 | "mac": { 21 | "title": "Mac Address", 22 | "type": "string", 23 | "required": true, 24 | "default": "" 25 | }, 26 | "port": { 27 | "title": "Port", 28 | "type": "number", 29 | "required": true, 30 | "default": 5000 31 | }, 32 | "username": { 33 | "title": "Username", 34 | "type": "string", 35 | "required": true, 36 | "default": "admin" 37 | }, 38 | "password": { 39 | "title": "Password", 40 | "type": "string", 41 | "required": true, 42 | "default": "" 43 | }, 44 | "protocol": { 45 | "title": "Protocol", 46 | "type": "string", 47 | "required": true, 48 | "default": "http" 49 | }, 50 | "version": { 51 | "title": "Version", 52 | "type": "string", 53 | "required": true, 54 | "default": "6.2.2" 55 | }, 56 | "startupTime": { 57 | "title": "Startup Time", 58 | "type": "number", 59 | "default": 60, 60 | "required": false 61 | }, 62 | "shutdownTime": { 63 | "title": "Shutdown Time", 64 | "type": "number", 65 | "default": 60, 66 | "required": false 67 | }, 68 | "disabled": { 69 | "title": "Disabled services", 70 | "type": "Array", 71 | "default": [], 72 | "required": false 73 | }, 74 | "otp": { 75 | "title": "OTP-Code", 76 | "type": "string", 77 | "required": false 78 | } 79 | } 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /nodemon.json: -------------------------------------------------------------------------------- 1 | { 2 | "watch": [ 3 | "src" 4 | ], 5 | "ext": "ts", 6 | "ignore": [], 7 | "exec": "tsc && homebridge -I -D", 8 | "signal": "SIGTERM", 9 | "env": { 10 | "NODE_OPTIONS": "--trace-warnings" 11 | } 12 | } -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "displayName": "Homebridge Synology", 3 | "name": "homebridge-synology", 4 | "version": "0.5.2", 5 | "description": "Control your Synology Diskstation with Homekit", 6 | "license": "MIT", 7 | "repository": { 8 | "type": "git", 9 | "url": "git://github.com/stfnhmplr/homebridge-synology.git" 10 | }, 11 | "bugs": { 12 | "url": "https://github.com/stfnhmplr/homebridge-synology/issues" 13 | }, 14 | "engines": { 15 | "node": ">=10.17.0", 16 | "homebridge": ">=1.3.0" 17 | }, 18 | "main": "dist/SynologyAccessory.js", 19 | "scripts": { 20 | "lint": "eslint src/**.ts --max-warnings=0", 21 | "lint:fix": "eslint src/**.ts --max-warnings=0 --fix", 22 | "watch": "npm run build && npm link && nodemon", 23 | "build": "rimraf ./dist && tsc", 24 | "prepublishOnly": "npm run lint && npm run build" 25 | }, 26 | "keywords": [ 27 | "homebridge-plugin", 28 | "synology", 29 | "diskstation" 30 | ], 31 | "dependencies": { 32 | "@types/ping": "^0.2.0", 33 | "@types/wol": "^1.0.0", 34 | "axios": "^0.21.1", 35 | "syno": "https://github.com/homeinstalator/syno", 36 | "wol": "^1.0.7" 37 | }, 38 | "devDependencies": { 39 | "@types/node": "^14.14.31", 40 | "@typescript-eslint/eslint-plugin": "^4.16.1", 41 | "@typescript-eslint/parser": "^4.16.1", 42 | "eslint": "^7.21.0", 43 | "homebridge": "^1.3.1", 44 | "nodemon": "^2.0.7", 45 | "rimraf": "^3.0.2", 46 | "ts-node": "^9.1.1", 47 | "typescript": "^4.2.2" 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/PollingService.ts: -------------------------------------------------------------------------------- 1 | import EventEmitter from 'events'; 2 | 3 | interface PollingFunction { 4 | (): void; 5 | } 6 | 7 | export default class PollingService extends EventEmitter { 8 | private readonly req: PollingFunction; 9 | private readonly interval: number; 10 | private intervalId?: ReturnType