├── JavaScript ├── .create-adapter.json ├── .eslintignore ├── .eslintrc.json ├── .github │ ├── ISSUE_TEMPLATE │ │ └── bug_report.md │ ├── auto-merge.yml │ ├── dependabot.yml │ └── workflows │ │ ├── dependabot-auto-merge.yml │ │ └── test-and-release.yml ├── .gitignore ├── .releaseconfig.json ├── .vscode │ ├── extensions.json │ └── settings.json ├── LICENSE ├── README.md ├── admin │ ├── admin.d.ts │ ├── custom_m.html │ ├── i18n │ │ ├── de │ │ │ └── translations.json │ │ ├── en │ │ │ └── translations.json │ │ ├── es │ │ │ └── translations.json │ │ ├── fr │ │ │ └── translations.json │ │ ├── it │ │ │ └── translations.json │ │ ├── nl │ │ │ └── translations.json │ │ ├── pl │ │ │ └── translations.json │ │ ├── pt │ │ │ └── translations.json │ │ ├── ru │ │ │ └── translations.json │ │ ├── uk │ │ │ └── translations.json │ │ └── zh-cn │ │ │ └── translations.json │ ├── jsonConfig.json │ ├── tab_m.html │ ├── template.png │ └── words.js ├── io-package.json ├── lib │ └── adapter-config.d.ts ├── main.js ├── main.test.js ├── package.json ├── test │ ├── integration.js │ ├── mocha.setup.js │ ├── mocharc.custom.json │ ├── package.js │ └── tsconfig.json ├── tsconfig.check.json └── tsconfig.json ├── JavaScriptReact ├── .create-adapter.json ├── .eslintignore ├── .eslintrc.json ├── .github │ ├── ISSUE_TEMPLATE │ │ └── bug_report.md │ ├── auto-merge.yml │ ├── dependabot.yml │ └── workflows │ │ ├── dependabot-auto-merge.yml │ │ └── test-and-release.yml ├── .gitignore ├── .releaseconfig.json ├── .vscode │ ├── extensions.json │ └── settings.json ├── LICENSE ├── README.md ├── admin │ ├── .eslintrc.json │ ├── custom_m.html │ ├── index_m.html │ ├── src │ │ ├── app.jsx │ │ ├── components │ │ │ └── settings.jsx │ │ ├── i18n │ │ │ ├── de.json │ │ │ ├── en.json │ │ │ ├── es.json │ │ │ ├── fr.json │ │ │ ├── i18n.d.ts │ │ │ ├── it.json │ │ │ ├── nl.json │ │ │ ├── pl.json │ │ │ ├── pt.json │ │ │ ├── ru.json │ │ │ ├── uk.json │ │ │ └── zh-cn.json │ │ ├── index.jsx │ │ ├── tab-app.jsx │ │ └── tab.jsx │ ├── style.css │ ├── tab_m.html │ ├── template.png │ └── tsconfig.json ├── io-package.json ├── lib │ └── adapter-config.d.ts ├── main.js ├── main.test.js ├── package.json ├── test │ ├── integration.js │ ├── mocha.setup.js │ ├── mocharc.custom.json │ ├── package.js │ └── tsconfig.json ├── tsconfig.check.json └── tsconfig.json ├── JavaScriptVIS ├── .create-adapter.json ├── .eslintignore ├── .eslintrc.json ├── .github │ ├── ISSUE_TEMPLATE │ │ └── bug_report.md │ ├── auto-merge.yml │ ├── dependabot.yml │ └── workflows │ │ ├── dependabot-auto-merge.yml │ │ └── test-and-release.yml ├── .gitignore ├── .releaseconfig.json ├── .vscode │ ├── extensions.json │ └── settings.json ├── LICENSE ├── README.md ├── admin │ ├── admin.d.ts │ ├── custom_m.html │ ├── i18n │ │ ├── de │ │ │ └── translations.json │ │ ├── en │ │ │ └── translations.json │ │ ├── es │ │ │ └── translations.json │ │ ├── fr │ │ │ └── translations.json │ │ ├── it │ │ │ └── translations.json │ │ ├── nl │ │ │ └── translations.json │ │ ├── pl │ │ │ └── translations.json │ │ ├── pt │ │ │ └── translations.json │ │ ├── ru │ │ │ └── translations.json │ │ ├── uk │ │ │ └── translations.json │ │ └── zh-cn │ │ │ └── translations.json │ ├── jsonConfig.json │ ├── tab_m.html │ ├── template.png │ └── words.js ├── io-package.json ├── lib │ └── adapter-config.d.ts ├── main.js ├── main.test.js ├── package.json ├── test │ ├── integration.js │ ├── mocha.setup.js │ ├── mocharc.custom.json │ ├── package.js │ └── tsconfig.json ├── tsconfig.check.json ├── tsconfig.json └── widgets │ ├── .eslintrc.json │ ├── template.html │ └── template │ ├── css │ └── style.css │ └── js │ └── template.js ├── README.md ├── TypeScript ├── .create-adapter.json ├── .eslintignore ├── .eslintrc.js ├── .github │ ├── ISSUE_TEMPLATE │ │ └── bug_report.md │ ├── auto-merge.yml │ ├── dependabot.yml │ └── workflows │ │ ├── dependabot-auto-merge.yml │ │ └── test-and-release.yml ├── .gitignore ├── .releaseconfig.json ├── .vscode │ ├── extensions.json │ └── settings.json ├── LICENSE ├── README.md ├── admin │ ├── admin.d.ts │ ├── custom_m.html │ ├── i18n │ │ ├── de │ │ │ └── translations.json │ │ ├── en │ │ │ └── translations.json │ │ ├── es │ │ │ └── translations.json │ │ ├── fr │ │ │ └── translations.json │ │ ├── it │ │ │ └── translations.json │ │ ├── nl │ │ │ └── translations.json │ │ ├── pl │ │ │ └── translations.json │ │ ├── pt │ │ │ └── translations.json │ │ ├── ru │ │ │ └── translations.json │ │ ├── uk │ │ │ └── translations.json │ │ └── zh-cn │ │ │ └── translations.json │ ├── jsonConfig.json │ ├── tab_m.html │ ├── template.png │ └── words.js ├── io-package.json ├── package.json ├── src │ ├── lib │ │ └── adapter-config.d.ts │ ├── main.test.ts │ └── main.ts ├── test │ ├── .eslintrc.json │ ├── integration.js │ ├── mocha.setup.js │ ├── mocharc.custom.json │ ├── package.js │ └── tsconfig.json ├── tsconfig.build.json └── tsconfig.json ├── TypeScriptReact ├── .create-adapter.json ├── .eslintignore ├── .eslintrc.js ├── .github │ ├── ISSUE_TEMPLATE │ │ └── bug_report.md │ ├── auto-merge.yml │ ├── dependabot.yml │ └── workflows │ │ ├── dependabot-auto-merge.yml │ │ └── test-and-release.yml ├── .gitignore ├── .releaseconfig.json ├── .vscode │ ├── extensions.json │ └── settings.json ├── LICENSE ├── README.md ├── admin │ ├── custom_m.html │ ├── index_m.html │ ├── src │ │ ├── app.tsx │ │ ├── components │ │ │ └── settings.tsx │ │ ├── i18n │ │ │ ├── de.json │ │ │ ├── en.json │ │ │ ├── es.json │ │ │ ├── fr.json │ │ │ ├── i18n.d.ts │ │ │ ├── it.json │ │ │ ├── nl.json │ │ │ ├── pl.json │ │ │ ├── pt.json │ │ │ ├── ru.json │ │ │ ├── uk.json │ │ │ └── zh-cn.json │ │ ├── index.tsx │ │ ├── tab-app.tsx │ │ └── tab.tsx │ ├── style.css │ ├── tab_m.html │ ├── template.png │ └── tsconfig.json ├── io-package.json ├── package.json ├── src │ ├── lib │ │ └── adapter-config.d.ts │ ├── main.test.ts │ └── main.ts ├── test │ ├── .eslintrc.json │ ├── integration.js │ ├── mocha.setup.js │ ├── mocharc.custom.json │ ├── package.js │ └── tsconfig.json ├── tsconfig.build.json └── tsconfig.json ├── TypeScriptVIS ├── .create-adapter.json ├── .eslintignore ├── .eslintrc.js ├── .github │ ├── ISSUE_TEMPLATE │ │ └── bug_report.md │ ├── auto-merge.yml │ ├── dependabot.yml │ └── workflows │ │ ├── dependabot-auto-merge.yml │ │ └── test-and-release.yml ├── .gitignore ├── .releaseconfig.json ├── .vscode │ ├── extensions.json │ └── settings.json ├── LICENSE ├── README.md ├── admin │ ├── admin.d.ts │ ├── custom_m.html │ ├── i18n │ │ ├── de │ │ │ └── translations.json │ │ ├── en │ │ │ └── translations.json │ │ ├── es │ │ │ └── translations.json │ │ ├── fr │ │ │ └── translations.json │ │ ├── it │ │ │ └── translations.json │ │ ├── nl │ │ │ └── translations.json │ │ ├── pl │ │ │ └── translations.json │ │ ├── pt │ │ │ └── translations.json │ │ ├── ru │ │ │ └── translations.json │ │ ├── uk │ │ │ └── translations.json │ │ └── zh-cn │ │ │ └── translations.json │ ├── jsonConfig.json │ ├── tab_m.html │ ├── template.png │ └── words.js ├── io-package.json ├── package.json ├── src │ ├── lib │ │ └── adapter-config.d.ts │ ├── main.test.ts │ └── main.ts ├── test │ ├── .eslintrc.json │ ├── integration.js │ ├── mocha.setup.js │ ├── mocharc.custom.json │ ├── package.js │ └── tsconfig.json ├── tsconfig.build.json ├── tsconfig.json └── widgets │ ├── .eslintrc.json │ ├── template.html │ └── template │ ├── css │ └── style.css │ └── js │ └── template.js ├── VIS ├── .create-adapter.json ├── .github │ ├── ISSUE_TEMPLATE │ │ └── bug_report.md │ ├── auto-merge.yml │ ├── dependabot.yml │ └── workflows │ │ ├── dependabot-auto-merge.yml │ │ └── test-and-release.yml ├── .gitignore ├── .releaseconfig.json ├── LICENSE ├── README.md ├── admin │ ├── template.png │ └── words.js ├── io-package.json ├── package.json ├── test │ ├── mocha.setup.js │ ├── mocharc.custom.json │ └── package.js └── widgets │ ├── .eslintrc.json │ ├── template.html │ └── template │ ├── css │ └── style.css │ └── js │ └── template.js └── icon.png /JavaScript/.create-adapter.json: -------------------------------------------------------------------------------- 1 | { 2 | "cli": true, 3 | "target": "directory", 4 | "adapterName": "template", 5 | "description": "Template for adapter development", 6 | "authorName": "Author", 7 | "authorGithub": "Author", 8 | "authorEmail": "author@mail.com", 9 | "gitRemoteProtocol": "HTTPS", 10 | "dependabot": "yes", 11 | "license": "MIT License", 12 | "releaseScript": "yes", 13 | "gitCommit": "no", 14 | "defaultBranch": "main", 15 | "startMode": "daemon", 16 | "features": [ 17 | "adapter" 18 | ], 19 | "connectionIndicator": "no", 20 | "type": "general", 21 | "adminFeatures": [ 22 | "custom", 23 | "tab" 24 | ], 25 | "adminUi": "json", 26 | "tabReact": "no", 27 | "language": "JavaScript", 28 | "title": "Template (JavaScript)", 29 | "tools": [ 30 | "ESLint", 31 | "type checking" 32 | ], 33 | "indentation": "Space (4)", 34 | "quotes": "single", 35 | "creatorVersion": "2.6.5" 36 | } -------------------------------------------------------------------------------- /JavaScript/.eslintignore: -------------------------------------------------------------------------------- 1 | **/.eslintrc.js 2 | admin/words.js -------------------------------------------------------------------------------- /JavaScript/.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "root": true, 3 | "env": { 4 | "es6": true, 5 | "node": true, 6 | "mocha": true 7 | }, 8 | "extends": [ 9 | "eslint:recommended" 10 | ], 11 | "plugins": [], 12 | "rules": { 13 | "indent": [ 14 | "error", 15 | 4, 16 | { 17 | "SwitchCase": 1 18 | } 19 | ], 20 | "no-console": "off", 21 | "no-unused-vars": [ 22 | "error", 23 | { 24 | "ignoreRestSiblings": true, 25 | "argsIgnorePattern": "^_" 26 | } 27 | ], 28 | "no-var": "error", 29 | "no-trailing-spaces": "error", 30 | "prefer-const": "error", 31 | "quotes": [ 32 | "error", 33 | "single", 34 | { 35 | "avoidEscape": true, 36 | "allowTemplateLiterals": true 37 | } 38 | ], 39 | "semi": [ 40 | "error", 41 | "always" 42 | ] 43 | }, 44 | "parserOptions": { 45 | "ecmaVersion": "latest" 46 | } 47 | } -------------------------------------------------------------------------------- /JavaScript/.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Something is not working as it should 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | --- 8 | 9 | **Describe the bug** 10 | A clear and concise description of what the bug is. 11 | 12 | **To Reproduce** 13 | Steps to reproduce the behavior: 14 | 1. Go to '...' 15 | 2. Click on '...' 16 | 3. Scroll down to '....' 17 | 4. See error 18 | 19 | **Expected behavior** 20 | A clear and concise description of what you expected to happen. 21 | 22 | **Screenshots & Logfiles** 23 | If applicable, add screenshots and logfiles to help explain your problem. 24 | 25 | **Versions:** 26 | - Adapter version: 27 | - JS-Controller version: 28 | - Node version: 29 | - Operating system: 30 | 31 | **Additional context** 32 | Add any other context about the problem here. 33 | -------------------------------------------------------------------------------- /JavaScript/.github/auto-merge.yml: -------------------------------------------------------------------------------- 1 | # Configure here which dependency updates should be merged automatically. 2 | # The recommended configuration is the following: 3 | - match: 4 | # Only merge patches for production dependencies 5 | dependency_type: production 6 | update_type: "semver:patch" 7 | - match: 8 | # Except for security fixes, here we allow minor patches 9 | dependency_type: production 10 | update_type: "security:minor" 11 | - match: 12 | # and development dependencies can have a minor update, too 13 | dependency_type: development 14 | update_type: "semver:minor" 15 | 16 | # The syntax is based on the legacy dependabot v1 automerged_updates syntax, see: 17 | # https://dependabot.com/docs/config-file/#automerged_updates 18 | -------------------------------------------------------------------------------- /JavaScript/.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: npm 4 | directory: "/" 5 | schedule: 6 | interval: monthly 7 | time: "04:00" 8 | timezone: Europe/Berlin 9 | open-pull-requests-limit: 5 10 | assignees: 11 | - Author 12 | versioning-strategy: increase 13 | 14 | - package-ecosystem: github-actions 15 | directory: "/" 16 | schedule: 17 | interval: monthly 18 | time: "04:00" 19 | timezone: Europe/Berlin 20 | open-pull-requests-limit: 5 21 | assignees: 22 | - Author 23 | -------------------------------------------------------------------------------- /JavaScript/.github/workflows/dependabot-auto-merge.yml: -------------------------------------------------------------------------------- 1 | # Automatically merge Dependabot PRs when version comparison is within the range 2 | # that is configured in .github/auto-merge.yml 3 | 4 | name: Auto-Merge Dependabot PRs 5 | 6 | on: 7 | # WARNING: This needs to be run in the PR base, DO NOT build untrusted code in this action 8 | # details under https://github.blog/changelog/2021-02-19-github-actions-workflows-triggered-by-dependabot-prs-will-run-with-read-only-permissions/ 9 | pull_request_target: 10 | 11 | jobs: 12 | auto-merge: 13 | if: github.actor == 'dependabot[bot]' 14 | runs-on: ubuntu-latest 15 | steps: 16 | - name: Checkout code 17 | uses: actions/checkout@v2 18 | 19 | - name: Check if PR should be auto-merged 20 | uses: ahmadnassri/action-dependabot-auto-merge@v2 21 | with: 22 | # In order to use this, you need to go to https://github.com/settings/tokens and 23 | # create a Personal Access Token with the permission "public_repo". 24 | # Enter this token in your repository settings under "Secrets" and name it AUTO_MERGE_TOKEN 25 | github-token: ${{ secrets.AUTO_MERGE_TOKEN }} 26 | # By default, squash and merge, so Github chooses nice commit messages 27 | command: squash and merge 28 | -------------------------------------------------------------------------------- /JavaScript/.gitignore: -------------------------------------------------------------------------------- 1 | # No dot-directories except github/vscode 2 | .*/ 3 | !.vscode/ 4 | !.github/ 5 | 6 | *.code-workspace 7 | node_modules 8 | nbproject 9 | 10 | # npm package files 11 | iobroker.*.tgz 12 | 13 | Thumbs.db 14 | 15 | # i18n intermediate files 16 | admin/i18n/flat.txt 17 | admin/i18n/*/flat.txt -------------------------------------------------------------------------------- /JavaScript/.releaseconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "plugins": [ 3 | "iobroker", 4 | "license", 5 | "manual-review" 6 | ] 7 | } -------------------------------------------------------------------------------- /JavaScript/.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | "recommendations": [ 3 | "dbaeumer.vscode-eslint" 4 | ] 5 | } -------------------------------------------------------------------------------- /JavaScript/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "eslint.enable": true, 3 | "json.schemas": [ 4 | { 5 | "fileMatch": [ 6 | "io-package.json" 7 | ], 8 | "url": "https://raw.githubusercontent.com/ioBroker/ioBroker.js-controller/master/schemas/io-package.json" 9 | }, 10 | { 11 | "fileMatch": [ 12 | "admin/jsonConfig.json", 13 | "admin/jsonCustom.json", 14 | "admin/jsonTab.json" 15 | ], 16 | "url": "https://raw.githubusercontent.com/ioBroker/adapter-react-v5/main/schemas/jsonConfig.json" 17 | } 18 | ] 19 | } -------------------------------------------------------------------------------- /JavaScript/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2024 Author 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 all 13 | 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 THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /JavaScript/admin/admin.d.ts: -------------------------------------------------------------------------------- 1 | declare let systemDictionary: Record>; 2 | 3 | declare let load: (settings: Record, onChange: (hasChanges: boolean) => void) => void; 4 | declare let save: (callback: (settings: Record) => void) => void; 5 | 6 | // make load and save exist on the window object 7 | interface Window { 8 | load: typeof load; 9 | save: typeof save; 10 | } 11 | 12 | declare const instance: number; 13 | declare const adapter: string; 14 | /** Translates text */ 15 | declare function _(text: string, arg1?: string, arg2?: string, arg3?: string): string; 16 | declare const socket: ioBrokerSocket; 17 | declare function sendTo( 18 | instance: any | null, 19 | command: string, 20 | message: any, 21 | callback: (result: SendToResult) => void | Promise, 22 | ): void; 23 | 24 | interface SendToResult { 25 | error?: string | Error; 26 | result?: any; 27 | } 28 | 29 | // tslint:disable-next-line:class-name 30 | interface ioBrokerSocket { 31 | emit( 32 | command: 'subscribeObjects', 33 | pattern: string, 34 | callback?: (err?: string) => void | Promise, 35 | ): void; 36 | emit( 37 | command: 'subscribeStates', 38 | pattern: string, 39 | callback?: (err?: string) => void | Promise, 40 | ): void; 41 | emit( 42 | command: 'unsubscribeObjects', 43 | pattern: string, 44 | callback?: (err?: string) => void | Promise, 45 | ): void; 46 | emit( 47 | command: 'unsubscribeStates', 48 | pattern: string, 49 | callback?: (err?: string) => void | Promise, 50 | ): void; 51 | 52 | emit( 53 | event: 'getObjectView', 54 | view: 'system', 55 | type: 'device', 56 | options: ioBroker.GetObjectViewParams, 57 | callback: ( 58 | err: string | undefined, 59 | result?: any, 60 | ) => void | Promise, 61 | ): void; 62 | emit( 63 | event: 'getStates', 64 | callback: ( 65 | err: string | undefined, 66 | result?: Record, 67 | ) => void, 68 | ): void; 69 | emit( 70 | event: 'getState', 71 | id: string, 72 | callback: (err: string | undefined, result?: ioBroker.State) => void, 73 | ): void; 74 | emit( 75 | event: 'setState', 76 | id: string, 77 | state: unknown, 78 | callback: (err: string | undefined, result?: any) => void, 79 | ): void; 80 | 81 | on(event: 'objectChange', handler: ioBroker.ObjectChangeHandler): void; 82 | on(event: 'stateChange', handler: ioBroker.StateChangeHandler): void; 83 | removeEventHandler( 84 | event: 'objectChange', 85 | handler: ioBroker.ObjectChangeHandler, 86 | ): void; 87 | removeEventHandler( 88 | event: 'stateChange', 89 | handler: ioBroker.StateChangeHandler, 90 | ): void; 91 | 92 | // TODO: other events 93 | } 94 | -------------------------------------------------------------------------------- /JavaScript/admin/custom_m.html: -------------------------------------------------------------------------------- 1 | 22 | 23 | -------------------------------------------------------------------------------- /JavaScript/admin/i18n/de/translations.json: -------------------------------------------------------------------------------- 1 | { 2 | "template adapter settings": "Adaptereinstellungen für template", 3 | "option1": "Option1", 4 | "option2": "Option2" 5 | } -------------------------------------------------------------------------------- /JavaScript/admin/i18n/en/translations.json: -------------------------------------------------------------------------------- 1 | { 2 | "template adapter settings": "Adapter settings for template", 3 | "option1": "option1", 4 | "option2": "option2" 5 | } -------------------------------------------------------------------------------- /JavaScript/admin/i18n/es/translations.json: -------------------------------------------------------------------------------- 1 | { 2 | "template adapter settings": "Ajustes del adaptador para template", 3 | "option1": "opción1", 4 | "option2": "opción2" 5 | } -------------------------------------------------------------------------------- /JavaScript/admin/i18n/fr/translations.json: -------------------------------------------------------------------------------- 1 | { 2 | "template adapter settings": "Paramètres d'adaptateur pour template", 3 | "option1": "option1", 4 | "option2": "option2" 5 | } -------------------------------------------------------------------------------- /JavaScript/admin/i18n/it/translations.json: -------------------------------------------------------------------------------- 1 | { 2 | "template adapter settings": "Impostazioni dell'adattatore per template", 3 | "option1": "opzione1", 4 | "option2": "opzione2" 5 | } -------------------------------------------------------------------------------- /JavaScript/admin/i18n/nl/translations.json: -------------------------------------------------------------------------------- 1 | { 2 | "template adapter settings": "Adapterinstellingen voor template", 3 | "option1": "optie1", 4 | "option2": "optie2" 5 | } -------------------------------------------------------------------------------- /JavaScript/admin/i18n/pl/translations.json: -------------------------------------------------------------------------------- 1 | { 2 | "template adapter settings": "Ustawienia adaptera dla template", 3 | "option1": "opcja 1", 4 | "option2": "opcja 2" 5 | } -------------------------------------------------------------------------------- /JavaScript/admin/i18n/pt/translations.json: -------------------------------------------------------------------------------- 1 | { 2 | "template adapter settings": "Configurações do adaptador para template", 3 | "option1": "opção1", 4 | "option2": "opção2" 5 | } -------------------------------------------------------------------------------- /JavaScript/admin/i18n/ru/translations.json: -------------------------------------------------------------------------------- 1 | { 2 | "template adapter settings": "Настройки адаптера для template", 3 | "option1": "вариант 1", 4 | "option2": "вариант2" 5 | } -------------------------------------------------------------------------------- /JavaScript/admin/i18n/uk/translations.json: -------------------------------------------------------------------------------- 1 | { 2 | "template adapter settings": "Налаштування адаптера для template", 3 | "option1": "варіант1", 4 | "option2": "варіант2" 5 | } -------------------------------------------------------------------------------- /JavaScript/admin/i18n/zh-cn/translations.json: -------------------------------------------------------------------------------- 1 | { 2 | "template adapter settings": "template的适配器设置", 3 | "option1": "选项1", 4 | "option2": "选项2" 5 | } -------------------------------------------------------------------------------- /JavaScript/admin/jsonConfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "i18n": true, 3 | "type": "panel", 4 | "items": { 5 | "option1": { 6 | "type": "checkbox", 7 | "label": "option1", 8 | "newLine": true 9 | }, 10 | "option2": { 11 | "type": "text", 12 | "label": "option2", 13 | "newLine": true 14 | } 15 | } 16 | } -------------------------------------------------------------------------------- /JavaScript/admin/template.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ioBroker/ioBroker.example/46e3823aafe0d918fea64ed9dd5d56a64e009b19/JavaScript/admin/template.png -------------------------------------------------------------------------------- /JavaScript/admin/words.js: -------------------------------------------------------------------------------- 1 | /* eslint no-unused-vars: off */ 2 | /* eslint no-global-assign: off */ 3 | /* global systemDictionary */ 4 | 'use strict'; 5 | 6 | systemDictionary = { 7 | 'template adapter settings': { 8 | 'en': 'Adapter settings for template', 9 | 'de': 'Adaptereinstellungen für template', 10 | 'ru': 'Настройки адаптера для template', 11 | 'pt': 'Configurações do adaptador para template', 12 | 'nl': 'Adapterinstellingen voor template', 13 | 'fr': "Paramètres d'adaptateur pour template", 14 | 'it': "Impostazioni dell'adattatore per template", 15 | 'es': 'Ajustes del adaptador para template', 16 | 'pl': 'Ustawienia adaptera dla template', 17 | 'uk': 'Налаштування адаптера для template', 18 | 'zh-cn': 'template的适配器设置' 19 | }, 20 | 'option1': { 21 | 'en': 'option1', 22 | 'de': 'Option1', 23 | 'ru': 'вариант 1', 24 | 'pt': 'opção1', 25 | 'nl': 'optie1', 26 | 'fr': 'option1', 27 | 'it': 'opzione1', 28 | 'es': 'opción1', 29 | 'pl': 'opcja 1', 30 | 'uk': 'варіант1', 31 | 'zh-cn': '选项1' 32 | }, 33 | 'option2': { 34 | 'en': 'option2', 35 | 'de': 'Option2', 36 | 'ru': 'вариант2', 37 | 'pt': 'opção2', 38 | 'nl': 'optie2', 39 | 'fr': 'option2', 40 | 'it': 'opzione2', 41 | 'es': 'opción2', 42 | 'pl': 'opcja 2', 43 | 'uk': 'варіант2', 44 | 'zh-cn': '选项2' 45 | } 46 | }; -------------------------------------------------------------------------------- /JavaScript/lib/adapter-config.d.ts: -------------------------------------------------------------------------------- 1 | // This file extends the AdapterConfig type from "@types/iobroker" 2 | // using the actual properties present in io-package.json 3 | // in order to provide typings for adapter.config properties 4 | 5 | import { native } from '../io-package.json'; 6 | 7 | type _AdapterConfig = typeof native; 8 | 9 | // Augment the globally declared type ioBroker.AdapterConfig 10 | declare global { 11 | namespace ioBroker { 12 | interface AdapterConfig extends _AdapterConfig { 13 | // Do not enter anything here! 14 | } 15 | } 16 | } 17 | 18 | // this is required so the above AdapterConfig is found by TypeScript / type checking 19 | export {}; -------------------------------------------------------------------------------- /JavaScript/main.test.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | /** 4 | * This is a dummy TypeScript test file using chai and mocha 5 | * 6 | * It's automatically excluded from npm and its build output is excluded from both git and npm. 7 | * It is advised to test all your modules with accompanying *.test.js-files 8 | */ 9 | 10 | // tslint:disable:no-unused-expression 11 | 12 | const { expect } = require('chai'); 13 | // import { functionToTest } from "./moduleToTest"; 14 | 15 | describe('module to test => function to test', () => { 16 | // initializing logic 17 | const expected = 5; 18 | 19 | it(`should return ${expected}`, () => { 20 | const result = 5; 21 | // assign result a value from functionToTest 22 | expect(result).to.equal(expected); 23 | // or using the should() syntax 24 | result.should.equal(expected); 25 | }); 26 | // ... more tests => it 27 | 28 | }); 29 | 30 | // ... more test suites => describe 31 | -------------------------------------------------------------------------------- /JavaScript/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "iobroker.template", 3 | "version": "0.0.1", 4 | "description": "Template for adapter development", 5 | "author": { 6 | "name": "Author", 7 | "email": "author@mail.com" 8 | }, 9 | "homepage": "https://github.com/Author/ioBroker.template", 10 | "license": "MIT", 11 | "keywords": [ 12 | "ioBroker", 13 | "template", 14 | "Smart Home", 15 | "home automation" 16 | ], 17 | "repository": { 18 | "type": "git", 19 | "url": "https://github.com/Author/ioBroker.template.git" 20 | }, 21 | "engines": { 22 | "node": ">= 20" 23 | }, 24 | "dependencies": { 25 | "@iobroker/adapter-core": "^3.1.6" 26 | }, 27 | "devDependencies": { 28 | "@alcalzone/release-script": "^3.8.0", 29 | "@alcalzone/release-script-plugin-iobroker": "^3.7.2", 30 | "@alcalzone/release-script-plugin-license": "^3.7.0", 31 | "@alcalzone/release-script-plugin-manual-review": "^3.7.0", 32 | "@iobroker/adapter-dev": "^1.3.0", 33 | "@iobroker/testing": "^4.1.3", 34 | "@tsconfig/node20": "^20.1.4", 35 | "@types/chai-as-promised": "^7.1.8", 36 | "@types/chai": "^4.3.19", 37 | "@types/mocha": "^10.0.8", 38 | "@types/node": "^20.16.5", 39 | "@types/proxyquire": "^1.3.31", 40 | "@types/sinon": "^17.0.3", 41 | "@types/sinon-chai": "^3.2.12", 42 | "chai-as-promised": "^7.1.2", 43 | "chai": "^4.5.0", 44 | "eslint": "^8.57.0", 45 | "mocha": "^10.7.3", 46 | "proxyquire": "^2.1.3", 47 | "sinon": "^19.0.2", 48 | "sinon-chai": "^3.7.0", 49 | "typescript": "~5.0.4" 50 | }, 51 | "main": "main.js", 52 | "files": [ 53 | "admin{,/!(src)/**}/!(tsconfig|tsconfig.*|.eslintrc).{json,json5}", 54 | "admin{,/!(src)/**}/*.{html,css,png,svg,jpg,js}", 55 | "lib/", 56 | "www/", 57 | "io-package.json", 58 | "LICENSE", 59 | "main.js" 60 | ], 61 | "scripts": { 62 | "test:js": "mocha --config test/mocharc.custom.json \"{!(node_modules|test)/**/*.test.js,*.test.js,test/**/test!(PackageFiles|Startup).js}\"", 63 | "test:package": "mocha test/package --exit", 64 | "test:integration": "mocha test/integration --exit", 65 | "test": "npm run test:js && npm run test:package", 66 | "check": "tsc --noEmit -p tsconfig.check.json", 67 | "lint": "eslint .", 68 | "translate": "translate-adapter", 69 | "release": "release-script" 70 | }, 71 | "bugs": { 72 | "url": "https://github.com/Author/ioBroker.template/issues" 73 | }, 74 | "readmeFilename": "README.md" 75 | } -------------------------------------------------------------------------------- /JavaScript/test/integration.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | const { tests } = require('@iobroker/testing'); 3 | 4 | // Run integration tests - See https://github.com/ioBroker/testing for a detailed explanation and further options 5 | tests.integration(path.join(__dirname, '..')); -------------------------------------------------------------------------------- /JavaScript/test/mocha.setup.js: -------------------------------------------------------------------------------- 1 | // Don't silently swallow unhandled rejections 2 | process.on('unhandledRejection', (e) => { 3 | throw e; 4 | }); 5 | 6 | // enable the should interface with sinon 7 | // and load chai-as-promised and sinon-chai by default 8 | const sinonChai = require('sinon-chai'); 9 | const chaiAsPromised = require('chai-as-promised'); 10 | const { should, use } = require('chai'); 11 | 12 | should(); 13 | use(sinonChai); 14 | use(chaiAsPromised); -------------------------------------------------------------------------------- /JavaScript/test/mocharc.custom.json: -------------------------------------------------------------------------------- 1 | { 2 | "require": [ 3 | "test/mocha.setup.js" 4 | ], 5 | "watch-files": [ 6 | "!(node_modules|test)/**/*.test.js", 7 | "*.test.js", 8 | "test/**/test!(PackageFiles|Startup).js" 9 | ] 10 | } -------------------------------------------------------------------------------- /JavaScript/test/package.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | const { tests } = require('@iobroker/testing'); 3 | 4 | // Validate the package files 5 | tests.packageFiles(path.join(__dirname, '..')); 6 | -------------------------------------------------------------------------------- /JavaScript/test/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "noImplicitAny": false 5 | }, 6 | "include": [ 7 | "./**/*.js" 8 | ] 9 | } 10 | -------------------------------------------------------------------------------- /JavaScript/tsconfig.check.json: -------------------------------------------------------------------------------- 1 | // Specialized tsconfig for type-checking js files 2 | { 3 | "extends": "./tsconfig.json", 4 | "compilerOptions": {}, 5 | "include": [ 6 | "**/*.js", 7 | "**/*.d.ts" 8 | ], 9 | "exclude": [ 10 | "**/build", 11 | "node_modules/", 12 | "widgets/" 13 | ] 14 | } 15 | -------------------------------------------------------------------------------- /JavaScript/tsconfig.json: -------------------------------------------------------------------------------- 1 | // Root tsconfig to set the settings and power editor support for all TS files 2 | { 3 | // To update the compilation target, install a different version of @tsconfig/node... and reference it here 4 | // https://github.com/tsconfig/bases#node-20-tsconfigjson 5 | "extends": "@tsconfig/node20/tsconfig.json", 6 | "compilerOptions": { 7 | // do not compile anything, this file is just to configure type checking 8 | "noEmit": true, 9 | 10 | // check JS files 11 | "allowJs": true, 12 | "checkJs": true, 13 | 14 | // This is necessary for the automatic typing of the adapter config 15 | "resolveJsonModule": true, 16 | 17 | // If you want to disable the stricter type checks (not recommended), uncomment the following line 18 | // "strict": false, 19 | // And enable some of those features for more fine-grained control 20 | // "strictNullChecks": true, 21 | // "strictPropertyInitialization": true, 22 | // "strictBindCallApply": true, 23 | "noImplicitAny": false, 24 | // "noUnusedLocals": true, 25 | // "noUnusedParameters": true, 26 | "useUnknownInCatchVariables": false, 27 | 28 | }, 29 | "include": [ 30 | "**/*.js", 31 | "**/*.d.ts" 32 | ], 33 | "exclude": [ 34 | "node_modules/**", 35 | "widgets/**" 36 | ] 37 | } -------------------------------------------------------------------------------- /JavaScriptReact/.create-adapter.json: -------------------------------------------------------------------------------- 1 | { 2 | "cli": true, 3 | "target": "directory", 4 | "adapterName": "template", 5 | "description": "Template for adapter development", 6 | "authorName": "Author", 7 | "authorGithub": "Author", 8 | "authorEmail": "author@mail.com", 9 | "gitRemoteProtocol": "HTTPS", 10 | "dependabot": "yes", 11 | "license": "MIT License", 12 | "releaseScript": "yes", 13 | "gitCommit": "no", 14 | "defaultBranch": "main", 15 | "startMode": "daemon", 16 | "features": [ 17 | "adapter" 18 | ], 19 | "connectionIndicator": "no", 20 | "type": "general", 21 | "adminFeatures": [ 22 | "custom", 23 | "tab" 24 | ], 25 | "adminUi": "react", 26 | "tabReact": "yes", 27 | "language": "JavaScript", 28 | "title": "Template (JavaScript)", 29 | "tools": [ 30 | "ESLint", 31 | "type checking" 32 | ], 33 | "indentation": "Space (4)", 34 | "quotes": "single", 35 | "creatorVersion": "2.6.5" 36 | } -------------------------------------------------------------------------------- /JavaScriptReact/.eslintignore: -------------------------------------------------------------------------------- 1 | admin/build/ 2 | **/.eslintrc.js 3 | admin/words.js -------------------------------------------------------------------------------- /JavaScriptReact/.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "root": true, 3 | "env": { 4 | "es6": true, 5 | "node": true, 6 | "mocha": true 7 | }, 8 | "extends": [ 9 | "eslint:recommended", 10 | "plugin:react/recommended" 11 | ], 12 | "plugins": [ 13 | "react" 14 | ], 15 | "settings": { 16 | "react": { 17 | "version": "detect" 18 | } 19 | }, 20 | "rules": { 21 | "indent": [ 22 | "error", 23 | 4, 24 | { 25 | "SwitchCase": 1 26 | } 27 | ], 28 | "no-console": "off", 29 | "no-unused-vars": [ 30 | "error", 31 | { 32 | "ignoreRestSiblings": true, 33 | "argsIgnorePattern": "^_" 34 | } 35 | ], 36 | "no-var": "error", 37 | "no-trailing-spaces": "error", 38 | "prefer-const": "error", 39 | "quotes": [ 40 | "error", 41 | "single", 42 | { 43 | "avoidEscape": true, 44 | "allowTemplateLiterals": true 45 | } 46 | ], 47 | "semi": [ 48 | "error", 49 | "always" 50 | ] 51 | }, 52 | "parserOptions": { 53 | "ecmaVersion": "latest", 54 | "ecmaFeatures": { 55 | "jsx": true 56 | } 57 | } 58 | } -------------------------------------------------------------------------------- /JavaScriptReact/.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Something is not working as it should 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | --- 8 | 9 | **Describe the bug** 10 | A clear and concise description of what the bug is. 11 | 12 | **To Reproduce** 13 | Steps to reproduce the behavior: 14 | 1. Go to '...' 15 | 2. Click on '...' 16 | 3. Scroll down to '....' 17 | 4. See error 18 | 19 | **Expected behavior** 20 | A clear and concise description of what you expected to happen. 21 | 22 | **Screenshots & Logfiles** 23 | If applicable, add screenshots and logfiles to help explain your problem. 24 | 25 | **Versions:** 26 | - Adapter version: 27 | - JS-Controller version: 28 | - Node version: 29 | - Operating system: 30 | 31 | **Additional context** 32 | Add any other context about the problem here. 33 | -------------------------------------------------------------------------------- /JavaScriptReact/.github/auto-merge.yml: -------------------------------------------------------------------------------- 1 | # Configure here which dependency updates should be merged automatically. 2 | # The recommended configuration is the following: 3 | - match: 4 | # Only merge patches for production dependencies 5 | dependency_type: production 6 | update_type: "semver:patch" 7 | - match: 8 | # Except for security fixes, here we allow minor patches 9 | dependency_type: production 10 | update_type: "security:minor" 11 | - match: 12 | # and development dependencies can have a minor update, too 13 | dependency_type: development 14 | update_type: "semver:minor" 15 | 16 | # The syntax is based on the legacy dependabot v1 automerged_updates syntax, see: 17 | # https://dependabot.com/docs/config-file/#automerged_updates 18 | -------------------------------------------------------------------------------- /JavaScriptReact/.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: npm 4 | directory: "/" 5 | schedule: 6 | interval: monthly 7 | time: "04:00" 8 | timezone: Europe/Berlin 9 | open-pull-requests-limit: 5 10 | assignees: 11 | - Author 12 | versioning-strategy: increase 13 | 14 | - package-ecosystem: github-actions 15 | directory: "/" 16 | schedule: 17 | interval: monthly 18 | time: "04:00" 19 | timezone: Europe/Berlin 20 | open-pull-requests-limit: 5 21 | assignees: 22 | - Author 23 | -------------------------------------------------------------------------------- /JavaScriptReact/.github/workflows/dependabot-auto-merge.yml: -------------------------------------------------------------------------------- 1 | # Automatically merge Dependabot PRs when version comparison is within the range 2 | # that is configured in .github/auto-merge.yml 3 | 4 | name: Auto-Merge Dependabot PRs 5 | 6 | on: 7 | # WARNING: This needs to be run in the PR base, DO NOT build untrusted code in this action 8 | # details under https://github.blog/changelog/2021-02-19-github-actions-workflows-triggered-by-dependabot-prs-will-run-with-read-only-permissions/ 9 | pull_request_target: 10 | 11 | jobs: 12 | auto-merge: 13 | if: github.actor == 'dependabot[bot]' 14 | runs-on: ubuntu-latest 15 | steps: 16 | - name: Checkout code 17 | uses: actions/checkout@v2 18 | 19 | - name: Check if PR should be auto-merged 20 | uses: ahmadnassri/action-dependabot-auto-merge@v2 21 | with: 22 | # In order to use this, you need to go to https://github.com/settings/tokens and 23 | # create a Personal Access Token with the permission "public_repo". 24 | # Enter this token in your repository settings under "Secrets" and name it AUTO_MERGE_TOKEN 25 | github-token: ${{ secrets.AUTO_MERGE_TOKEN }} 26 | # By default, squash and merge, so Github chooses nice commit messages 27 | command: squash and merge 28 | -------------------------------------------------------------------------------- /JavaScriptReact/.gitignore: -------------------------------------------------------------------------------- 1 | # No dot-directories except github/vscode 2 | .*/ 3 | !.vscode/ 4 | !.github/ 5 | 6 | *.code-workspace 7 | node_modules 8 | nbproject 9 | 10 | # npm package files 11 | iobroker.*.tgz 12 | 13 | Thumbs.db 14 | 15 | # i18n intermediate files 16 | admin/i18n/flat.txt 17 | admin/i18n/*/flat.txt -------------------------------------------------------------------------------- /JavaScriptReact/.releaseconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "plugins": [ 3 | "iobroker", 4 | "license", 5 | "manual-review" 6 | ], 7 | "exec": { 8 | "before_commit": "npm run build" 9 | } 10 | } -------------------------------------------------------------------------------- /JavaScriptReact/.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | "recommendations": [ 3 | "dbaeumer.vscode-eslint" 4 | ] 5 | } -------------------------------------------------------------------------------- /JavaScriptReact/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "eslint.enable": true, 3 | "json.schemas": [ 4 | { 5 | "fileMatch": [ 6 | "io-package.json" 7 | ], 8 | "url": "https://raw.githubusercontent.com/ioBroker/ioBroker.js-controller/master/schemas/io-package.json" 9 | }, 10 | { 11 | "fileMatch": [ 12 | "admin/jsonConfig.json", 13 | "admin/jsonCustom.json", 14 | "admin/jsonTab.json" 15 | ], 16 | "url": "https://raw.githubusercontent.com/ioBroker/adapter-react-v5/main/schemas/jsonConfig.json" 17 | } 18 | ] 19 | } -------------------------------------------------------------------------------- /JavaScriptReact/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2024 Author 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 all 13 | 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 THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /JavaScriptReact/admin/.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "browser": true, 4 | "es6": true 5 | }, 6 | "parserOptions": { 7 | "sourceType": "module", 8 | "project": "./tsconfig.json" 9 | }, 10 | "rules": { 11 | "react/prop-types": "off" 12 | } 13 | } -------------------------------------------------------------------------------- /JavaScriptReact/admin/custom_m.html: -------------------------------------------------------------------------------- 1 | 22 | 23 | -------------------------------------------------------------------------------- /JavaScriptReact/admin/index_m.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /JavaScriptReact/admin/src/app.jsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { withStyles } from '@material-ui/core/styles'; 3 | 4 | import GenericApp from '@iobroker/adapter-react/GenericApp'; 5 | import Settings from './components/settings'; 6 | 7 | /** 8 | * @type {(_theme: import("@material-ui/core/styles").Theme) => import("@material-ui/styles").StyleRules} 9 | */ 10 | const styles = (_theme) => ({ 11 | root: {}, 12 | }); 13 | 14 | class App extends GenericApp { 15 | constructor(props) { 16 | const extendedProps = { 17 | ...props, 18 | encryptedFields: [], 19 | translations: { 20 | 'en': require('./i18n/en.json'), 21 | 'de': require('./i18n/de.json'), 22 | 'ru': require('./i18n/ru.json'), 23 | 'pt': require('./i18n/pt.json'), 24 | 'nl': require('./i18n/nl.json'), 25 | 'fr': require('./i18n/fr.json'), 26 | 'it': require('./i18n/it.json'), 27 | 'es': require('./i18n/es.json'), 28 | 'pl': require('./i18n/pl.json'), 29 | 'uk': require('./i18n/uk.json'), 30 | 'zh-cn': require('./i18n/zh-cn.json'), 31 | }, 32 | }; 33 | super(props, extendedProps); 34 | } 35 | 36 | onConnectionReady() { 37 | // executed when connection is ready 38 | } 39 | 40 | render() { 41 | if (!this.state.loaded) { 42 | return super.render(); 43 | } 44 | 45 | return ( 46 |
47 | this.updateNativeValue(attr, value)} /> 48 | {this.renderError()} 49 | {this.renderToast()} 50 | {this.renderSaveCloseButtons()} 51 |
52 | ); 53 | } 54 | } 55 | 56 | export default withStyles(styles)(App); -------------------------------------------------------------------------------- /JavaScriptReact/admin/src/i18n/de.json: -------------------------------------------------------------------------------- 1 | { 2 | "template adapter settings": "Adaptereinstellungen für template", 3 | "option1": "Option1", 4 | "option2": "Option2" 5 | } -------------------------------------------------------------------------------- /JavaScriptReact/admin/src/i18n/en.json: -------------------------------------------------------------------------------- 1 | { 2 | "template adapter settings": "Adapter settings for template", 3 | "option1": "option1", 4 | "option2": "option2" 5 | } -------------------------------------------------------------------------------- /JavaScriptReact/admin/src/i18n/es.json: -------------------------------------------------------------------------------- 1 | { 2 | "template adapter settings": "Ajustes del adaptador para template", 3 | "option1": "opción1", 4 | "option2": "opción2" 5 | } -------------------------------------------------------------------------------- /JavaScriptReact/admin/src/i18n/fr.json: -------------------------------------------------------------------------------- 1 | { 2 | "template adapter settings": "Paramètres d'adaptateur pour template", 3 | "option1": "option1", 4 | "option2": "option2" 5 | } -------------------------------------------------------------------------------- /JavaScriptReact/admin/src/i18n/i18n.d.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * This file loads the translations keys from `i18n/en.json` file and overrides 3 | * the declarations for the translate function `I18n.t` available in "@iobroker/adapter-react/i18n". 4 | * Using these definitions it is ensured that all used translations in the React 5 | * context are defined at least in the english translations file. 6 | * This will add no overhead in the generated code since it just reexports the 7 | * I18n class but with a more typed `t` function. 8 | */ 9 | 10 | /* 11 | * DO NOT add any imports or exports in this file or it will stop working! 12 | */ 13 | 14 | /** 15 | * Available words in `i18n/en.json`. 16 | */ 17 | declare type AdminWord = keyof typeof import('./en.json'); 18 | 19 | declare module '@iobroker/adapter-react/i18n' { 20 | /** 21 | * Translate the given string to the selected language. 22 | * @param word The (key) word to look up the string. Has to be defined at least in `i18n/en.json`. 23 | * @param args Optional arguments which will replace the first (second, third, ...) occurence of %s 24 | */ 25 | function t(word: AdminWord, ...args: string[]): string; 26 | } -------------------------------------------------------------------------------- /JavaScriptReact/admin/src/i18n/it.json: -------------------------------------------------------------------------------- 1 | { 2 | "template adapter settings": "Impostazioni dell'adattatore per template", 3 | "option1": "opzione1", 4 | "option2": "opzione2" 5 | } -------------------------------------------------------------------------------- /JavaScriptReact/admin/src/i18n/nl.json: -------------------------------------------------------------------------------- 1 | { 2 | "template adapter settings": "Adapterinstellingen voor template", 3 | "option1": "optie1", 4 | "option2": "optie2" 5 | } -------------------------------------------------------------------------------- /JavaScriptReact/admin/src/i18n/pl.json: -------------------------------------------------------------------------------- 1 | { 2 | "template adapter settings": "Ustawienia adaptera dla template", 3 | "option1": "opcja 1", 4 | "option2": "opcja 2" 5 | } -------------------------------------------------------------------------------- /JavaScriptReact/admin/src/i18n/pt.json: -------------------------------------------------------------------------------- 1 | { 2 | "template adapter settings": "Configurações do adaptador para template", 3 | "option1": "opção1", 4 | "option2": "opção2" 5 | } -------------------------------------------------------------------------------- /JavaScriptReact/admin/src/i18n/ru.json: -------------------------------------------------------------------------------- 1 | { 2 | "template adapter settings": "Настройки адаптера для template", 3 | "option1": "вариант 1", 4 | "option2": "вариант2" 5 | } -------------------------------------------------------------------------------- /JavaScriptReact/admin/src/i18n/uk.json: -------------------------------------------------------------------------------- 1 | { 2 | "template adapter settings": "Налаштування адаптера для template", 3 | "option1": "варіант1", 4 | "option2": "варіант2" 5 | } -------------------------------------------------------------------------------- /JavaScriptReact/admin/src/i18n/zh-cn.json: -------------------------------------------------------------------------------- 1 | { 2 | "template adapter settings": "template的适配器设置", 3 | "option1": "选项1", 4 | "option2": "选项2" 5 | } -------------------------------------------------------------------------------- /JavaScriptReact/admin/src/index.jsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import { MuiThemeProvider } from '@material-ui/core/styles'; 4 | import theme from '@iobroker/adapter-react/Theme'; 5 | import Utils from '@iobroker/adapter-react/Components/Utils'; 6 | import App from './app'; 7 | 8 | let themeName = Utils.getThemeName(); 9 | 10 | function build() { 11 | ReactDOM.render( 12 | 13 | { 16 | themeName = _theme; 17 | build(); 18 | }} 19 | /> 20 | , 21 | document.getElementById('root'), 22 | ); 23 | } 24 | 25 | build(); -------------------------------------------------------------------------------- /JavaScriptReact/admin/src/tab-app.jsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { withStyles } from '@material-ui/core/styles'; 3 | 4 | import GenericApp from '@iobroker/adapter-react/GenericApp'; 5 | 6 | /** 7 | * @type {(_theme: Theme) => import("@material-ui/styles").StyleRules} 8 | */ 9 | const styles = (_theme) => ({ 10 | root: {}, 11 | }); 12 | 13 | class TabApp extends GenericApp { 14 | constructor(props) { 15 | const extendedProps = { 16 | ...props, 17 | bottomButtons: false, 18 | encryptedFields: [], 19 | translations: { 20 | 'en': require('./i18n/en.json'), 21 | 'de': require('./i18n/de.json'), 22 | 'ru': require('./i18n/ru.json'), 23 | 'pt': require('./i18n/pt.json'), 24 | 'nl': require('./i18n/nl.json'), 25 | 'fr': require('./i18n/fr.json'), 26 | 'it': require('./i18n/it.json'), 27 | 'es': require('./i18n/es.json'), 28 | 'pl': require('./i18n/pl.json'), 29 | 'uk': require('./i18n/uk.json'), 30 | 'zh-cn': require('./i18n/zh-cn.json'), 31 | }, 32 | }; 33 | super(props, extendedProps); 34 | } 35 | 36 | onConnectionReady() { 37 | // executed when connection is ready 38 | } 39 | 40 | render() { 41 | if (!this.state.loaded) { 42 | return super.render(); 43 | } 44 | 45 | return ( 46 |
47 | Add your components here. 48 | {this.renderError()} 49 | {this.renderToast()} 50 |
51 | ); 52 | } 53 | } 54 | 55 | export default withStyles(styles)(TabApp); -------------------------------------------------------------------------------- /JavaScriptReact/admin/src/tab.jsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import { MuiThemeProvider } from '@material-ui/core/styles'; 4 | import theme from '@iobroker/adapter-react/Theme'; 5 | import Utils from '@iobroker/adapter-react/Components/Utils'; 6 | import TabApp from './tab-app'; 7 | 8 | let themeName = Utils.getThemeName(); 9 | 10 | function build() { 11 | ReactDOM.render( 12 | 13 | { 16 | themeName = _theme; 17 | build(); 18 | }} 19 | /> 20 | , 21 | document.getElementById('root'), 22 | ); 23 | } 24 | 25 | build(); -------------------------------------------------------------------------------- /JavaScriptReact/admin/style.css: -------------------------------------------------------------------------------- 1 | /* You can delete those if you want. I just found them very helpful */ 2 | * { 3 | box-sizing: border-box 4 | } 5 | .m { 6 | /* Don't cut off dropdowns! */ 7 | overflow: initial; 8 | } 9 | .m.adapter-container, 10 | .m.adapter-container > div.App { 11 | /* Fix layout/scrolling issues with tabs */ 12 | height: 100%; 13 | width: 100%; 14 | position: relative; 15 | } 16 | .m .select-wrapper + label { 17 | /* The positioning for dropdown labels is messed up */ 18 | transform: none !important; 19 | } 20 | 21 | label > i[title] { 22 | /* Display the help cursor for the tooltip icons and fix their positioning */ 23 | cursor: help; 24 | margin-left: 0.25em; 25 | } 26 | 27 | .dropdown-content { 28 | /* Don't wrap text in dropdowns */ 29 | white-space: nowrap; 30 | } 31 | 32 | /* Add your styles here */ 33 | -------------------------------------------------------------------------------- /JavaScriptReact/admin/tab_m.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /JavaScriptReact/admin/template.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ioBroker/ioBroker.example/46e3823aafe0d918fea64ed9dd5d56a64e009b19/JavaScriptReact/admin/template.png -------------------------------------------------------------------------------- /JavaScriptReact/admin/tsconfig.json: -------------------------------------------------------------------------------- 1 | // Specialized tsconfig for the admin directory, 2 | // includes DOM typings and configures the admin build 3 | { 4 | "extends": "../tsconfig.json", 5 | "compilerOptions": { 6 | "noEmit": false, 7 | "outDir": "./build", 8 | "sourceMap": true, 9 | "sourceRoot": "./src", 10 | "noImplicitAny": false, 11 | "lib": [ 12 | "es2018", 13 | "DOM" 14 | ], 15 | "jsx": "react" 16 | }, 17 | "include": [ 18 | "./**/*.d.ts", 19 | "./**/*.jsx", 20 | "../lib/adapter-config.d.ts" 21 | ], 22 | "exclude": [ 23 | "./**/*.test.jsx" 24 | ] 25 | } 26 | -------------------------------------------------------------------------------- /JavaScriptReact/lib/adapter-config.d.ts: -------------------------------------------------------------------------------- 1 | // This file extends the AdapterConfig type from "@types/iobroker" 2 | // using the actual properties present in io-package.json 3 | // in order to provide typings for adapter.config properties 4 | 5 | import { native } from '../io-package.json'; 6 | 7 | type _AdapterConfig = typeof native; 8 | 9 | // Augment the globally declared type ioBroker.AdapterConfig 10 | declare global { 11 | namespace ioBroker { 12 | interface AdapterConfig extends _AdapterConfig { 13 | // Do not enter anything here! 14 | } 15 | } 16 | } 17 | 18 | // this is required so the above AdapterConfig is found by TypeScript / type checking 19 | export {}; -------------------------------------------------------------------------------- /JavaScriptReact/main.test.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | /** 4 | * This is a dummy TypeScript test file using chai and mocha 5 | * 6 | * It's automatically excluded from npm and its build output is excluded from both git and npm. 7 | * It is advised to test all your modules with accompanying *.test.js-files 8 | */ 9 | 10 | // tslint:disable:no-unused-expression 11 | 12 | const { expect } = require('chai'); 13 | // import { functionToTest } from "./moduleToTest"; 14 | 15 | describe('module to test => function to test', () => { 16 | // initializing logic 17 | const expected = 5; 18 | 19 | it(`should return ${expected}`, () => { 20 | const result = 5; 21 | // assign result a value from functionToTest 22 | expect(result).to.equal(expected); 23 | // or using the should() syntax 24 | result.should.equal(expected); 25 | }); 26 | // ... more tests => it 27 | 28 | }); 29 | 30 | // ... more test suites => describe 31 | -------------------------------------------------------------------------------- /JavaScriptReact/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "iobroker.template", 3 | "version": "0.0.1", 4 | "description": "Template for adapter development", 5 | "author": { 6 | "name": "Author", 7 | "email": "author@mail.com" 8 | }, 9 | "homepage": "https://github.com/Author/ioBroker.template", 10 | "license": "MIT", 11 | "keywords": [ 12 | "ioBroker", 13 | "template", 14 | "Smart Home", 15 | "home automation" 16 | ], 17 | "repository": { 18 | "type": "git", 19 | "url": "https://github.com/Author/ioBroker.template.git" 20 | }, 21 | "engines": { 22 | "node": ">= 20" 23 | }, 24 | "dependencies": { 25 | "@iobroker/adapter-core": "^3.1.6" 26 | }, 27 | "devDependencies": { 28 | "@alcalzone/release-script": "^3.8.0", 29 | "@alcalzone/release-script-plugin-iobroker": "^3.7.2", 30 | "@alcalzone/release-script-plugin-license": "^3.7.0", 31 | "@alcalzone/release-script-plugin-manual-review": "^3.7.0", 32 | "@iobroker/adapter-dev": "^1.3.0", 33 | "@iobroker/adapter-react": "2.0.22", 34 | "@iobroker/testing": "^4.1.3", 35 | "@material-ui/core": "^4.12.4", 36 | "@tsconfig/node20": "^20.1.4", 37 | "@types/chai-as-promised": "^7.1.8", 38 | "@types/chai": "^4.3.19", 39 | "@types/mocha": "^10.0.8", 40 | "@types/node": "^20.16.5", 41 | "@types/proxyquire": "^1.3.31", 42 | "@types/react-dom": "^17.0.25", 43 | "@types/react": "^17.0.80", 44 | "@types/sinon": "^17.0.3", 45 | "@types/sinon-chai": "^3.2.12", 46 | "chai-as-promised": "^7.1.2", 47 | "chai": "^4.5.0", 48 | "eslint-plugin-react": "^7.36.1", 49 | "eslint": "^8.57.0", 50 | "mocha": "^10.7.3", 51 | "proxyquire": "^2.1.3", 52 | "react-dom": "^17.0.2", 53 | "react": "^17.0.2", 54 | "sinon": "^19.0.2", 55 | "sinon-chai": "^3.7.0", 56 | "typescript": "~5.0.4" 57 | }, 58 | "main": "main.js", 59 | "files": [ 60 | "admin{,/!(src)/**}/!(tsconfig|tsconfig.*|.eslintrc).{json,json5}", 61 | "admin{,/!(src)/**}/*.{html,css,png,svg,jpg,js}", 62 | "admin/build/", 63 | "lib/", 64 | "www/", 65 | "io-package.json", 66 | "LICENSE", 67 | "main.js" 68 | ], 69 | "scripts": { 70 | "prebuild": "rimraf admin/build", 71 | "build": "build-adapter react", 72 | "watch": "build-adapter react --watch", 73 | "prebuild:react": "rimraf admin/build", 74 | "build:react": "build-adapter react", 75 | "watch:react": "build-adapter react --watch", 76 | "test:js": "mocha --config test/mocharc.custom.json \"{!(node_modules|test)/**/*.test.js,*.test.js,test/**/test!(PackageFiles|Startup).js}\"", 77 | "test:package": "mocha test/package --exit", 78 | "test:integration": "mocha test/integration --exit", 79 | "test": "npm run test:js && npm run test:package", 80 | "check": "tsc --noEmit -p tsconfig.check.json", 81 | "lint": "eslint --ext .js,.jsx .", 82 | "translate": "translate-adapter", 83 | "release": "release-script" 84 | }, 85 | "bugs": { 86 | "url": "https://github.com/Author/ioBroker.template/issues" 87 | }, 88 | "readmeFilename": "README.md" 89 | } -------------------------------------------------------------------------------- /JavaScriptReact/test/integration.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | const { tests } = require('@iobroker/testing'); 3 | 4 | // Run integration tests - See https://github.com/ioBroker/testing for a detailed explanation and further options 5 | tests.integration(path.join(__dirname, '..')); -------------------------------------------------------------------------------- /JavaScriptReact/test/mocha.setup.js: -------------------------------------------------------------------------------- 1 | // Don't silently swallow unhandled rejections 2 | process.on('unhandledRejection', (e) => { 3 | throw e; 4 | }); 5 | 6 | // enable the should interface with sinon 7 | // and load chai-as-promised and sinon-chai by default 8 | const sinonChai = require('sinon-chai'); 9 | const chaiAsPromised = require('chai-as-promised'); 10 | const { should, use } = require('chai'); 11 | 12 | should(); 13 | use(sinonChai); 14 | use(chaiAsPromised); -------------------------------------------------------------------------------- /JavaScriptReact/test/mocharc.custom.json: -------------------------------------------------------------------------------- 1 | { 2 | "require": [ 3 | "test/mocha.setup.js" 4 | ], 5 | "watch-files": [ 6 | "!(node_modules|test)/**/*.test.js", 7 | "*.test.js", 8 | "test/**/test!(PackageFiles|Startup).js" 9 | ] 10 | } -------------------------------------------------------------------------------- /JavaScriptReact/test/package.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | const { tests } = require('@iobroker/testing'); 3 | 4 | // Validate the package files 5 | tests.packageFiles(path.join(__dirname, '..')); 6 | -------------------------------------------------------------------------------- /JavaScriptReact/test/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "noImplicitAny": false 5 | }, 6 | "include": [ 7 | "./**/*.js" 8 | ] 9 | } 10 | -------------------------------------------------------------------------------- /JavaScriptReact/tsconfig.check.json: -------------------------------------------------------------------------------- 1 | // Specialized tsconfig for type-checking js files 2 | { 3 | "extends": "./tsconfig.json", 4 | "compilerOptions": {}, 5 | "include": [ 6 | "**/*.js", 7 | "**/*.d.ts" 8 | ], 9 | "exclude": [ 10 | "**/build", 11 | "node_modules/", 12 | "widgets/" 13 | ] 14 | } 15 | -------------------------------------------------------------------------------- /JavaScriptReact/tsconfig.json: -------------------------------------------------------------------------------- 1 | // Root tsconfig to set the settings and power editor support for all TS files 2 | { 3 | // To update the compilation target, install a different version of @tsconfig/node... and reference it here 4 | // https://github.com/tsconfig/bases#node-20-tsconfigjson 5 | "extends": "@tsconfig/node20/tsconfig.json", 6 | "compilerOptions": { 7 | // do not compile anything, this file is just to configure type checking 8 | "noEmit": true, 9 | 10 | // check JS files 11 | "allowJs": true, 12 | "checkJs": true, 13 | 14 | // This is necessary for the automatic typing of the adapter config 15 | "resolveJsonModule": true, 16 | 17 | // If you want to disable the stricter type checks (not recommended), uncomment the following line 18 | // "strict": false, 19 | // And enable some of those features for more fine-grained control 20 | // "strictNullChecks": true, 21 | // "strictPropertyInitialization": true, 22 | // "strictBindCallApply": true, 23 | "noImplicitAny": false, 24 | // "noUnusedLocals": true, 25 | // "noUnusedParameters": true, 26 | "useUnknownInCatchVariables": false, 27 | 28 | }, 29 | "include": [ 30 | "**/*.js", 31 | "**/*.d.ts" 32 | ], 33 | "exclude": [ 34 | "node_modules/**", 35 | "widgets/**" 36 | ] 37 | } -------------------------------------------------------------------------------- /JavaScriptVIS/.create-adapter.json: -------------------------------------------------------------------------------- 1 | { 2 | "cli": true, 3 | "target": "directory", 4 | "adapterName": "template", 5 | "description": "Template for adapter development", 6 | "authorName": "Author", 7 | "authorGithub": "Author", 8 | "authorEmail": "author@mail.com", 9 | "gitRemoteProtocol": "HTTPS", 10 | "dependabot": "yes", 11 | "license": "MIT License", 12 | "releaseScript": "yes", 13 | "gitCommit": "no", 14 | "defaultBranch": "main", 15 | "startMode": "daemon", 16 | "features": [ 17 | "adapter", 18 | "vis" 19 | ], 20 | "connectionIndicator": "no", 21 | "type": "general", 22 | "adminFeatures": [ 23 | "custom", 24 | "tab" 25 | ], 26 | "adminUi": "json", 27 | "tabReact": "no", 28 | "language": "JavaScript", 29 | "title": "Template (JavaScript with VIS)", 30 | "tools": [ 31 | "ESLint", 32 | "type checking" 33 | ], 34 | "indentation": "Space (4)", 35 | "quotes": "single", 36 | "creatorVersion": "2.6.5" 37 | } -------------------------------------------------------------------------------- /JavaScriptVIS/.eslintignore: -------------------------------------------------------------------------------- 1 | **/.eslintrc.js 2 | admin/words.js -------------------------------------------------------------------------------- /JavaScriptVIS/.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "root": true, 3 | "env": { 4 | "es6": true, 5 | "node": true, 6 | "mocha": true 7 | }, 8 | "extends": [ 9 | "eslint:recommended" 10 | ], 11 | "plugins": [], 12 | "rules": { 13 | "indent": [ 14 | "error", 15 | 4, 16 | { 17 | "SwitchCase": 1 18 | } 19 | ], 20 | "no-console": "off", 21 | "no-unused-vars": [ 22 | "error", 23 | { 24 | "ignoreRestSiblings": true, 25 | "argsIgnorePattern": "^_" 26 | } 27 | ], 28 | "no-var": "error", 29 | "no-trailing-spaces": "error", 30 | "prefer-const": "error", 31 | "quotes": [ 32 | "error", 33 | "single", 34 | { 35 | "avoidEscape": true, 36 | "allowTemplateLiterals": true 37 | } 38 | ], 39 | "semi": [ 40 | "error", 41 | "always" 42 | ] 43 | }, 44 | "parserOptions": { 45 | "ecmaVersion": "latest" 46 | } 47 | } -------------------------------------------------------------------------------- /JavaScriptVIS/.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Something is not working as it should 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | --- 8 | 9 | **Describe the bug** 10 | A clear and concise description of what the bug is. 11 | 12 | **To Reproduce** 13 | Steps to reproduce the behavior: 14 | 1. Go to '...' 15 | 2. Click on '...' 16 | 3. Scroll down to '....' 17 | 4. See error 18 | 19 | **Expected behavior** 20 | A clear and concise description of what you expected to happen. 21 | 22 | **Screenshots & Logfiles** 23 | If applicable, add screenshots and logfiles to help explain your problem. 24 | 25 | **Versions:** 26 | - Adapter version: 27 | - JS-Controller version: 28 | - Node version: 29 | - Operating system: 30 | 31 | **Additional context** 32 | Add any other context about the problem here. 33 | -------------------------------------------------------------------------------- /JavaScriptVIS/.github/auto-merge.yml: -------------------------------------------------------------------------------- 1 | # Configure here which dependency updates should be merged automatically. 2 | # The recommended configuration is the following: 3 | - match: 4 | # Only merge patches for production dependencies 5 | dependency_type: production 6 | update_type: "semver:patch" 7 | - match: 8 | # Except for security fixes, here we allow minor patches 9 | dependency_type: production 10 | update_type: "security:minor" 11 | - match: 12 | # and development dependencies can have a minor update, too 13 | dependency_type: development 14 | update_type: "semver:minor" 15 | 16 | # The syntax is based on the legacy dependabot v1 automerged_updates syntax, see: 17 | # https://dependabot.com/docs/config-file/#automerged_updates 18 | -------------------------------------------------------------------------------- /JavaScriptVIS/.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: npm 4 | directory: "/" 5 | schedule: 6 | interval: monthly 7 | time: "04:00" 8 | timezone: Europe/Berlin 9 | open-pull-requests-limit: 5 10 | assignees: 11 | - Author 12 | versioning-strategy: increase 13 | 14 | - package-ecosystem: github-actions 15 | directory: "/" 16 | schedule: 17 | interval: monthly 18 | time: "04:00" 19 | timezone: Europe/Berlin 20 | open-pull-requests-limit: 5 21 | assignees: 22 | - Author 23 | -------------------------------------------------------------------------------- /JavaScriptVIS/.github/workflows/dependabot-auto-merge.yml: -------------------------------------------------------------------------------- 1 | # Automatically merge Dependabot PRs when version comparison is within the range 2 | # that is configured in .github/auto-merge.yml 3 | 4 | name: Auto-Merge Dependabot PRs 5 | 6 | on: 7 | # WARNING: This needs to be run in the PR base, DO NOT build untrusted code in this action 8 | # details under https://github.blog/changelog/2021-02-19-github-actions-workflows-triggered-by-dependabot-prs-will-run-with-read-only-permissions/ 9 | pull_request_target: 10 | 11 | jobs: 12 | auto-merge: 13 | if: github.actor == 'dependabot[bot]' 14 | runs-on: ubuntu-latest 15 | steps: 16 | - name: Checkout code 17 | uses: actions/checkout@v2 18 | 19 | - name: Check if PR should be auto-merged 20 | uses: ahmadnassri/action-dependabot-auto-merge@v2 21 | with: 22 | # In order to use this, you need to go to https://github.com/settings/tokens and 23 | # create a Personal Access Token with the permission "public_repo". 24 | # Enter this token in your repository settings under "Secrets" and name it AUTO_MERGE_TOKEN 25 | github-token: ${{ secrets.AUTO_MERGE_TOKEN }} 26 | # By default, squash and merge, so Github chooses nice commit messages 27 | command: squash and merge 28 | -------------------------------------------------------------------------------- /JavaScriptVIS/.gitignore: -------------------------------------------------------------------------------- 1 | # No dot-directories except github/vscode 2 | .*/ 3 | !.vscode/ 4 | !.github/ 5 | 6 | *.code-workspace 7 | node_modules 8 | nbproject 9 | 10 | # npm package files 11 | iobroker.*.tgz 12 | 13 | Thumbs.db 14 | 15 | # i18n intermediate files 16 | admin/i18n/flat.txt 17 | admin/i18n/*/flat.txt -------------------------------------------------------------------------------- /JavaScriptVIS/.releaseconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "plugins": [ 3 | "iobroker", 4 | "license", 5 | "manual-review" 6 | ] 7 | } -------------------------------------------------------------------------------- /JavaScriptVIS/.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | "recommendations": [ 3 | "dbaeumer.vscode-eslint" 4 | ] 5 | } -------------------------------------------------------------------------------- /JavaScriptVIS/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "eslint.enable": true, 3 | "json.schemas": [ 4 | { 5 | "fileMatch": [ 6 | "io-package.json" 7 | ], 8 | "url": "https://raw.githubusercontent.com/ioBroker/ioBroker.js-controller/master/schemas/io-package.json" 9 | }, 10 | { 11 | "fileMatch": [ 12 | "admin/jsonConfig.json", 13 | "admin/jsonCustom.json", 14 | "admin/jsonTab.json" 15 | ], 16 | "url": "https://raw.githubusercontent.com/ioBroker/adapter-react-v5/main/schemas/jsonConfig.json" 17 | } 18 | ] 19 | } -------------------------------------------------------------------------------- /JavaScriptVIS/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2024 Author 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 all 13 | 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 THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /JavaScriptVIS/admin/admin.d.ts: -------------------------------------------------------------------------------- 1 | declare let systemDictionary: Record>; 2 | 3 | declare let load: (settings: Record, onChange: (hasChanges: boolean) => void) => void; 4 | declare let save: (callback: (settings: Record) => void) => void; 5 | 6 | // make load and save exist on the window object 7 | interface Window { 8 | load: typeof load; 9 | save: typeof save; 10 | } 11 | 12 | declare const instance: number; 13 | declare const adapter: string; 14 | /** Translates text */ 15 | declare function _(text: string, arg1?: string, arg2?: string, arg3?: string): string; 16 | declare const socket: ioBrokerSocket; 17 | declare function sendTo( 18 | instance: any | null, 19 | command: string, 20 | message: any, 21 | callback: (result: SendToResult) => void | Promise, 22 | ): void; 23 | 24 | interface SendToResult { 25 | error?: string | Error; 26 | result?: any; 27 | } 28 | 29 | // tslint:disable-next-line:class-name 30 | interface ioBrokerSocket { 31 | emit( 32 | command: 'subscribeObjects', 33 | pattern: string, 34 | callback?: (err?: string) => void | Promise, 35 | ): void; 36 | emit( 37 | command: 'subscribeStates', 38 | pattern: string, 39 | callback?: (err?: string) => void | Promise, 40 | ): void; 41 | emit( 42 | command: 'unsubscribeObjects', 43 | pattern: string, 44 | callback?: (err?: string) => void | Promise, 45 | ): void; 46 | emit( 47 | command: 'unsubscribeStates', 48 | pattern: string, 49 | callback?: (err?: string) => void | Promise, 50 | ): void; 51 | 52 | emit( 53 | event: 'getObjectView', 54 | view: 'system', 55 | type: 'device', 56 | options: ioBroker.GetObjectViewParams, 57 | callback: ( 58 | err: string | undefined, 59 | result?: any, 60 | ) => void | Promise, 61 | ): void; 62 | emit( 63 | event: 'getStates', 64 | callback: ( 65 | err: string | undefined, 66 | result?: Record, 67 | ) => void, 68 | ): void; 69 | emit( 70 | event: 'getState', 71 | id: string, 72 | callback: (err: string | undefined, result?: ioBroker.State) => void, 73 | ): void; 74 | emit( 75 | event: 'setState', 76 | id: string, 77 | state: unknown, 78 | callback: (err: string | undefined, result?: any) => void, 79 | ): void; 80 | 81 | on(event: 'objectChange', handler: ioBroker.ObjectChangeHandler): void; 82 | on(event: 'stateChange', handler: ioBroker.StateChangeHandler): void; 83 | removeEventHandler( 84 | event: 'objectChange', 85 | handler: ioBroker.ObjectChangeHandler, 86 | ): void; 87 | removeEventHandler( 88 | event: 'stateChange', 89 | handler: ioBroker.StateChangeHandler, 90 | ): void; 91 | 92 | // TODO: other events 93 | } 94 | -------------------------------------------------------------------------------- /JavaScriptVIS/admin/custom_m.html: -------------------------------------------------------------------------------- 1 | 22 | 23 | -------------------------------------------------------------------------------- /JavaScriptVIS/admin/i18n/de/translations.json: -------------------------------------------------------------------------------- 1 | { 2 | "template adapter settings": "Adaptereinstellungen für template", 3 | "option1": "Option1", 4 | "option2": "Option2" 5 | } -------------------------------------------------------------------------------- /JavaScriptVIS/admin/i18n/en/translations.json: -------------------------------------------------------------------------------- 1 | { 2 | "template adapter settings": "Adapter settings for template", 3 | "option1": "option1", 4 | "option2": "option2" 5 | } -------------------------------------------------------------------------------- /JavaScriptVIS/admin/i18n/es/translations.json: -------------------------------------------------------------------------------- 1 | { 2 | "template adapter settings": "Ajustes del adaptador para template", 3 | "option1": "opción1", 4 | "option2": "opción2" 5 | } -------------------------------------------------------------------------------- /JavaScriptVIS/admin/i18n/fr/translations.json: -------------------------------------------------------------------------------- 1 | { 2 | "template adapter settings": "Paramètres d'adaptateur pour template", 3 | "option1": "option1", 4 | "option2": "option2" 5 | } -------------------------------------------------------------------------------- /JavaScriptVIS/admin/i18n/it/translations.json: -------------------------------------------------------------------------------- 1 | { 2 | "template adapter settings": "Impostazioni dell'adattatore per template", 3 | "option1": "opzione1", 4 | "option2": "opzione2" 5 | } -------------------------------------------------------------------------------- /JavaScriptVIS/admin/i18n/nl/translations.json: -------------------------------------------------------------------------------- 1 | { 2 | "template adapter settings": "Adapterinstellingen voor template", 3 | "option1": "optie1", 4 | "option2": "optie2" 5 | } -------------------------------------------------------------------------------- /JavaScriptVIS/admin/i18n/pl/translations.json: -------------------------------------------------------------------------------- 1 | { 2 | "template adapter settings": "Ustawienia adaptera dla template", 3 | "option1": "opcja 1", 4 | "option2": "opcja 2" 5 | } -------------------------------------------------------------------------------- /JavaScriptVIS/admin/i18n/pt/translations.json: -------------------------------------------------------------------------------- 1 | { 2 | "template adapter settings": "Configurações do adaptador para template", 3 | "option1": "opção1", 4 | "option2": "opção2" 5 | } -------------------------------------------------------------------------------- /JavaScriptVIS/admin/i18n/ru/translations.json: -------------------------------------------------------------------------------- 1 | { 2 | "template adapter settings": "Настройки адаптера для template", 3 | "option1": "вариант 1", 4 | "option2": "вариант2" 5 | } -------------------------------------------------------------------------------- /JavaScriptVIS/admin/i18n/uk/translations.json: -------------------------------------------------------------------------------- 1 | { 2 | "template adapter settings": "Налаштування адаптера для template", 3 | "option1": "варіант1", 4 | "option2": "варіант2" 5 | } -------------------------------------------------------------------------------- /JavaScriptVIS/admin/i18n/zh-cn/translations.json: -------------------------------------------------------------------------------- 1 | { 2 | "template adapter settings": "template的适配器设置", 3 | "option1": "选项1", 4 | "option2": "选项2" 5 | } -------------------------------------------------------------------------------- /JavaScriptVIS/admin/jsonConfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "i18n": true, 3 | "type": "panel", 4 | "items": { 5 | "option1": { 6 | "type": "checkbox", 7 | "label": "option1", 8 | "newLine": true 9 | }, 10 | "option2": { 11 | "type": "text", 12 | "label": "option2", 13 | "newLine": true 14 | } 15 | } 16 | } -------------------------------------------------------------------------------- /JavaScriptVIS/admin/template.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ioBroker/ioBroker.example/46e3823aafe0d918fea64ed9dd5d56a64e009b19/JavaScriptVIS/admin/template.png -------------------------------------------------------------------------------- /JavaScriptVIS/lib/adapter-config.d.ts: -------------------------------------------------------------------------------- 1 | // This file extends the AdapterConfig type from "@types/iobroker" 2 | // using the actual properties present in io-package.json 3 | // in order to provide typings for adapter.config properties 4 | 5 | import { native } from '../io-package.json'; 6 | 7 | type _AdapterConfig = typeof native; 8 | 9 | // Augment the globally declared type ioBroker.AdapterConfig 10 | declare global { 11 | namespace ioBroker { 12 | interface AdapterConfig extends _AdapterConfig { 13 | // Do not enter anything here! 14 | } 15 | } 16 | } 17 | 18 | // this is required so the above AdapterConfig is found by TypeScript / type checking 19 | export {}; -------------------------------------------------------------------------------- /JavaScriptVIS/main.test.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | /** 4 | * This is a dummy TypeScript test file using chai and mocha 5 | * 6 | * It's automatically excluded from npm and its build output is excluded from both git and npm. 7 | * It is advised to test all your modules with accompanying *.test.js-files 8 | */ 9 | 10 | // tslint:disable:no-unused-expression 11 | 12 | const { expect } = require('chai'); 13 | // import { functionToTest } from "./moduleToTest"; 14 | 15 | describe('module to test => function to test', () => { 16 | // initializing logic 17 | const expected = 5; 18 | 19 | it(`should return ${expected}`, () => { 20 | const result = 5; 21 | // assign result a value from functionToTest 22 | expect(result).to.equal(expected); 23 | // or using the should() syntax 24 | result.should.equal(expected); 25 | }); 26 | // ... more tests => it 27 | 28 | }); 29 | 30 | // ... more test suites => describe 31 | -------------------------------------------------------------------------------- /JavaScriptVIS/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "iobroker.template", 3 | "version": "0.0.1", 4 | "description": "Template for adapter development", 5 | "author": { 6 | "name": "Author", 7 | "email": "author@mail.com" 8 | }, 9 | "homepage": "https://github.com/Author/ioBroker.template", 10 | "license": "MIT", 11 | "keywords": [ 12 | "ioBroker", 13 | "template", 14 | "Smart Home", 15 | "home automation" 16 | ], 17 | "repository": { 18 | "type": "git", 19 | "url": "https://github.com/Author/ioBroker.template.git" 20 | }, 21 | "engines": { 22 | "node": ">= 20" 23 | }, 24 | "dependencies": { 25 | "@iobroker/adapter-core": "^3.1.6" 26 | }, 27 | "devDependencies": { 28 | "@alcalzone/release-script": "^3.8.0", 29 | "@alcalzone/release-script-plugin-iobroker": "^3.7.2", 30 | "@alcalzone/release-script-plugin-license": "^3.7.0", 31 | "@alcalzone/release-script-plugin-manual-review": "^3.7.0", 32 | "@iobroker/adapter-dev": "^1.3.0", 33 | "@iobroker/testing": "^4.1.3", 34 | "@tsconfig/node20": "^20.1.4", 35 | "@types/chai-as-promised": "^7.1.8", 36 | "@types/chai": "^4.3.19", 37 | "@types/mocha": "^10.0.8", 38 | "@types/node": "^20.16.5", 39 | "@types/proxyquire": "^1.3.31", 40 | "@types/sinon": "^17.0.3", 41 | "@types/sinon-chai": "^3.2.12", 42 | "chai-as-promised": "^7.1.2", 43 | "chai": "^4.5.0", 44 | "eslint": "^8.57.0", 45 | "mocha": "^10.7.3", 46 | "proxyquire": "^2.1.3", 47 | "sinon": "^19.0.2", 48 | "sinon-chai": "^3.7.0", 49 | "typescript": "~5.0.4" 50 | }, 51 | "main": "main.js", 52 | "files": [ 53 | "admin{,/!(src)/**}/!(tsconfig|tsconfig.*|.eslintrc).{json,json5}", 54 | "admin{,/!(src)/**}/*.{html,css,png,svg,jpg,js}", 55 | "lib/", 56 | "widgets/**/!(tsconfig|tsconfig.*|.eslintrc).json", 57 | "widgets/**/*.{html,css,png,svg,jpg,js}", 58 | "www/", 59 | "io-package.json", 60 | "LICENSE", 61 | "main.js" 62 | ], 63 | "scripts": { 64 | "test:js": "mocha --config test/mocharc.custom.json \"{!(node_modules|test)/**/*.test.js,*.test.js,test/**/test!(PackageFiles|Startup).js}\"", 65 | "test:package": "mocha test/package --exit", 66 | "test:integration": "mocha test/integration --exit", 67 | "test": "npm run test:js && npm run test:package", 68 | "check": "tsc --noEmit -p tsconfig.check.json", 69 | "lint": "eslint .", 70 | "translate": "translate-adapter", 71 | "release": "release-script" 72 | }, 73 | "bugs": { 74 | "url": "https://github.com/Author/ioBroker.template/issues" 75 | }, 76 | "readmeFilename": "README.md" 77 | } -------------------------------------------------------------------------------- /JavaScriptVIS/test/integration.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | const { tests } = require('@iobroker/testing'); 3 | 4 | // Run integration tests - See https://github.com/ioBroker/testing for a detailed explanation and further options 5 | tests.integration(path.join(__dirname, '..')); -------------------------------------------------------------------------------- /JavaScriptVIS/test/mocha.setup.js: -------------------------------------------------------------------------------- 1 | // Don't silently swallow unhandled rejections 2 | process.on('unhandledRejection', (e) => { 3 | throw e; 4 | }); 5 | 6 | // enable the should interface with sinon 7 | // and load chai-as-promised and sinon-chai by default 8 | const sinonChai = require('sinon-chai'); 9 | const chaiAsPromised = require('chai-as-promised'); 10 | const { should, use } = require('chai'); 11 | 12 | should(); 13 | use(sinonChai); 14 | use(chaiAsPromised); -------------------------------------------------------------------------------- /JavaScriptVIS/test/mocharc.custom.json: -------------------------------------------------------------------------------- 1 | { 2 | "require": [ 3 | "test/mocha.setup.js" 4 | ], 5 | "watch-files": [ 6 | "!(node_modules|test)/**/*.test.js", 7 | "*.test.js", 8 | "test/**/test!(PackageFiles|Startup).js" 9 | ] 10 | } -------------------------------------------------------------------------------- /JavaScriptVIS/test/package.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | const { tests } = require('@iobroker/testing'); 3 | 4 | // Validate the package files 5 | tests.packageFiles(path.join(__dirname, '..')); 6 | -------------------------------------------------------------------------------- /JavaScriptVIS/test/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "noImplicitAny": false 5 | }, 6 | "include": [ 7 | "./**/*.js" 8 | ] 9 | } 10 | -------------------------------------------------------------------------------- /JavaScriptVIS/tsconfig.check.json: -------------------------------------------------------------------------------- 1 | // Specialized tsconfig for type-checking js files 2 | { 3 | "extends": "./tsconfig.json", 4 | "compilerOptions": {}, 5 | "include": [ 6 | "**/*.js", 7 | "**/*.d.ts" 8 | ], 9 | "exclude": [ 10 | "**/build", 11 | "node_modules/", 12 | "widgets/" 13 | ] 14 | } 15 | -------------------------------------------------------------------------------- /JavaScriptVIS/tsconfig.json: -------------------------------------------------------------------------------- 1 | // Root tsconfig to set the settings and power editor support for all TS files 2 | { 3 | // To update the compilation target, install a different version of @tsconfig/node... and reference it here 4 | // https://github.com/tsconfig/bases#node-20-tsconfigjson 5 | "extends": "@tsconfig/node20/tsconfig.json", 6 | "compilerOptions": { 7 | // do not compile anything, this file is just to configure type checking 8 | "noEmit": true, 9 | 10 | // check JS files 11 | "allowJs": true, 12 | "checkJs": true, 13 | 14 | // This is necessary for the automatic typing of the adapter config 15 | "resolveJsonModule": true, 16 | 17 | // If you want to disable the stricter type checks (not recommended), uncomment the following line 18 | // "strict": false, 19 | // And enable some of those features for more fine-grained control 20 | // "strictNullChecks": true, 21 | // "strictPropertyInitialization": true, 22 | // "strictBindCallApply": true, 23 | "noImplicitAny": false, 24 | // "noUnusedLocals": true, 25 | // "noUnusedParameters": true, 26 | "useUnknownInCatchVariables": false, 27 | 28 | }, 29 | "include": [ 30 | "**/*.js", 31 | "**/*.d.ts" 32 | ], 33 | "exclude": [ 34 | "node_modules/**", 35 | "widgets/**" 36 | ] 37 | } -------------------------------------------------------------------------------- /JavaScriptVIS/widgets/.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "browser": true, 4 | "es6": false 5 | }, 6 | "rules": { 7 | // Visualizations may run in very old browsers without `let` and `const` 8 | "no-var": "off", 9 | // The example code does not use some parameters. If unused variables should be 10 | // an error, delete the following rule 11 | "no-unused-vars": [ 12 | "warn", 13 | { 14 | "ignoreRestSiblings": true, 15 | "argsIgnorePattern": "^_" 16 | } 17 | ] 18 | } 19 | } -------------------------------------------------------------------------------- /JavaScriptVIS/widgets/template/css/style.css: -------------------------------------------------------------------------------- 1 | /* Style your widget here */ 2 | .template-class { 3 | font-style: italic; 4 | } -------------------------------------------------------------------------------- /JavaScriptVIS/widgets/template/js/template.js: -------------------------------------------------------------------------------- 1 | /* 2 | ioBroker.vis template Widget-Set 3 | 4 | version: "0.0.1" 5 | 6 | Copyright 2024 Author author@mail.com 7 | */ 8 | 'use strict'; 9 | 10 | /* global $, vis, systemDictionary */ 11 | 12 | // add translations for edit mode 13 | $.extend( 14 | true, 15 | systemDictionary, 16 | { 17 | // Add your translations here, e.g.: 18 | // "size": { 19 | // "en": "Size", 20 | // "de": "Größe", 21 | // "ru": "Размер", 22 | // "pt": "Tamanho", 23 | // "nl": "Grootte", 24 | // "fr": "Taille", 25 | // "it": "Dimensione", 26 | // "es": "Talla", 27 | // "pl": "Rozmiar", 28 | // "uk": "Розмір" 29 | // "zh-cn": "尺寸" 30 | // } 31 | } 32 | ); 33 | 34 | // this code can be placed directly in template.html 35 | vis.binds['template'] = { 36 | version: '0.0.1', 37 | showVersion: function () { 38 | if (vis.binds['template'].version) { 39 | console.log('Version template: ' + vis.binds['template'].version); 40 | vis.binds['template'].version = null; 41 | } 42 | }, 43 | createWidget: function (widgetID, view, data, style) { 44 | var $div = $('#' + widgetID); 45 | // if nothing found => wait 46 | if (!$div.length) { 47 | return setTimeout(function () { 48 | vis.binds['template'].createWidget(widgetID, view, data, style); 49 | }, 100); 50 | } 51 | 52 | var text = ''; 53 | text += 'OID: ' + data.oid + '
'; 54 | text += 'OID value: ' + vis.states[data.oid + '.val'] + '
'; 55 | text += 'Color: ' + data.myColor + '
'; 56 | text += 'extraAttr: ' + data.extraAttr + '
'; 57 | text += 'Browser instance: ' + vis.instance + '
'; 58 | text += 'htmlText:
'; 59 | 60 | $('#' + widgetID).html(text); 61 | 62 | // subscribe on updates of value 63 | function onChange(e, newVal, oldVal) { 64 | $div.find('.template-value').html(newVal); 65 | } 66 | if (data.oid) { 67 | vis.states.bind(data.oid + '.val', onChange); 68 | //remember bound state that vis can release if didnt needed 69 | $div.data('bound', [data.oid + '.val']); 70 | //remember onchange handler to release bound states 71 | $div.data('bindHandler', onChange); 72 | } 73 | } 74 | }; 75 | 76 | vis.binds['template'].showVersion(); -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ioBroker examples 2 | 3 | This is a collection of examples for ioBroker developers to create adapters or VIS widgets. You can use it to get an overview how ioBroker adapter code and structure looks like. 4 | 5 | Please use [`@iobroker/create-adapter`](https://github.com/ioBroker/create-adapter) to generate a custom skeleton based on your exact needs. We recommend that way if you start developing an adapter or widget. 6 | 7 | 8 | 9 | ## Templates 10 | Currently, the following templates are available: 11 | 12 | ### Adapter and visualization 13 | 14 | #### [JavaScript](JavaScriptVIS) 15 | 16 | #### [TypeScript](TypeScriptVIS) 17 | 18 | ### Adapter only 19 | 20 | #### [JavaScript](JavaScript) 21 | 22 | #### [TypeScript](TypeScript) 23 | 24 | ## [Visualization only](VIS) 25 | 26 | 27 | ## Features 28 | All templates come with the following features: 29 | * IntelliSense (auto completion and tooltips) in supporting editors 30 | * JavaScript only: 31 | * [ESLint](https://github.com/eslint/eslint) for code quality 32 | * Type checking based on the ioBroker declarations 33 | * TypeScript only: 34 | * [ESLint](https://github.com/eslint/eslint) for code quality 35 | * [nyc](https://github.com/istanbuljs/nyc) for code coverage 36 | * Built-in component tests using `mocha` & `chai` (with `chai-as-promised`) and `sinon` (with `sinon-chai`) for: 37 | * Correctly defined package files 38 | * and your own tests 39 | * ... [and more to come](https://github.com/ioBroker/create-adapter/blob/master/README.md#roadmap) 40 | 41 | ## Anything missing? 42 | The templates are automatically generated using [`@iobroker/create-adapter`](https://github.com/ioBroker/create-adapter). If you're missing a feature or found a bug, please open an issue in that repository. Or consider using the tool directly for much more configuration goodness. 43 | 44 | ## For developers 45 | Please don't edit these files directly (except this README). Instead the CI builds in the `create-adapter` repo should be updated. 46 | -------------------------------------------------------------------------------- /TypeScript/.create-adapter.json: -------------------------------------------------------------------------------- 1 | { 2 | "cli": true, 3 | "target": "directory", 4 | "adapterName": "template", 5 | "description": "Template for adapter development", 6 | "authorName": "Author", 7 | "authorGithub": "Author", 8 | "authorEmail": "author@mail.com", 9 | "gitRemoteProtocol": "HTTPS", 10 | "dependabot": "yes", 11 | "license": "MIT License", 12 | "releaseScript": "yes", 13 | "gitCommit": "no", 14 | "defaultBranch": "main", 15 | "startMode": "daemon", 16 | "features": [ 17 | "adapter" 18 | ], 19 | "connectionIndicator": "no", 20 | "type": "general", 21 | "adminFeatures": [ 22 | "custom", 23 | "tab" 24 | ], 25 | "adminUi": "json", 26 | "tabReact": "no", 27 | "language": "TypeScript", 28 | "title": "Template (TypeScript)", 29 | "tools": [ 30 | "ESLint", 31 | "code coverage" 32 | ], 33 | "indentation": "Tab", 34 | "quotes": "double", 35 | "creatorVersion": "2.6.5" 36 | } -------------------------------------------------------------------------------- /TypeScript/.eslintignore: -------------------------------------------------------------------------------- 1 | build/ 2 | **/.eslintrc.js 3 | admin/words.js -------------------------------------------------------------------------------- /TypeScript/.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | root: true, // Don't look outside this project for inherited configs 3 | parser: "@typescript-eslint/parser", // Specifies the ESLint parser 4 | parserOptions: { 5 | ecmaVersion: "latest", // Allows for the parsing of modern ECMAScript features 6 | sourceType: "module", // Allows for the use of imports 7 | project: "./tsconfig.json", 8 | }, 9 | extends: [ 10 | "plugin:@typescript-eslint/recommended", // Uses the recommended rules from the @typescript-eslint/eslint-plugin 11 | ], 12 | plugins: [], 13 | rules: { 14 | "indent": "off", 15 | "@typescript-eslint/indent": [ 16 | "error", 17 | "tab", 18 | { 19 | "SwitchCase": 1 20 | } 21 | ], 22 | "quotes": [ 23 | "error", 24 | "double", 25 | { 26 | "avoidEscape": true, 27 | "allowTemplateLiterals": true 28 | } 29 | ], 30 | "@typescript-eslint/no-parameter-properties": "off", 31 | "@typescript-eslint/no-explicit-any": "off", 32 | "@typescript-eslint/no-use-before-define": [ 33 | "error", 34 | { 35 | functions: false, 36 | typedefs: false, 37 | classes: false, 38 | }, 39 | ], 40 | "@typescript-eslint/no-unused-vars": [ 41 | "error", 42 | { 43 | ignoreRestSiblings: true, 44 | argsIgnorePattern: "^_", 45 | }, 46 | ], 47 | "@typescript-eslint/explicit-function-return-type": [ 48 | "warn", 49 | { 50 | allowExpressions: true, 51 | allowTypedFunctionExpressions: true, 52 | }, 53 | ], 54 | "@typescript-eslint/no-object-literal-type-assertion": "off", 55 | "@typescript-eslint/interface-name-prefix": "off", 56 | "@typescript-eslint/no-non-null-assertion": "off", // This is necessary for Map.has()/get()! 57 | "no-var": "error", 58 | "prefer-const": "error", 59 | "no-trailing-spaces": "error", 60 | }, 61 | overrides: [ 62 | { 63 | files: ["*.test.ts"], 64 | rules: { 65 | "@typescript-eslint/explicit-function-return-type": "off", 66 | }, 67 | }, 68 | ], 69 | }; -------------------------------------------------------------------------------- /TypeScript/.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Something is not working as it should 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | --- 8 | 9 | **Describe the bug** 10 | A clear and concise description of what the bug is. 11 | 12 | **To Reproduce** 13 | Steps to reproduce the behavior: 14 | 1. Go to '...' 15 | 2. Click on '...' 16 | 3. Scroll down to '....' 17 | 4. See error 18 | 19 | **Expected behavior** 20 | A clear and concise description of what you expected to happen. 21 | 22 | **Screenshots & Logfiles** 23 | If applicable, add screenshots and logfiles to help explain your problem. 24 | 25 | **Versions:** 26 | - Adapter version: 27 | - JS-Controller version: 28 | - Node version: 29 | - Operating system: 30 | 31 | **Additional context** 32 | Add any other context about the problem here. 33 | -------------------------------------------------------------------------------- /TypeScript/.github/auto-merge.yml: -------------------------------------------------------------------------------- 1 | # Configure here which dependency updates should be merged automatically. 2 | # The recommended configuration is the following: 3 | - match: 4 | # Only merge patches for production dependencies 5 | dependency_type: production 6 | update_type: "semver:patch" 7 | - match: 8 | # Except for security fixes, here we allow minor patches 9 | dependency_type: production 10 | update_type: "security:minor" 11 | - match: 12 | # and development dependencies can have a minor update, too 13 | dependency_type: development 14 | update_type: "semver:minor" 15 | 16 | # The syntax is based on the legacy dependabot v1 automerged_updates syntax, see: 17 | # https://dependabot.com/docs/config-file/#automerged_updates 18 | -------------------------------------------------------------------------------- /TypeScript/.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: npm 4 | directory: "/" 5 | schedule: 6 | interval: monthly 7 | time: "04:00" 8 | timezone: Europe/Berlin 9 | open-pull-requests-limit: 5 10 | assignees: 11 | - Author 12 | versioning-strategy: increase 13 | 14 | - package-ecosystem: github-actions 15 | directory: "/" 16 | schedule: 17 | interval: monthly 18 | time: "04:00" 19 | timezone: Europe/Berlin 20 | open-pull-requests-limit: 5 21 | assignees: 22 | - Author 23 | -------------------------------------------------------------------------------- /TypeScript/.github/workflows/dependabot-auto-merge.yml: -------------------------------------------------------------------------------- 1 | # Automatically merge Dependabot PRs when version comparison is within the range 2 | # that is configured in .github/auto-merge.yml 3 | 4 | name: Auto-Merge Dependabot PRs 5 | 6 | on: 7 | # WARNING: This needs to be run in the PR base, DO NOT build untrusted code in this action 8 | # details under https://github.blog/changelog/2021-02-19-github-actions-workflows-triggered-by-dependabot-prs-will-run-with-read-only-permissions/ 9 | pull_request_target: 10 | 11 | jobs: 12 | auto-merge: 13 | if: github.actor == 'dependabot[bot]' 14 | runs-on: ubuntu-latest 15 | steps: 16 | - name: Checkout code 17 | uses: actions/checkout@v2 18 | 19 | - name: Check if PR should be auto-merged 20 | uses: ahmadnassri/action-dependabot-auto-merge@v2 21 | with: 22 | # In order to use this, you need to go to https://github.com/settings/tokens and 23 | # create a Personal Access Token with the permission "public_repo". 24 | # Enter this token in your repository settings under "Secrets" and name it AUTO_MERGE_TOKEN 25 | github-token: ${{ secrets.AUTO_MERGE_TOKEN }} 26 | # By default, squash and merge, so Github chooses nice commit messages 27 | command: squash and merge 28 | -------------------------------------------------------------------------------- /TypeScript/.gitignore: -------------------------------------------------------------------------------- 1 | # No dot-directories except github/vscode 2 | .*/ 3 | !.vscode/ 4 | !.github/ 5 | 6 | *.code-workspace 7 | node_modules 8 | nbproject 9 | 10 | # npm package files 11 | iobroker.*.tgz 12 | 13 | Thumbs.db 14 | 15 | # NYC coverage files 16 | coverage 17 | 18 | # i18n intermediate files 19 | admin/i18n/flat.txt 20 | admin/i18n/*/flat.txt -------------------------------------------------------------------------------- /TypeScript/.releaseconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "plugins": [ 3 | "iobroker", 4 | "license", 5 | "manual-review" 6 | ], 7 | "exec": { 8 | "before_commit": "npm run build" 9 | } 10 | } -------------------------------------------------------------------------------- /TypeScript/.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | "recommendations": [ 3 | "dbaeumer.vscode-eslint" 4 | ] 5 | } -------------------------------------------------------------------------------- /TypeScript/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "typescript.tsdk": "node_modules/typescript/lib", 3 | "eslint.enable": true, 4 | "json.schemas": [ 5 | { 6 | "fileMatch": [ 7 | "io-package.json" 8 | ], 9 | "url": "https://raw.githubusercontent.com/ioBroker/ioBroker.js-controller/master/schemas/io-package.json" 10 | }, 11 | { 12 | "fileMatch": [ 13 | "admin/jsonConfig.json", 14 | "admin/jsonCustom.json", 15 | "admin/jsonTab.json" 16 | ], 17 | "url": "https://raw.githubusercontent.com/ioBroker/adapter-react-v5/main/schemas/jsonConfig.json" 18 | } 19 | ] 20 | } -------------------------------------------------------------------------------- /TypeScript/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2024 Author 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 all 13 | 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 THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /TypeScript/admin/admin.d.ts: -------------------------------------------------------------------------------- 1 | declare let systemDictionary: Record>; 2 | 3 | declare let load: (settings: Record, onChange: (hasChanges: boolean) => void) => void; 4 | declare let save: (callback: (settings: Record) => void) => void; 5 | 6 | // make load and save exist on the window object 7 | interface Window { 8 | load: typeof load; 9 | save: typeof save; 10 | } 11 | 12 | declare const instance: number; 13 | declare const adapter: string; 14 | /** Translates text */ 15 | declare function _(text: string, arg1?: string, arg2?: string, arg3?: string): string; 16 | declare const socket: ioBrokerSocket; 17 | declare function sendTo( 18 | instance: any | null, 19 | command: string, 20 | message: any, 21 | callback: (result: SendToResult) => void | Promise, 22 | ): void; 23 | 24 | interface SendToResult { 25 | error?: string | Error; 26 | result?: any; 27 | } 28 | 29 | // tslint:disable-next-line:class-name 30 | interface ioBrokerSocket { 31 | emit( 32 | command: "subscribeObjects", 33 | pattern: string, 34 | callback?: (err?: string) => void | Promise, 35 | ): void; 36 | emit( 37 | command: "subscribeStates", 38 | pattern: string, 39 | callback?: (err?: string) => void | Promise, 40 | ): void; 41 | emit( 42 | command: "unsubscribeObjects", 43 | pattern: string, 44 | callback?: (err?: string) => void | Promise, 45 | ): void; 46 | emit( 47 | command: "unsubscribeStates", 48 | pattern: string, 49 | callback?: (err?: string) => void | Promise, 50 | ): void; 51 | 52 | emit( 53 | event: "getObjectView", 54 | view: "system", 55 | type: "device", 56 | options: ioBroker.GetObjectViewParams, 57 | callback: ( 58 | err: string | undefined, 59 | result?: any, 60 | ) => void | Promise, 61 | ): void; 62 | emit( 63 | event: "getStates", 64 | callback: ( 65 | err: string | undefined, 66 | result?: Record, 67 | ) => void, 68 | ): void; 69 | emit( 70 | event: "getState", 71 | id: string, 72 | callback: (err: string | undefined, result?: ioBroker.State) => void, 73 | ): void; 74 | emit( 75 | event: "setState", 76 | id: string, 77 | state: unknown, 78 | callback: (err: string | undefined, result?: any) => void, 79 | ): void; 80 | 81 | on(event: "objectChange", handler: ioBroker.ObjectChangeHandler): void; 82 | on(event: "stateChange", handler: ioBroker.StateChangeHandler): void; 83 | removeEventHandler( 84 | event: "objectChange", 85 | handler: ioBroker.ObjectChangeHandler, 86 | ): void; 87 | removeEventHandler( 88 | event: "stateChange", 89 | handler: ioBroker.StateChangeHandler, 90 | ): void; 91 | 92 | // TODO: other events 93 | } 94 | -------------------------------------------------------------------------------- /TypeScript/admin/custom_m.html: -------------------------------------------------------------------------------- 1 | 22 | 23 | -------------------------------------------------------------------------------- /TypeScript/admin/i18n/de/translations.json: -------------------------------------------------------------------------------- 1 | { 2 | "template adapter settings": "Adaptereinstellungen für template", 3 | "option1": "Option1", 4 | "option2": "Option2" 5 | } -------------------------------------------------------------------------------- /TypeScript/admin/i18n/en/translations.json: -------------------------------------------------------------------------------- 1 | { 2 | "template adapter settings": "Adapter settings for template", 3 | "option1": "option1", 4 | "option2": "option2" 5 | } -------------------------------------------------------------------------------- /TypeScript/admin/i18n/es/translations.json: -------------------------------------------------------------------------------- 1 | { 2 | "template adapter settings": "Ajustes del adaptador para template", 3 | "option1": "opción1", 4 | "option2": "opción2" 5 | } -------------------------------------------------------------------------------- /TypeScript/admin/i18n/fr/translations.json: -------------------------------------------------------------------------------- 1 | { 2 | "template adapter settings": "Paramètres d'adaptateur pour template", 3 | "option1": "option1", 4 | "option2": "option2" 5 | } -------------------------------------------------------------------------------- /TypeScript/admin/i18n/it/translations.json: -------------------------------------------------------------------------------- 1 | { 2 | "template adapter settings": "Impostazioni dell'adattatore per template", 3 | "option1": "opzione1", 4 | "option2": "opzione2" 5 | } -------------------------------------------------------------------------------- /TypeScript/admin/i18n/nl/translations.json: -------------------------------------------------------------------------------- 1 | { 2 | "template adapter settings": "Adapterinstellingen voor template", 3 | "option1": "optie1", 4 | "option2": "optie2" 5 | } -------------------------------------------------------------------------------- /TypeScript/admin/i18n/pl/translations.json: -------------------------------------------------------------------------------- 1 | { 2 | "template adapter settings": "Ustawienia adaptera dla template", 3 | "option1": "opcja 1", 4 | "option2": "opcja 2" 5 | } -------------------------------------------------------------------------------- /TypeScript/admin/i18n/pt/translations.json: -------------------------------------------------------------------------------- 1 | { 2 | "template adapter settings": "Configurações do adaptador para template", 3 | "option1": "opção1", 4 | "option2": "opção2" 5 | } -------------------------------------------------------------------------------- /TypeScript/admin/i18n/ru/translations.json: -------------------------------------------------------------------------------- 1 | { 2 | "template adapter settings": "Настройки адаптера для template", 3 | "option1": "вариант 1", 4 | "option2": "вариант2" 5 | } -------------------------------------------------------------------------------- /TypeScript/admin/i18n/uk/translations.json: -------------------------------------------------------------------------------- 1 | { 2 | "template adapter settings": "Налаштування адаптера для template", 3 | "option1": "варіант1", 4 | "option2": "варіант2" 5 | } -------------------------------------------------------------------------------- /TypeScript/admin/i18n/zh-cn/translations.json: -------------------------------------------------------------------------------- 1 | { 2 | "template adapter settings": "template的适配器设置", 3 | "option1": "选项1", 4 | "option2": "选项2" 5 | } -------------------------------------------------------------------------------- /TypeScript/admin/jsonConfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "i18n": true, 3 | "type": "panel", 4 | "items": { 5 | "option1": { 6 | "type": "checkbox", 7 | "label": "option1", 8 | "newLine": true 9 | }, 10 | "option2": { 11 | "type": "text", 12 | "label": "option2", 13 | "newLine": true 14 | } 15 | } 16 | } -------------------------------------------------------------------------------- /TypeScript/admin/tab_m.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 21 | 22 | 23 | 24 | 25 |
26 |
27 | 29 |
30 |
31 | 32 |
33 |
34 |
35 |
36 | 37 | 38 |
39 |
40 |
41 |
42 | 43 | 44 | Descriptions of the input field 45 |
46 |
47 | 48 | 49 | 50 | test2 51 |
52 |
53 | 54 | 55 | 56 | Verification input 57 |
58 |
59 |
60 |
61 | 65 | 66 | 67 |
68 |
69 | mode_edit 70 | 71 | 72 |
73 |
74 |
75 |
76 | 77 | 78 | 79 | -------------------------------------------------------------------------------- /TypeScript/admin/template.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ioBroker/ioBroker.example/46e3823aafe0d918fea64ed9dd5d56a64e009b19/TypeScript/admin/template.png -------------------------------------------------------------------------------- /TypeScript/admin/words.js: -------------------------------------------------------------------------------- 1 | /* eslint no-unused-vars: off */ 2 | /* eslint no-global-assign: off */ 3 | /* global systemDictionary */ 4 | "use strict"; 5 | 6 | systemDictionary = { 7 | "template adapter settings": { 8 | "en": "Adapter settings for template", 9 | "de": "Adaptereinstellungen für template", 10 | "ru": "Настройки адаптера для template", 11 | "pt": "Configurações do adaptador para template", 12 | "nl": "Adapterinstellingen voor template", 13 | "fr": "Paramètres d'adaptateur pour template", 14 | "it": "Impostazioni dell'adattatore per template", 15 | "es": "Ajustes del adaptador para template", 16 | "pl": "Ustawienia adaptera dla template", 17 | "uk": "Налаштування адаптера для template", 18 | "zh-cn": "template的适配器设置" 19 | }, 20 | "option1": { 21 | "en": "option1", 22 | "de": "Option1", 23 | "ru": "вариант 1", 24 | "pt": "opção1", 25 | "nl": "optie1", 26 | "fr": "option1", 27 | "it": "opzione1", 28 | "es": "opción1", 29 | "pl": "opcja 1", 30 | "uk": "варіант1", 31 | "zh-cn": "选项1" 32 | }, 33 | "option2": { 34 | "en": "option2", 35 | "de": "Option2", 36 | "ru": "вариант2", 37 | "pt": "opção2", 38 | "nl": "optie2", 39 | "fr": "option2", 40 | "it": "opzione2", 41 | "es": "opción2", 42 | "pl": "opcja 2", 43 | "uk": "варіант2", 44 | "zh-cn": "选项2" 45 | } 46 | }; -------------------------------------------------------------------------------- /TypeScript/io-package.json: -------------------------------------------------------------------------------- 1 | { 2 | "common": { 3 | "name": "template", 4 | "version": "0.0.1", 5 | "news": { 6 | "0.0.1": { 7 | "en": "initial release", 8 | "de": "Erstveröffentlichung", 9 | "ru": "Начальная версия", 10 | "pt": "lançamento inicial", 11 | "nl": "Eerste uitgave", 12 | "fr": "Première version", 13 | "it": "Versione iniziale", 14 | "es": "Versión inicial", 15 | "pl": "Pierwsze wydanie", 16 | "uk": "Початкова версія", 17 | "zh-cn": "首次出版" 18 | } 19 | }, 20 | "titleLang": { 21 | "en": "Template (TypeScript)", 22 | "de": "Vorlage (TypeScript)", 23 | "ru": "Шаблон (TypeScript)", 24 | "pt": "Modelo (TypeScript)", 25 | "nl": "Sjabloon (typescript)", 26 | "fr": "Modèle (TypeScript)", 27 | "it": "Modello (TypeScript)", 28 | "es": "Plantilla (mecanografiado)", 29 | "pl": "Szablon (TypeScript)", 30 | "uk": "Шаблон (TypeScript)", 31 | "zh-cn": "模板(打字稿)" 32 | }, 33 | "desc": { 34 | "en": "Template for adapter development", 35 | "de": "Vorlage für die Adapterentwicklung", 36 | "ru": "Шаблон для разработки адаптера", 37 | "pt": "Modelo para desenvolvimento de adaptador", 38 | "nl": "Sjabloon voor adapterontwikkeling", 39 | "fr": "Modèle pour le développement d'adaptateurs", 40 | "it": "Modello per lo sviluppo dell'adattatore", 41 | "es": "Plantilla para el desarrollo de adaptadores.", 42 | "pl": "Szablon do opracowania adaptera", 43 | "uk": "Шаблон для розробки адаптера", 44 | "zh-cn": "适配器开发模板" 45 | }, 46 | "authors": [ 47 | "Author " 48 | ], 49 | "keywords": [ 50 | "ioBroker", 51 | "template", 52 | "Smart Home", 53 | "home automation" 54 | ], 55 | "licenseInformation": { 56 | "type": "free", 57 | "license": "MIT" 58 | }, 59 | "platform": "Javascript/Node.js", 60 | "icon": "template.png", 61 | "enabled": true, 62 | "extIcon": "https://raw.githubusercontent.com/Author/ioBroker.template/main/admin/template.png", 63 | "readme": "https://github.com/Author/ioBroker.template/blob/main/README.md", 64 | "loglevel": "info", 65 | "tier": 3, 66 | "mode": "daemon", 67 | "type": "general", 68 | "compact": true, 69 | "adminUI": { 70 | "config": "json", 71 | "tab": "materialize" 72 | }, 73 | "adminTab": { 74 | "singleton": true, 75 | "name": { 76 | "en": "Template (TypeScript)", 77 | "de": "Vorlage (TypeScript)", 78 | "ru": "Шаблон (TypeScript)", 79 | "pt": "Modelo (TypeScript)", 80 | "nl": "Sjabloon (typescript)", 81 | "fr": "Modèle (TypeScript)", 82 | "it": "Modello (TypeScript)", 83 | "es": "Plantilla (mecanografiado)", 84 | "pl": "Szablon (TypeScript)", 85 | "uk": "Шаблон (TypeScript)", 86 | "zh-cn": "模板(打字稿)" 87 | }, 88 | "link": "", 89 | "fa-icon": "info" 90 | }, 91 | "supportCustoms": true, 92 | "dependencies": [ 93 | { 94 | "js-controller": ">=6.0.11" 95 | } 96 | ], 97 | "globalDependencies": [ 98 | { 99 | "admin": "7.0.23" 100 | } 101 | ] 102 | }, 103 | "native": { 104 | "option1": true, 105 | "option2": "42" 106 | }, 107 | "objects": [], 108 | "instanceObjects": [] 109 | } -------------------------------------------------------------------------------- /TypeScript/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "iobroker.template", 3 | "version": "0.0.1", 4 | "description": "Template for adapter development", 5 | "author": { 6 | "name": "Author", 7 | "email": "author@mail.com" 8 | }, 9 | "homepage": "https://github.com/Author/ioBroker.template", 10 | "license": "MIT", 11 | "keywords": [ 12 | "ioBroker", 13 | "template", 14 | "Smart Home", 15 | "home automation" 16 | ], 17 | "repository": { 18 | "type": "git", 19 | "url": "https://github.com/Author/ioBroker.template.git" 20 | }, 21 | "engines": { 22 | "node": ">= 20" 23 | }, 24 | "dependencies": { 25 | "@iobroker/adapter-core": "^3.1.6" 26 | }, 27 | "devDependencies": { 28 | "@alcalzone/release-script": "^3.8.0", 29 | "@alcalzone/release-script-plugin-iobroker": "^3.7.2", 30 | "@alcalzone/release-script-plugin-license": "^3.7.0", 31 | "@alcalzone/release-script-plugin-manual-review": "^3.7.0", 32 | "@iobroker/adapter-dev": "^1.3.0", 33 | "@iobroker/testing": "^4.1.3", 34 | "@tsconfig/node20": "^20.1.4", 35 | "@types/chai-as-promised": "^7.1.8", 36 | "@types/chai": "^4.3.19", 37 | "@types/mocha": "^10.0.8", 38 | "@types/node": "^20.16.5", 39 | "@types/proxyquire": "^1.3.31", 40 | "@types/sinon": "^17.0.3", 41 | "@types/sinon-chai": "^3.2.12", 42 | "@typescript-eslint/eslint-plugin": "^7.18.0", 43 | "@typescript-eslint/parser": "^7.18.0", 44 | "chai-as-promised": "^7.1.2", 45 | "chai": "^4.5.0", 46 | "eslint": "^8.57.0", 47 | "mocha": "^10.7.3", 48 | "nyc": "^17.0.0", 49 | "proxyquire": "^2.1.3", 50 | "rimraf": "^6.0.1", 51 | "sinon": "^19.0.2", 52 | "sinon-chai": "^3.7.0", 53 | "source-map-support": "^0.5.21", 54 | "ts-node": "^10.9.2", 55 | "typescript": "~5.0.4" 56 | }, 57 | "main": "build/main.js", 58 | "files": [ 59 | "admin{,/!(src)/**}/!(tsconfig|tsconfig.*|.eslintrc).{json,json5}", 60 | "admin{,/!(src)/**}/*.{html,css,png,svg,jpg,js}", 61 | "build/", 62 | "www/", 63 | "io-package.json", 64 | "LICENSE" 65 | ], 66 | "scripts": { 67 | "prebuild": "rimraf build", 68 | "build": "build-adapter ts", 69 | "watch": "build-adapter ts --watch", 70 | "prebuild:ts": "rimraf build", 71 | "build:ts": "build-adapter ts", 72 | "watch:ts": "build-adapter ts --watch", 73 | "test:ts": "mocha --config test/mocharc.custom.json src/**/*.test.ts", 74 | "test:package": "mocha test/package --exit", 75 | "test:integration": "mocha test/integration --exit", 76 | "test": "npm run test:ts && npm run test:package", 77 | "check": "tsc --noEmit", 78 | "coverage": "nyc npm run test:ts", 79 | "lint": "eslint --ext .ts src/", 80 | "translate": "translate-adapter", 81 | "release": "release-script" 82 | }, 83 | "nyc": { 84 | "include": [ 85 | "src/**/*.ts" 86 | ], 87 | "exclude": [ 88 | "src/**/*.test.ts" 89 | ], 90 | "extension": [ 91 | ".ts" 92 | ], 93 | "require": [ 94 | "ts-node/register" 95 | ], 96 | "reporter": [ 97 | "text-summary", 98 | "html" 99 | ], 100 | "sourceMap": true, 101 | "instrument": true 102 | }, 103 | "bugs": { 104 | "url": "https://github.com/Author/ioBroker.template/issues" 105 | }, 106 | "readmeFilename": "README.md" 107 | } -------------------------------------------------------------------------------- /TypeScript/src/lib/adapter-config.d.ts: -------------------------------------------------------------------------------- 1 | // This file extends the AdapterConfig type from "@types/iobroker" 2 | 3 | // Augment the globally declared type ioBroker.AdapterConfig 4 | declare global { 5 | namespace ioBroker { 6 | interface AdapterConfig { 7 | option1: boolean; 8 | option2: string; 9 | } 10 | } 11 | } 12 | 13 | // this is required so the above AdapterConfig is found by TypeScript / type checking 14 | export {}; -------------------------------------------------------------------------------- /TypeScript/src/main.test.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This is a dummy TypeScript test file using chai and mocha 3 | * 4 | * It's automatically excluded from npm and its build output is excluded from both git and npm. 5 | * It is advised to test all your modules with accompanying *.test.ts-files 6 | */ 7 | 8 | import { expect } from "chai"; 9 | // import { functionToTest } from "./moduleToTest"; 10 | 11 | describe("module to test => function to test", () => { 12 | // initializing logic 13 | const expected = 5; 14 | 15 | it(`should return ${expected}`, () => { 16 | const result = 5; 17 | // assign result a value from functionToTest 18 | expect(result).to.equal(expected); 19 | // or using the should() syntax 20 | result.should.equal(expected); 21 | }); 22 | // ... more tests => it 23 | 24 | }); 25 | 26 | // ... more test suites => describe 27 | -------------------------------------------------------------------------------- /TypeScript/test/.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "root": true, 3 | "env": { 4 | "es6": true, 5 | "node": true, 6 | "mocha": true 7 | }, 8 | "extends": [ 9 | "eslint:recommended" 10 | ], 11 | "rules": { 12 | "indent": [ 13 | "error", 14 | "tab", 15 | { 16 | "SwitchCase": 1 17 | } 18 | ], 19 | "no-console": "off", 20 | "no-unused-vars": [ 21 | "error", 22 | { 23 | "ignoreRestSiblings": true, 24 | "argsIgnorePattern": "^_" 25 | } 26 | ], 27 | "no-var": "error", 28 | "no-trailing-spaces": "error", 29 | "prefer-const": "error", 30 | "quotes": [ 31 | "error", 32 | "double", 33 | { 34 | "avoidEscape": true, 35 | "allowTemplateLiterals": true 36 | } 37 | ], 38 | "semi": [ 39 | "error", 40 | "always" 41 | ] 42 | } 43 | } -------------------------------------------------------------------------------- /TypeScript/test/integration.js: -------------------------------------------------------------------------------- 1 | const path = require("path"); 2 | const { tests } = require("@iobroker/testing"); 3 | 4 | // Run integration tests - See https://github.com/ioBroker/testing for a detailed explanation and further options 5 | tests.integration(path.join(__dirname, "..")); -------------------------------------------------------------------------------- /TypeScript/test/mocha.setup.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | // Makes ts-node ignore warnings, so mocha --watch does work 4 | process.env.TS_NODE_IGNORE_WARNINGS = "TRUE"; 5 | // Sets the correct tsconfig for testing 6 | process.env.TS_NODE_PROJECT = "tsconfig.json"; 7 | // Make ts-node respect the "include" key in tsconfig.json 8 | process.env.TS_NODE_FILES = "TRUE"; 9 | 10 | // Don't silently swallow unhandled rejections 11 | process.on("unhandledRejection", (e) => { 12 | throw e; 13 | }); 14 | 15 | // enable the should interface with sinon 16 | // and load chai-as-promised and sinon-chai by default 17 | const sinonChai = require("sinon-chai"); 18 | const chaiAsPromised = require("chai-as-promised"); 19 | const { should, use } = require("chai"); 20 | 21 | should(); 22 | use(sinonChai); 23 | use(chaiAsPromised); -------------------------------------------------------------------------------- /TypeScript/test/mocharc.custom.json: -------------------------------------------------------------------------------- 1 | { 2 | "require": [ 3 | "test/mocha.setup.js", 4 | "ts-node/register", 5 | "source-map-support/register" 6 | ], 7 | "watch-files": [ 8 | "src/**/*.test.ts" 9 | ] 10 | } -------------------------------------------------------------------------------- /TypeScript/test/package.js: -------------------------------------------------------------------------------- 1 | const path = require("path"); 2 | const { tests } = require("@iobroker/testing"); 3 | 4 | // Validate the package files 5 | tests.packageFiles(path.join(__dirname, "..")); 6 | -------------------------------------------------------------------------------- /TypeScript/test/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "noImplicitAny": false 5 | }, 6 | "include": [ 7 | "./**/*.js" 8 | ] 9 | } 10 | -------------------------------------------------------------------------------- /TypeScript/tsconfig.build.json: -------------------------------------------------------------------------------- 1 | // Specialized tsconfig to only compile .ts-files in the src dir 2 | { 3 | "extends": "./tsconfig.json", 4 | "compilerOptions": { 5 | "allowJs": false, 6 | "checkJs": false, 7 | "noEmit": false, 8 | "declaration": false 9 | }, 10 | "include": [ 11 | "src/**/*.ts" 12 | ], 13 | "exclude": [ 14 | "src/**/*.test.ts" 15 | ] 16 | } 17 | -------------------------------------------------------------------------------- /TypeScript/tsconfig.json: -------------------------------------------------------------------------------- 1 | // Root tsconfig to set the settings and power editor support for all TS files 2 | { 3 | // To update the compilation target, install a different version of @tsconfig/node... and reference it here 4 | // https://github.com/tsconfig/bases#node-20-tsconfigjson 5 | "extends": "@tsconfig/node20/tsconfig.json", 6 | "compilerOptions": { 7 | // do not compile anything, this file is just to configure type checking 8 | // the compilation is configured in tsconfig.build.json 9 | "noEmit": true, 10 | 11 | // check JS files, but do not compile them => tsconfig.build.json 12 | "allowJs": true, 13 | "checkJs": true, 14 | 15 | "noEmitOnError": true, 16 | "outDir": "./build/", 17 | "removeComments": false, 18 | 19 | // This is necessary for the automatic typing of the adapter config 20 | "resolveJsonModule": true, 21 | 22 | // If you want to disable the stricter type checks (not recommended), uncomment the following line 23 | // "strict": false, 24 | // And enable some of those features for more fine-grained control 25 | // "strictNullChecks": true, 26 | // "strictPropertyInitialization": true, 27 | // "strictBindCallApply": true, 28 | // "noImplicitAny": true, 29 | // "noUnusedLocals": true, 30 | // "noUnusedParameters": true, 31 | // Uncomment this if you want the old behavior of catch variables being `any` 32 | // "useUnknownInCatchVariables": false, 33 | 34 | "sourceMap": true, 35 | "inlineSourceMap": false 36 | }, 37 | "include": [ 38 | "src/**/*.ts", 39 | "test/**/*.ts" 40 | ], 41 | "exclude": [ 42 | "build/**", 43 | "node_modules/**", 44 | "widgets/**" 45 | ] 46 | } -------------------------------------------------------------------------------- /TypeScriptReact/.create-adapter.json: -------------------------------------------------------------------------------- 1 | { 2 | "cli": true, 3 | "target": "directory", 4 | "adapterName": "template", 5 | "description": "Template for adapter development", 6 | "authorName": "Author", 7 | "authorGithub": "Author", 8 | "authorEmail": "author@mail.com", 9 | "gitRemoteProtocol": "HTTPS", 10 | "dependabot": "yes", 11 | "license": "MIT License", 12 | "releaseScript": "yes", 13 | "gitCommit": "no", 14 | "defaultBranch": "main", 15 | "startMode": "daemon", 16 | "features": [ 17 | "adapter" 18 | ], 19 | "connectionIndicator": "no", 20 | "type": "general", 21 | "adminFeatures": [ 22 | "custom", 23 | "tab" 24 | ], 25 | "adminUi": "react", 26 | "tabReact": "yes", 27 | "language": "TypeScript", 28 | "title": "Template (TypeScript with React)", 29 | "tools": [ 30 | "ESLint", 31 | "code coverage" 32 | ], 33 | "indentation": "Tab", 34 | "quotes": "double", 35 | "creatorVersion": "2.6.5" 36 | } -------------------------------------------------------------------------------- /TypeScriptReact/.eslintignore: -------------------------------------------------------------------------------- 1 | admin/build/ 2 | build/ 3 | **/.eslintrc.js 4 | admin/words.js -------------------------------------------------------------------------------- /TypeScriptReact/.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | root: true, // Don't look outside this project for inherited configs 3 | parser: "@typescript-eslint/parser", // Specifies the ESLint parser 4 | parserOptions: { 5 | ecmaVersion: "latest", // Allows for the parsing of modern ECMAScript features 6 | sourceType: "module", // Allows for the use of imports 7 | project: ["./tsconfig.json", "./admin/tsconfig.json"], 8 | ecmaFeatures: { 9 | jsx: true, 10 | }, 11 | }, 12 | extends: [ 13 | "plugin:@typescript-eslint/recommended", // Uses the recommended rules from the @typescript-eslint/eslint-plugin 14 | "plugin:react/recommended", // Supports React JSX 15 | ], 16 | plugins: ["react"], 17 | settings: { 18 | react: { 19 | version: "detect", 20 | }, 21 | }, 22 | rules: { 23 | "indent": "off", 24 | "@typescript-eslint/indent": [ 25 | "error", 26 | "tab", 27 | { 28 | "SwitchCase": 1 29 | } 30 | ], 31 | "quotes": [ 32 | "error", 33 | "double", 34 | { 35 | "avoidEscape": true, 36 | "allowTemplateLiterals": true 37 | } 38 | ], 39 | "@typescript-eslint/no-parameter-properties": "off", 40 | "@typescript-eslint/no-explicit-any": "off", 41 | "@typescript-eslint/no-use-before-define": [ 42 | "error", 43 | { 44 | functions: false, 45 | typedefs: false, 46 | classes: false, 47 | }, 48 | ], 49 | "@typescript-eslint/no-unused-vars": [ 50 | "error", 51 | { 52 | ignoreRestSiblings: true, 53 | argsIgnorePattern: "^_", 54 | }, 55 | ], 56 | "@typescript-eslint/explicit-function-return-type": [ 57 | "warn", 58 | { 59 | allowExpressions: true, 60 | allowTypedFunctionExpressions: true, 61 | }, 62 | ], 63 | "@typescript-eslint/no-object-literal-type-assertion": "off", 64 | "@typescript-eslint/interface-name-prefix": "off", 65 | "@typescript-eslint/no-non-null-assertion": "off", // This is necessary for Map.has()/get()! 66 | "no-var": "error", 67 | "prefer-const": "error", 68 | "no-trailing-spaces": "error", 69 | }, 70 | overrides: [ 71 | { 72 | files: ["*.test.ts", "*.tsx"], 73 | rules: { 74 | "@typescript-eslint/explicit-function-return-type": "off", 75 | }, 76 | }, 77 | ], 78 | }; -------------------------------------------------------------------------------- /TypeScriptReact/.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Something is not working as it should 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | --- 8 | 9 | **Describe the bug** 10 | A clear and concise description of what the bug is. 11 | 12 | **To Reproduce** 13 | Steps to reproduce the behavior: 14 | 1. Go to '...' 15 | 2. Click on '...' 16 | 3. Scroll down to '....' 17 | 4. See error 18 | 19 | **Expected behavior** 20 | A clear and concise description of what you expected to happen. 21 | 22 | **Screenshots & Logfiles** 23 | If applicable, add screenshots and logfiles to help explain your problem. 24 | 25 | **Versions:** 26 | - Adapter version: 27 | - JS-Controller version: 28 | - Node version: 29 | - Operating system: 30 | 31 | **Additional context** 32 | Add any other context about the problem here. 33 | -------------------------------------------------------------------------------- /TypeScriptReact/.github/auto-merge.yml: -------------------------------------------------------------------------------- 1 | # Configure here which dependency updates should be merged automatically. 2 | # The recommended configuration is the following: 3 | - match: 4 | # Only merge patches for production dependencies 5 | dependency_type: production 6 | update_type: "semver:patch" 7 | - match: 8 | # Except for security fixes, here we allow minor patches 9 | dependency_type: production 10 | update_type: "security:minor" 11 | - match: 12 | # and development dependencies can have a minor update, too 13 | dependency_type: development 14 | update_type: "semver:minor" 15 | 16 | # The syntax is based on the legacy dependabot v1 automerged_updates syntax, see: 17 | # https://dependabot.com/docs/config-file/#automerged_updates 18 | -------------------------------------------------------------------------------- /TypeScriptReact/.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: npm 4 | directory: "/" 5 | schedule: 6 | interval: monthly 7 | time: "04:00" 8 | timezone: Europe/Berlin 9 | open-pull-requests-limit: 5 10 | assignees: 11 | - Author 12 | versioning-strategy: increase 13 | 14 | - package-ecosystem: github-actions 15 | directory: "/" 16 | schedule: 17 | interval: monthly 18 | time: "04:00" 19 | timezone: Europe/Berlin 20 | open-pull-requests-limit: 5 21 | assignees: 22 | - Author 23 | -------------------------------------------------------------------------------- /TypeScriptReact/.github/workflows/dependabot-auto-merge.yml: -------------------------------------------------------------------------------- 1 | # Automatically merge Dependabot PRs when version comparison is within the range 2 | # that is configured in .github/auto-merge.yml 3 | 4 | name: Auto-Merge Dependabot PRs 5 | 6 | on: 7 | # WARNING: This needs to be run in the PR base, DO NOT build untrusted code in this action 8 | # details under https://github.blog/changelog/2021-02-19-github-actions-workflows-triggered-by-dependabot-prs-will-run-with-read-only-permissions/ 9 | pull_request_target: 10 | 11 | jobs: 12 | auto-merge: 13 | if: github.actor == 'dependabot[bot]' 14 | runs-on: ubuntu-latest 15 | steps: 16 | - name: Checkout code 17 | uses: actions/checkout@v2 18 | 19 | - name: Check if PR should be auto-merged 20 | uses: ahmadnassri/action-dependabot-auto-merge@v2 21 | with: 22 | # In order to use this, you need to go to https://github.com/settings/tokens and 23 | # create a Personal Access Token with the permission "public_repo". 24 | # Enter this token in your repository settings under "Secrets" and name it AUTO_MERGE_TOKEN 25 | github-token: ${{ secrets.AUTO_MERGE_TOKEN }} 26 | # By default, squash and merge, so Github chooses nice commit messages 27 | command: squash and merge 28 | -------------------------------------------------------------------------------- /TypeScriptReact/.gitignore: -------------------------------------------------------------------------------- 1 | # No dot-directories except github/vscode 2 | .*/ 3 | !.vscode/ 4 | !.github/ 5 | 6 | *.code-workspace 7 | node_modules 8 | nbproject 9 | 10 | # npm package files 11 | iobroker.*.tgz 12 | 13 | Thumbs.db 14 | 15 | # NYC coverage files 16 | coverage 17 | 18 | # i18n intermediate files 19 | admin/i18n/flat.txt 20 | admin/i18n/*/flat.txt -------------------------------------------------------------------------------- /TypeScriptReact/.releaseconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "plugins": [ 3 | "iobroker", 4 | "license", 5 | "manual-review" 6 | ], 7 | "exec": { 8 | "before_commit": "npm run build" 9 | } 10 | } -------------------------------------------------------------------------------- /TypeScriptReact/.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | "recommendations": [ 3 | "dbaeumer.vscode-eslint" 4 | ] 5 | } -------------------------------------------------------------------------------- /TypeScriptReact/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "typescript.tsdk": "node_modules/typescript/lib", 3 | "eslint.enable": true, 4 | "json.schemas": [ 5 | { 6 | "fileMatch": [ 7 | "io-package.json" 8 | ], 9 | "url": "https://raw.githubusercontent.com/ioBroker/ioBroker.js-controller/master/schemas/io-package.json" 10 | }, 11 | { 12 | "fileMatch": [ 13 | "admin/jsonConfig.json", 14 | "admin/jsonCustom.json", 15 | "admin/jsonTab.json" 16 | ], 17 | "url": "https://raw.githubusercontent.com/ioBroker/adapter-react-v5/main/schemas/jsonConfig.json" 18 | } 19 | ] 20 | } -------------------------------------------------------------------------------- /TypeScriptReact/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2024 Author 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 all 13 | 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 THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /TypeScriptReact/admin/custom_m.html: -------------------------------------------------------------------------------- 1 | 22 | 23 | -------------------------------------------------------------------------------- /TypeScriptReact/admin/index_m.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /TypeScriptReact/admin/src/app.tsx: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import { Theme, withStyles } from "@material-ui/core/styles"; 3 | 4 | import GenericApp from "@iobroker/adapter-react/GenericApp"; 5 | import Settings from "./components/settings"; 6 | import { GenericAppProps, GenericAppSettings } from "@iobroker/adapter-react/types"; 7 | import { StyleRules } from "@material-ui/core/styles"; 8 | 9 | const styles = (_theme: Theme): StyleRules => ({ 10 | root: {}, 11 | }); 12 | 13 | class App extends GenericApp { 14 | constructor(props: GenericAppProps) { 15 | const extendedProps: GenericAppSettings = { 16 | ...props, 17 | encryptedFields: [], 18 | translations: { 19 | "en": require("./i18n/en.json"), 20 | "de": require("./i18n/de.json"), 21 | "ru": require("./i18n/ru.json"), 22 | "pt": require("./i18n/pt.json"), 23 | "nl": require("./i18n/nl.json"), 24 | "fr": require("./i18n/fr.json"), 25 | "it": require("./i18n/it.json"), 26 | "es": require("./i18n/es.json"), 27 | "pl": require("./i18n/pl.json"), 28 | "uk": require("./i18n/uk.json"), 29 | "zh-cn": require("./i18n/zh-cn.json"), 30 | }, 31 | }; 32 | super(props, extendedProps); 33 | } 34 | 35 | onConnectionReady(): void { 36 | // executed when connection is ready 37 | } 38 | 39 | render() { 40 | if (!this.state.loaded) { 41 | return super.render(); 42 | } 43 | 44 | return ( 45 |
46 | this.updateNativeValue(attr, value)} /> 47 | {this.renderError()} 48 | {this.renderToast()} 49 | {this.renderSaveCloseButtons()} 50 |
51 | ); 52 | } 53 | } 54 | 55 | export default withStyles(styles)(App); -------------------------------------------------------------------------------- /TypeScriptReact/admin/src/i18n/de.json: -------------------------------------------------------------------------------- 1 | { 2 | "template adapter settings": "Adaptereinstellungen für template", 3 | "option1": "Option1", 4 | "option2": "Option2" 5 | } -------------------------------------------------------------------------------- /TypeScriptReact/admin/src/i18n/en.json: -------------------------------------------------------------------------------- 1 | { 2 | "template adapter settings": "Adapter settings for template", 3 | "option1": "option1", 4 | "option2": "option2" 5 | } -------------------------------------------------------------------------------- /TypeScriptReact/admin/src/i18n/es.json: -------------------------------------------------------------------------------- 1 | { 2 | "template adapter settings": "Ajustes del adaptador para template", 3 | "option1": "opción1", 4 | "option2": "opción2" 5 | } -------------------------------------------------------------------------------- /TypeScriptReact/admin/src/i18n/fr.json: -------------------------------------------------------------------------------- 1 | { 2 | "template adapter settings": "Paramètres d'adaptateur pour template", 3 | "option1": "option1", 4 | "option2": "option2" 5 | } -------------------------------------------------------------------------------- /TypeScriptReact/admin/src/i18n/i18n.d.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * This file loads the translations keys from `i18n/en.json` file and overrides 3 | * the declarations for the translate function `I18n.t` available in "@iobroker/adapter-react/i18n". 4 | * Using these definitions it is ensured that all used translations in the React 5 | * context are defined at least in the english translations file. 6 | * This will add no overhead in the generated code since it just reexports the 7 | * I18n class but with a more typed `t` function. 8 | */ 9 | 10 | /* 11 | * DO NOT add any imports or exports in this file or it will stop working! 12 | */ 13 | 14 | /** 15 | * Available words in `i18n/en.json`. 16 | */ 17 | declare type AdminWord = keyof typeof import("./en.json"); 18 | 19 | declare module "@iobroker/adapter-react/i18n" { 20 | /** 21 | * Translate the given string to the selected language. 22 | * @param word The (key) word to look up the string. Has to be defined at least in `i18n/en.json`. 23 | * @param args Optional arguments which will replace the first (second, third, ...) occurence of %s 24 | */ 25 | function t(word: AdminWord, ...args: string[]): string; 26 | } -------------------------------------------------------------------------------- /TypeScriptReact/admin/src/i18n/it.json: -------------------------------------------------------------------------------- 1 | { 2 | "template adapter settings": "Impostazioni dell'adattatore per template", 3 | "option1": "opzione1", 4 | "option2": "opzione2" 5 | } -------------------------------------------------------------------------------- /TypeScriptReact/admin/src/i18n/nl.json: -------------------------------------------------------------------------------- 1 | { 2 | "template adapter settings": "Adapterinstellingen voor template", 3 | "option1": "optie1", 4 | "option2": "optie2" 5 | } -------------------------------------------------------------------------------- /TypeScriptReact/admin/src/i18n/pl.json: -------------------------------------------------------------------------------- 1 | { 2 | "template adapter settings": "Ustawienia adaptera dla template", 3 | "option1": "opcja 1", 4 | "option2": "opcja 2" 5 | } -------------------------------------------------------------------------------- /TypeScriptReact/admin/src/i18n/pt.json: -------------------------------------------------------------------------------- 1 | { 2 | "template adapter settings": "Configurações do adaptador para template", 3 | "option1": "opção1", 4 | "option2": "opção2" 5 | } -------------------------------------------------------------------------------- /TypeScriptReact/admin/src/i18n/ru.json: -------------------------------------------------------------------------------- 1 | { 2 | "template adapter settings": "Настройки адаптера для template", 3 | "option1": "вариант 1", 4 | "option2": "вариант2" 5 | } -------------------------------------------------------------------------------- /TypeScriptReact/admin/src/i18n/uk.json: -------------------------------------------------------------------------------- 1 | { 2 | "template adapter settings": "Налаштування адаптера для template", 3 | "option1": "варіант1", 4 | "option2": "варіант2" 5 | } -------------------------------------------------------------------------------- /TypeScriptReact/admin/src/i18n/zh-cn.json: -------------------------------------------------------------------------------- 1 | { 2 | "template adapter settings": "template的适配器设置", 3 | "option1": "选项1", 4 | "option2": "选项2" 5 | } -------------------------------------------------------------------------------- /TypeScriptReact/admin/src/index.tsx: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import ReactDOM from "react-dom"; 3 | import { MuiThemeProvider } from "@material-ui/core/styles"; 4 | import theme from "@iobroker/adapter-react/Theme"; 5 | import Utils from "@iobroker/adapter-react/Components/Utils"; 6 | import App from "./app"; 7 | 8 | let themeName = Utils.getThemeName(); 9 | 10 | function build(): void { 11 | ReactDOM.render( 12 | 13 | { 16 | themeName = _theme; 17 | build(); 18 | }} 19 | /> 20 | , 21 | document.getElementById("root"), 22 | ); 23 | } 24 | 25 | build(); -------------------------------------------------------------------------------- /TypeScriptReact/admin/src/tab-app.tsx: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import { Theme, withStyles } from "@material-ui/core/styles"; 3 | 4 | import GenericApp from "@iobroker/adapter-react/GenericApp"; 5 | import { GenericAppProps, GenericAppSettings } from "@iobroker/adapter-react/types"; 6 | import { StyleRules } from "@material-ui/core/styles"; 7 | 8 | const styles = (_theme: Theme): StyleRules => ({ 9 | root: {}, 10 | }); 11 | 12 | class TabApp extends GenericApp { 13 | constructor(props: GenericAppProps) { 14 | const extendedProps: GenericAppSettings = { 15 | ...props, 16 | bottomButtons: false, 17 | encryptedFields: [], 18 | translations: { 19 | "en": require("./i18n/en.json"), 20 | "de": require("./i18n/de.json"), 21 | "ru": require("./i18n/ru.json"), 22 | "pt": require("./i18n/pt.json"), 23 | "nl": require("./i18n/nl.json"), 24 | "fr": require("./i18n/fr.json"), 25 | "it": require("./i18n/it.json"), 26 | "es": require("./i18n/es.json"), 27 | "pl": require("./i18n/pl.json"), 28 | "uk": require("./i18n/uk.json"), 29 | "zh-cn": require("./i18n/zh-cn.json"), 30 | }, 31 | }; 32 | super(props, extendedProps); 33 | } 34 | 35 | onConnectionReady(): void { 36 | // executed when connection is ready 37 | } 38 | 39 | render() { 40 | if (!this.state.loaded) { 41 | return super.render(); 42 | } 43 | 44 | return ( 45 |
46 | Add your components here. 47 | {this.renderError()} 48 | {this.renderToast()} 49 |
50 | ); 51 | } 52 | } 53 | 54 | export default withStyles(styles)(TabApp); -------------------------------------------------------------------------------- /TypeScriptReact/admin/src/tab.tsx: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import ReactDOM from "react-dom"; 3 | import { MuiThemeProvider } from "@material-ui/core/styles"; 4 | import theme from "@iobroker/adapter-react/Theme"; 5 | import Utils from "@iobroker/adapter-react/Components/Utils"; 6 | import TabApp from "./tab-app"; 7 | 8 | let themeName = Utils.getThemeName(); 9 | 10 | function build(): void { 11 | ReactDOM.render( 12 | 13 | { 16 | themeName = _theme; 17 | build(); 18 | }} 19 | /> 20 | , 21 | document.getElementById("root"), 22 | ); 23 | } 24 | 25 | build(); -------------------------------------------------------------------------------- /TypeScriptReact/admin/style.css: -------------------------------------------------------------------------------- 1 | /* You can delete those if you want. I just found them very helpful */ 2 | * { 3 | box-sizing: border-box 4 | } 5 | .m { 6 | /* Don't cut off dropdowns! */ 7 | overflow: initial; 8 | } 9 | .m.adapter-container, 10 | .m.adapter-container > div.App { 11 | /* Fix layout/scrolling issues with tabs */ 12 | height: 100%; 13 | width: 100%; 14 | position: relative; 15 | } 16 | .m .select-wrapper + label { 17 | /* The positioning for dropdown labels is messed up */ 18 | transform: none !important; 19 | } 20 | 21 | label > i[title] { 22 | /* Display the help cursor for the tooltip icons and fix their positioning */ 23 | cursor: help; 24 | margin-left: 0.25em; 25 | } 26 | 27 | .dropdown-content { 28 | /* Don't wrap text in dropdowns */ 29 | white-space: nowrap; 30 | } 31 | 32 | /* Add your styles here */ 33 | -------------------------------------------------------------------------------- /TypeScriptReact/admin/tab_m.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /TypeScriptReact/admin/template.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ioBroker/ioBroker.example/46e3823aafe0d918fea64ed9dd5d56a64e009b19/TypeScriptReact/admin/template.png -------------------------------------------------------------------------------- /TypeScriptReact/admin/tsconfig.json: -------------------------------------------------------------------------------- 1 | // Specialized tsconfig for the admin directory, 2 | // includes DOM typings and configures the admin build 3 | { 4 | "extends": "../tsconfig.json", 5 | "compilerOptions": { 6 | "noEmit": false, 7 | "outDir": "./build", 8 | "sourceMap": true, 9 | "sourceRoot": "./src", 10 | "noImplicitAny": false, 11 | "lib": [ 12 | "es2018", 13 | "DOM" 14 | ], 15 | "jsx": "react" 16 | }, 17 | "include": [ 18 | "./**/*.ts", 19 | "./**/*.tsx", 20 | "../src/lib/adapter-config.d.ts" 21 | ], 22 | "exclude": [ 23 | "./**/*.test.ts", 24 | "./**/*.test.tsx" 25 | ] 26 | } 27 | -------------------------------------------------------------------------------- /TypeScriptReact/src/lib/adapter-config.d.ts: -------------------------------------------------------------------------------- 1 | // This file extends the AdapterConfig type from "@types/iobroker" 2 | 3 | // Augment the globally declared type ioBroker.AdapterConfig 4 | declare global { 5 | namespace ioBroker { 6 | interface AdapterConfig { 7 | option1: boolean; 8 | option2: string; 9 | } 10 | } 11 | } 12 | 13 | // this is required so the above AdapterConfig is found by TypeScript / type checking 14 | export {}; -------------------------------------------------------------------------------- /TypeScriptReact/src/main.test.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This is a dummy TypeScript test file using chai and mocha 3 | * 4 | * It's automatically excluded from npm and its build output is excluded from both git and npm. 5 | * It is advised to test all your modules with accompanying *.test.ts-files 6 | */ 7 | 8 | import { expect } from "chai"; 9 | // import { functionToTest } from "./moduleToTest"; 10 | 11 | describe("module to test => function to test", () => { 12 | // initializing logic 13 | const expected = 5; 14 | 15 | it(`should return ${expected}`, () => { 16 | const result = 5; 17 | // assign result a value from functionToTest 18 | expect(result).to.equal(expected); 19 | // or using the should() syntax 20 | result.should.equal(expected); 21 | }); 22 | // ... more tests => it 23 | 24 | }); 25 | 26 | // ... more test suites => describe 27 | -------------------------------------------------------------------------------- /TypeScriptReact/test/.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "root": true, 3 | "env": { 4 | "es6": true, 5 | "node": true, 6 | "mocha": true 7 | }, 8 | "extends": [ 9 | "eslint:recommended" 10 | ], 11 | "rules": { 12 | "indent": [ 13 | "error", 14 | "tab", 15 | { 16 | "SwitchCase": 1 17 | } 18 | ], 19 | "no-console": "off", 20 | "no-unused-vars": [ 21 | "error", 22 | { 23 | "ignoreRestSiblings": true, 24 | "argsIgnorePattern": "^_" 25 | } 26 | ], 27 | "no-var": "error", 28 | "no-trailing-spaces": "error", 29 | "prefer-const": "error", 30 | "quotes": [ 31 | "error", 32 | "double", 33 | { 34 | "avoidEscape": true, 35 | "allowTemplateLiterals": true 36 | } 37 | ], 38 | "semi": [ 39 | "error", 40 | "always" 41 | ] 42 | } 43 | } -------------------------------------------------------------------------------- /TypeScriptReact/test/integration.js: -------------------------------------------------------------------------------- 1 | const path = require("path"); 2 | const { tests } = require("@iobroker/testing"); 3 | 4 | // Run integration tests - See https://github.com/ioBroker/testing for a detailed explanation and further options 5 | tests.integration(path.join(__dirname, "..")); -------------------------------------------------------------------------------- /TypeScriptReact/test/mocha.setup.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | // Makes ts-node ignore warnings, so mocha --watch does work 4 | process.env.TS_NODE_IGNORE_WARNINGS = "TRUE"; 5 | // Sets the correct tsconfig for testing 6 | process.env.TS_NODE_PROJECT = "tsconfig.json"; 7 | // Make ts-node respect the "include" key in tsconfig.json 8 | process.env.TS_NODE_FILES = "TRUE"; 9 | 10 | // Don't silently swallow unhandled rejections 11 | process.on("unhandledRejection", (e) => { 12 | throw e; 13 | }); 14 | 15 | // enable the should interface with sinon 16 | // and load chai-as-promised and sinon-chai by default 17 | const sinonChai = require("sinon-chai"); 18 | const chaiAsPromised = require("chai-as-promised"); 19 | const { should, use } = require("chai"); 20 | 21 | should(); 22 | use(sinonChai); 23 | use(chaiAsPromised); -------------------------------------------------------------------------------- /TypeScriptReact/test/mocharc.custom.json: -------------------------------------------------------------------------------- 1 | { 2 | "require": [ 3 | "test/mocha.setup.js", 4 | "ts-node/register", 5 | "source-map-support/register" 6 | ], 7 | "watch-files": [ 8 | "src/**/*.test.ts" 9 | ] 10 | } -------------------------------------------------------------------------------- /TypeScriptReact/test/package.js: -------------------------------------------------------------------------------- 1 | const path = require("path"); 2 | const { tests } = require("@iobroker/testing"); 3 | 4 | // Validate the package files 5 | tests.packageFiles(path.join(__dirname, "..")); 6 | -------------------------------------------------------------------------------- /TypeScriptReact/test/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "noImplicitAny": false 5 | }, 6 | "include": [ 7 | "./**/*.js" 8 | ] 9 | } 10 | -------------------------------------------------------------------------------- /TypeScriptReact/tsconfig.build.json: -------------------------------------------------------------------------------- 1 | // Specialized tsconfig to only compile .ts-files in the src dir 2 | { 3 | "extends": "./tsconfig.json", 4 | "compilerOptions": { 5 | "allowJs": false, 6 | "checkJs": false, 7 | "noEmit": false, 8 | "declaration": false 9 | }, 10 | "include": [ 11 | "src/**/*.ts" 12 | ], 13 | "exclude": [ 14 | "src/**/*.test.ts" 15 | ] 16 | } 17 | -------------------------------------------------------------------------------- /TypeScriptReact/tsconfig.json: -------------------------------------------------------------------------------- 1 | // Root tsconfig to set the settings and power editor support for all TS files 2 | { 3 | // To update the compilation target, install a different version of @tsconfig/node... and reference it here 4 | // https://github.com/tsconfig/bases#node-20-tsconfigjson 5 | "extends": "@tsconfig/node20/tsconfig.json", 6 | "compilerOptions": { 7 | // do not compile anything, this file is just to configure type checking 8 | // the compilation is configured in tsconfig.build.json 9 | "noEmit": true, 10 | 11 | // check JS files, but do not compile them => tsconfig.build.json 12 | "allowJs": true, 13 | "checkJs": true, 14 | 15 | "noEmitOnError": true, 16 | "outDir": "./build/", 17 | "removeComments": false, 18 | 19 | // This is necessary for the automatic typing of the adapter config 20 | "resolveJsonModule": true, 21 | 22 | // If you want to disable the stricter type checks (not recommended), uncomment the following line 23 | // "strict": false, 24 | // And enable some of those features for more fine-grained control 25 | // "strictNullChecks": true, 26 | // "strictPropertyInitialization": true, 27 | // "strictBindCallApply": true, 28 | // "noImplicitAny": true, 29 | // "noUnusedLocals": true, 30 | // "noUnusedParameters": true, 31 | // Uncomment this if you want the old behavior of catch variables being `any` 32 | // "useUnknownInCatchVariables": false, 33 | 34 | "sourceMap": true, 35 | "inlineSourceMap": false 36 | }, 37 | "include": [ 38 | "src/**/*.ts", 39 | "test/**/*.ts" 40 | ], 41 | "exclude": [ 42 | "build/**", 43 | "node_modules/**", 44 | "widgets/**" 45 | ] 46 | } -------------------------------------------------------------------------------- /TypeScriptVIS/.create-adapter.json: -------------------------------------------------------------------------------- 1 | { 2 | "cli": true, 3 | "target": "directory", 4 | "adapterName": "template", 5 | "description": "Template for adapter development", 6 | "authorName": "Author", 7 | "authorGithub": "Author", 8 | "authorEmail": "author@mail.com", 9 | "gitRemoteProtocol": "HTTPS", 10 | "dependabot": "yes", 11 | "license": "MIT License", 12 | "releaseScript": "yes", 13 | "gitCommit": "no", 14 | "defaultBranch": "main", 15 | "startMode": "daemon", 16 | "features": [ 17 | "adapter", 18 | "vis" 19 | ], 20 | "connectionIndicator": "no", 21 | "type": "general", 22 | "adminFeatures": [ 23 | "custom", 24 | "tab" 25 | ], 26 | "adminUi": "json", 27 | "tabReact": "no", 28 | "language": "TypeScript", 29 | "title": "Template (TypeScript with VIS)", 30 | "tools": [ 31 | "ESLint", 32 | "code coverage" 33 | ], 34 | "indentation": "Tab", 35 | "quotes": "double", 36 | "creatorVersion": "2.6.5" 37 | } -------------------------------------------------------------------------------- /TypeScriptVIS/.eslintignore: -------------------------------------------------------------------------------- 1 | build/ 2 | **/.eslintrc.js 3 | admin/words.js -------------------------------------------------------------------------------- /TypeScriptVIS/.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | root: true, // Don't look outside this project for inherited configs 3 | parser: "@typescript-eslint/parser", // Specifies the ESLint parser 4 | parserOptions: { 5 | ecmaVersion: "latest", // Allows for the parsing of modern ECMAScript features 6 | sourceType: "module", // Allows for the use of imports 7 | project: "./tsconfig.json", 8 | }, 9 | extends: [ 10 | "plugin:@typescript-eslint/recommended", // Uses the recommended rules from the @typescript-eslint/eslint-plugin 11 | ], 12 | plugins: [], 13 | rules: { 14 | "indent": "off", 15 | "@typescript-eslint/indent": [ 16 | "error", 17 | "tab", 18 | { 19 | "SwitchCase": 1 20 | } 21 | ], 22 | "quotes": [ 23 | "error", 24 | "double", 25 | { 26 | "avoidEscape": true, 27 | "allowTemplateLiterals": true 28 | } 29 | ], 30 | "@typescript-eslint/no-parameter-properties": "off", 31 | "@typescript-eslint/no-explicit-any": "off", 32 | "@typescript-eslint/no-use-before-define": [ 33 | "error", 34 | { 35 | functions: false, 36 | typedefs: false, 37 | classes: false, 38 | }, 39 | ], 40 | "@typescript-eslint/no-unused-vars": [ 41 | "error", 42 | { 43 | ignoreRestSiblings: true, 44 | argsIgnorePattern: "^_", 45 | }, 46 | ], 47 | "@typescript-eslint/explicit-function-return-type": [ 48 | "warn", 49 | { 50 | allowExpressions: true, 51 | allowTypedFunctionExpressions: true, 52 | }, 53 | ], 54 | "@typescript-eslint/no-object-literal-type-assertion": "off", 55 | "@typescript-eslint/interface-name-prefix": "off", 56 | "@typescript-eslint/no-non-null-assertion": "off", // This is necessary for Map.has()/get()! 57 | "no-var": "error", 58 | "prefer-const": "error", 59 | "no-trailing-spaces": "error", 60 | }, 61 | overrides: [ 62 | { 63 | files: ["*.test.ts"], 64 | rules: { 65 | "@typescript-eslint/explicit-function-return-type": "off", 66 | }, 67 | }, 68 | ], 69 | }; -------------------------------------------------------------------------------- /TypeScriptVIS/.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Something is not working as it should 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | --- 8 | 9 | **Describe the bug** 10 | A clear and concise description of what the bug is. 11 | 12 | **To Reproduce** 13 | Steps to reproduce the behavior: 14 | 1. Go to '...' 15 | 2. Click on '...' 16 | 3. Scroll down to '....' 17 | 4. See error 18 | 19 | **Expected behavior** 20 | A clear and concise description of what you expected to happen. 21 | 22 | **Screenshots & Logfiles** 23 | If applicable, add screenshots and logfiles to help explain your problem. 24 | 25 | **Versions:** 26 | - Adapter version: 27 | - JS-Controller version: 28 | - Node version: 29 | - Operating system: 30 | 31 | **Additional context** 32 | Add any other context about the problem here. 33 | -------------------------------------------------------------------------------- /TypeScriptVIS/.github/auto-merge.yml: -------------------------------------------------------------------------------- 1 | # Configure here which dependency updates should be merged automatically. 2 | # The recommended configuration is the following: 3 | - match: 4 | # Only merge patches for production dependencies 5 | dependency_type: production 6 | update_type: "semver:patch" 7 | - match: 8 | # Except for security fixes, here we allow minor patches 9 | dependency_type: production 10 | update_type: "security:minor" 11 | - match: 12 | # and development dependencies can have a minor update, too 13 | dependency_type: development 14 | update_type: "semver:minor" 15 | 16 | # The syntax is based on the legacy dependabot v1 automerged_updates syntax, see: 17 | # https://dependabot.com/docs/config-file/#automerged_updates 18 | -------------------------------------------------------------------------------- /TypeScriptVIS/.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: npm 4 | directory: "/" 5 | schedule: 6 | interval: monthly 7 | time: "04:00" 8 | timezone: Europe/Berlin 9 | open-pull-requests-limit: 5 10 | assignees: 11 | - Author 12 | versioning-strategy: increase 13 | 14 | - package-ecosystem: github-actions 15 | directory: "/" 16 | schedule: 17 | interval: monthly 18 | time: "04:00" 19 | timezone: Europe/Berlin 20 | open-pull-requests-limit: 5 21 | assignees: 22 | - Author 23 | -------------------------------------------------------------------------------- /TypeScriptVIS/.github/workflows/dependabot-auto-merge.yml: -------------------------------------------------------------------------------- 1 | # Automatically merge Dependabot PRs when version comparison is within the range 2 | # that is configured in .github/auto-merge.yml 3 | 4 | name: Auto-Merge Dependabot PRs 5 | 6 | on: 7 | # WARNING: This needs to be run in the PR base, DO NOT build untrusted code in this action 8 | # details under https://github.blog/changelog/2021-02-19-github-actions-workflows-triggered-by-dependabot-prs-will-run-with-read-only-permissions/ 9 | pull_request_target: 10 | 11 | jobs: 12 | auto-merge: 13 | if: github.actor == 'dependabot[bot]' 14 | runs-on: ubuntu-latest 15 | steps: 16 | - name: Checkout code 17 | uses: actions/checkout@v2 18 | 19 | - name: Check if PR should be auto-merged 20 | uses: ahmadnassri/action-dependabot-auto-merge@v2 21 | with: 22 | # In order to use this, you need to go to https://github.com/settings/tokens and 23 | # create a Personal Access Token with the permission "public_repo". 24 | # Enter this token in your repository settings under "Secrets" and name it AUTO_MERGE_TOKEN 25 | github-token: ${{ secrets.AUTO_MERGE_TOKEN }} 26 | # By default, squash and merge, so Github chooses nice commit messages 27 | command: squash and merge 28 | -------------------------------------------------------------------------------- /TypeScriptVIS/.gitignore: -------------------------------------------------------------------------------- 1 | # No dot-directories except github/vscode 2 | .*/ 3 | !.vscode/ 4 | !.github/ 5 | 6 | *.code-workspace 7 | node_modules 8 | nbproject 9 | 10 | # npm package files 11 | iobroker.*.tgz 12 | 13 | Thumbs.db 14 | 15 | # NYC coverage files 16 | coverage 17 | 18 | # i18n intermediate files 19 | admin/i18n/flat.txt 20 | admin/i18n/*/flat.txt -------------------------------------------------------------------------------- /TypeScriptVIS/.releaseconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "plugins": [ 3 | "iobroker", 4 | "license", 5 | "manual-review" 6 | ], 7 | "exec": { 8 | "before_commit": "npm run build" 9 | } 10 | } -------------------------------------------------------------------------------- /TypeScriptVIS/.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | "recommendations": [ 3 | "dbaeumer.vscode-eslint" 4 | ] 5 | } -------------------------------------------------------------------------------- /TypeScriptVIS/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "typescript.tsdk": "node_modules/typescript/lib", 3 | "eslint.enable": true, 4 | "json.schemas": [ 5 | { 6 | "fileMatch": [ 7 | "io-package.json" 8 | ], 9 | "url": "https://raw.githubusercontent.com/ioBroker/ioBroker.js-controller/master/schemas/io-package.json" 10 | }, 11 | { 12 | "fileMatch": [ 13 | "admin/jsonConfig.json", 14 | "admin/jsonCustom.json", 15 | "admin/jsonTab.json" 16 | ], 17 | "url": "https://raw.githubusercontent.com/ioBroker/adapter-react-v5/main/schemas/jsonConfig.json" 18 | } 19 | ] 20 | } -------------------------------------------------------------------------------- /TypeScriptVIS/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2024 Author 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 all 13 | 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 THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /TypeScriptVIS/admin/admin.d.ts: -------------------------------------------------------------------------------- 1 | declare let systemDictionary: Record>; 2 | 3 | declare let load: (settings: Record, onChange: (hasChanges: boolean) => void) => void; 4 | declare let save: (callback: (settings: Record) => void) => void; 5 | 6 | // make load and save exist on the window object 7 | interface Window { 8 | load: typeof load; 9 | save: typeof save; 10 | } 11 | 12 | declare const instance: number; 13 | declare const adapter: string; 14 | /** Translates text */ 15 | declare function _(text: string, arg1?: string, arg2?: string, arg3?: string): string; 16 | declare const socket: ioBrokerSocket; 17 | declare function sendTo( 18 | instance: any | null, 19 | command: string, 20 | message: any, 21 | callback: (result: SendToResult) => void | Promise, 22 | ): void; 23 | 24 | interface SendToResult { 25 | error?: string | Error; 26 | result?: any; 27 | } 28 | 29 | // tslint:disable-next-line:class-name 30 | interface ioBrokerSocket { 31 | emit( 32 | command: "subscribeObjects", 33 | pattern: string, 34 | callback?: (err?: string) => void | Promise, 35 | ): void; 36 | emit( 37 | command: "subscribeStates", 38 | pattern: string, 39 | callback?: (err?: string) => void | Promise, 40 | ): void; 41 | emit( 42 | command: "unsubscribeObjects", 43 | pattern: string, 44 | callback?: (err?: string) => void | Promise, 45 | ): void; 46 | emit( 47 | command: "unsubscribeStates", 48 | pattern: string, 49 | callback?: (err?: string) => void | Promise, 50 | ): void; 51 | 52 | emit( 53 | event: "getObjectView", 54 | view: "system", 55 | type: "device", 56 | options: ioBroker.GetObjectViewParams, 57 | callback: ( 58 | err: string | undefined, 59 | result?: any, 60 | ) => void | Promise, 61 | ): void; 62 | emit( 63 | event: "getStates", 64 | callback: ( 65 | err: string | undefined, 66 | result?: Record, 67 | ) => void, 68 | ): void; 69 | emit( 70 | event: "getState", 71 | id: string, 72 | callback: (err: string | undefined, result?: ioBroker.State) => void, 73 | ): void; 74 | emit( 75 | event: "setState", 76 | id: string, 77 | state: unknown, 78 | callback: (err: string | undefined, result?: any) => void, 79 | ): void; 80 | 81 | on(event: "objectChange", handler: ioBroker.ObjectChangeHandler): void; 82 | on(event: "stateChange", handler: ioBroker.StateChangeHandler): void; 83 | removeEventHandler( 84 | event: "objectChange", 85 | handler: ioBroker.ObjectChangeHandler, 86 | ): void; 87 | removeEventHandler( 88 | event: "stateChange", 89 | handler: ioBroker.StateChangeHandler, 90 | ): void; 91 | 92 | // TODO: other events 93 | } 94 | -------------------------------------------------------------------------------- /TypeScriptVIS/admin/custom_m.html: -------------------------------------------------------------------------------- 1 | 22 | 23 | -------------------------------------------------------------------------------- /TypeScriptVIS/admin/i18n/de/translations.json: -------------------------------------------------------------------------------- 1 | { 2 | "template adapter settings": "Adaptereinstellungen für template", 3 | "option1": "Option1", 4 | "option2": "Option2" 5 | } -------------------------------------------------------------------------------- /TypeScriptVIS/admin/i18n/en/translations.json: -------------------------------------------------------------------------------- 1 | { 2 | "template adapter settings": "Adapter settings for template", 3 | "option1": "option1", 4 | "option2": "option2" 5 | } -------------------------------------------------------------------------------- /TypeScriptVIS/admin/i18n/es/translations.json: -------------------------------------------------------------------------------- 1 | { 2 | "template adapter settings": "Ajustes del adaptador para template", 3 | "option1": "opción1", 4 | "option2": "opción2" 5 | } -------------------------------------------------------------------------------- /TypeScriptVIS/admin/i18n/fr/translations.json: -------------------------------------------------------------------------------- 1 | { 2 | "template adapter settings": "Paramètres d'adaptateur pour template", 3 | "option1": "option1", 4 | "option2": "option2" 5 | } -------------------------------------------------------------------------------- /TypeScriptVIS/admin/i18n/it/translations.json: -------------------------------------------------------------------------------- 1 | { 2 | "template adapter settings": "Impostazioni dell'adattatore per template", 3 | "option1": "opzione1", 4 | "option2": "opzione2" 5 | } -------------------------------------------------------------------------------- /TypeScriptVIS/admin/i18n/nl/translations.json: -------------------------------------------------------------------------------- 1 | { 2 | "template adapter settings": "Adapterinstellingen voor template", 3 | "option1": "optie1", 4 | "option2": "optie2" 5 | } -------------------------------------------------------------------------------- /TypeScriptVIS/admin/i18n/pl/translations.json: -------------------------------------------------------------------------------- 1 | { 2 | "template adapter settings": "Ustawienia adaptera dla template", 3 | "option1": "opcja 1", 4 | "option2": "opcja 2" 5 | } -------------------------------------------------------------------------------- /TypeScriptVIS/admin/i18n/pt/translations.json: -------------------------------------------------------------------------------- 1 | { 2 | "template adapter settings": "Configurações do adaptador para template", 3 | "option1": "opção1", 4 | "option2": "opção2" 5 | } -------------------------------------------------------------------------------- /TypeScriptVIS/admin/i18n/ru/translations.json: -------------------------------------------------------------------------------- 1 | { 2 | "template adapter settings": "Настройки адаптера для template", 3 | "option1": "вариант 1", 4 | "option2": "вариант2" 5 | } -------------------------------------------------------------------------------- /TypeScriptVIS/admin/i18n/uk/translations.json: -------------------------------------------------------------------------------- 1 | { 2 | "template adapter settings": "Налаштування адаптера для template", 3 | "option1": "варіант1", 4 | "option2": "варіант2" 5 | } -------------------------------------------------------------------------------- /TypeScriptVIS/admin/i18n/zh-cn/translations.json: -------------------------------------------------------------------------------- 1 | { 2 | "template adapter settings": "template的适配器设置", 3 | "option1": "选项1", 4 | "option2": "选项2" 5 | } -------------------------------------------------------------------------------- /TypeScriptVIS/admin/jsonConfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "i18n": true, 3 | "type": "panel", 4 | "items": { 5 | "option1": { 6 | "type": "checkbox", 7 | "label": "option1", 8 | "newLine": true 9 | }, 10 | "option2": { 11 | "type": "text", 12 | "label": "option2", 13 | "newLine": true 14 | } 15 | } 16 | } -------------------------------------------------------------------------------- /TypeScriptVIS/admin/tab_m.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 21 | 22 | 23 | 24 | 25 |
26 |
27 | 29 |
30 |
31 | 32 |
33 |
34 |
35 |
36 | 37 | 38 |
39 |
40 |
41 |
42 | 43 | 44 | Descriptions of the input field 45 |
46 |
47 | 48 | 49 | 50 | test2 51 |
52 |
53 | 54 | 55 | 56 | Verification input 57 |
58 |
59 |
60 |
61 | 65 | 66 | 67 |
68 |
69 | mode_edit 70 | 71 | 72 |
73 |
74 |
75 |
76 | 77 | 78 | 79 | -------------------------------------------------------------------------------- /TypeScriptVIS/admin/template.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ioBroker/ioBroker.example/46e3823aafe0d918fea64ed9dd5d56a64e009b19/TypeScriptVIS/admin/template.png -------------------------------------------------------------------------------- /TypeScriptVIS/admin/words.js: -------------------------------------------------------------------------------- 1 | /* eslint no-unused-vars: off */ 2 | /* eslint no-global-assign: off */ 3 | /* global systemDictionary */ 4 | "use strict"; 5 | 6 | systemDictionary = { 7 | "template adapter settings": { 8 | "en": "Adapter settings for template", 9 | "de": "Adaptereinstellungen für template", 10 | "ru": "Настройки адаптера для template", 11 | "pt": "Configurações do adaptador para template", 12 | "nl": "Adapterinstellingen voor template", 13 | "fr": "Paramètres d'adaptateur pour template", 14 | "it": "Impostazioni dell'adattatore per template", 15 | "es": "Ajustes del adaptador para template", 16 | "pl": "Ustawienia adaptera dla template", 17 | "uk": "Налаштування адаптера для template", 18 | "zh-cn": "template的适配器设置" 19 | }, 20 | "option1": { 21 | "en": "option1", 22 | "de": "Option1", 23 | "ru": "вариант 1", 24 | "pt": "opção1", 25 | "nl": "optie1", 26 | "fr": "option1", 27 | "it": "opzione1", 28 | "es": "opción1", 29 | "pl": "opcja 1", 30 | "uk": "варіант1", 31 | "zh-cn": "选项1" 32 | }, 33 | "option2": { 34 | "en": "option2", 35 | "de": "Option2", 36 | "ru": "вариант2", 37 | "pt": "opção2", 38 | "nl": "optie2", 39 | "fr": "option2", 40 | "it": "opzione2", 41 | "es": "opción2", 42 | "pl": "opcja 2", 43 | "uk": "варіант2", 44 | "zh-cn": "选项2" 45 | }, 46 | "myColor": { 47 | "en": "myColor", 48 | "de": "meineColor", 49 | "ru": "Мой цвет", 50 | "pt": "minhaCor", 51 | "nl": "mijnKleur", 52 | "fr": "maCouleur", 53 | "it": "mioColore", 54 | "es": "miColor", 55 | "pl": "mójKolor", 56 | "uk": "мійКолір", 57 | "zh-cn": "我的颜色" 58 | }, 59 | "myColor_tooltip": { 60 | "en": "Description of\nmyColor", 61 | "de": "Beschreibung von\nmyColor", 62 | "ru": "Описание\nmyColor", 63 | "pt": "Descrição de\nmyColor", 64 | "nl": "Beschrijving van\nmyColor", 65 | "fr": "Description de\nmyColor", 66 | "it": "Descrizione di\nmyColor", 67 | "es": "Descripción de\nmyColor", 68 | "pl": "Opis\nmyColor", 69 | "uk": "Опис\nmyColor", 70 | "zh-cn": "\nmyColor的描述" 71 | }, 72 | "htmlText": { 73 | "en": "htmlText", 74 | "de": "htmlText", 75 | "ru": "htmlText", 76 | "pt": "htmlText", 77 | "nl": "htmlText", 78 | "fr": "htmlText", 79 | "it": "htmlText", 80 | "es": "htmlText", 81 | "pl": "htmlText", 82 | "uk": "htmlText", 83 | "zh-cn": "htmlText" 84 | }, 85 | "group_extraMyset": { 86 | "en": "extraMyset", 87 | "de": "extraMyset", 88 | "ru": "extraMyset", 89 | "pt": "extraMyset", 90 | "nl": "extraMyset", 91 | "fr": "extraMyset", 92 | "it": "extraMyset", 93 | "es": "extraMyset", 94 | "pl": "extraMyset", 95 | "uk": "extraMyset", 96 | "zh-cn": "extraMyset" 97 | }, 98 | "extraAttr": { 99 | "en": "extraAttr", 100 | "de": "extraAttr", 101 | "ru": "extraAttr", 102 | "pt": "extraAttr", 103 | "nl": "extraAttr", 104 | "fr": "extraAttr", 105 | "it": "extraAttr", 106 | "es": "extraAttr", 107 | "pl": "extraAttr", 108 | "uk": "extraAttr", 109 | "zh-cn": "extraAttr" 110 | }, 111 | "Instance": { 112 | "en": "Instance", 113 | "de": "Instanz", 114 | "ru": "Инстанция", 115 | "pt": "Instância", 116 | "nl": "Instantie", 117 | "fr": "Instance", 118 | "it": "Esempio", 119 | "es": "Instancia", 120 | "pl": "Instancja", 121 | "uk": "Інстанція", 122 | "zh-cn": "例" 123 | } 124 | }; -------------------------------------------------------------------------------- /TypeScriptVIS/src/lib/adapter-config.d.ts: -------------------------------------------------------------------------------- 1 | // This file extends the AdapterConfig type from "@types/iobroker" 2 | 3 | // Augment the globally declared type ioBroker.AdapterConfig 4 | declare global { 5 | namespace ioBroker { 6 | interface AdapterConfig { 7 | option1: boolean; 8 | option2: string; 9 | } 10 | } 11 | } 12 | 13 | // this is required so the above AdapterConfig is found by TypeScript / type checking 14 | export {}; -------------------------------------------------------------------------------- /TypeScriptVIS/src/main.test.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This is a dummy TypeScript test file using chai and mocha 3 | * 4 | * It's automatically excluded from npm and its build output is excluded from both git and npm. 5 | * It is advised to test all your modules with accompanying *.test.ts-files 6 | */ 7 | 8 | import { expect } from "chai"; 9 | // import { functionToTest } from "./moduleToTest"; 10 | 11 | describe("module to test => function to test", () => { 12 | // initializing logic 13 | const expected = 5; 14 | 15 | it(`should return ${expected}`, () => { 16 | const result = 5; 17 | // assign result a value from functionToTest 18 | expect(result).to.equal(expected); 19 | // or using the should() syntax 20 | result.should.equal(expected); 21 | }); 22 | // ... more tests => it 23 | 24 | }); 25 | 26 | // ... more test suites => describe 27 | -------------------------------------------------------------------------------- /TypeScriptVIS/test/.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "root": true, 3 | "env": { 4 | "es6": true, 5 | "node": true, 6 | "mocha": true 7 | }, 8 | "extends": [ 9 | "eslint:recommended" 10 | ], 11 | "rules": { 12 | "indent": [ 13 | "error", 14 | "tab", 15 | { 16 | "SwitchCase": 1 17 | } 18 | ], 19 | "no-console": "off", 20 | "no-unused-vars": [ 21 | "error", 22 | { 23 | "ignoreRestSiblings": true, 24 | "argsIgnorePattern": "^_" 25 | } 26 | ], 27 | "no-var": "error", 28 | "no-trailing-spaces": "error", 29 | "prefer-const": "error", 30 | "quotes": [ 31 | "error", 32 | "double", 33 | { 34 | "avoidEscape": true, 35 | "allowTemplateLiterals": true 36 | } 37 | ], 38 | "semi": [ 39 | "error", 40 | "always" 41 | ] 42 | } 43 | } -------------------------------------------------------------------------------- /TypeScriptVIS/test/integration.js: -------------------------------------------------------------------------------- 1 | const path = require("path"); 2 | const { tests } = require("@iobroker/testing"); 3 | 4 | // Run integration tests - See https://github.com/ioBroker/testing for a detailed explanation and further options 5 | tests.integration(path.join(__dirname, "..")); -------------------------------------------------------------------------------- /TypeScriptVIS/test/mocha.setup.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | // Makes ts-node ignore warnings, so mocha --watch does work 4 | process.env.TS_NODE_IGNORE_WARNINGS = "TRUE"; 5 | // Sets the correct tsconfig for testing 6 | process.env.TS_NODE_PROJECT = "tsconfig.json"; 7 | // Make ts-node respect the "include" key in tsconfig.json 8 | process.env.TS_NODE_FILES = "TRUE"; 9 | 10 | // Don't silently swallow unhandled rejections 11 | process.on("unhandledRejection", (e) => { 12 | throw e; 13 | }); 14 | 15 | // enable the should interface with sinon 16 | // and load chai-as-promised and sinon-chai by default 17 | const sinonChai = require("sinon-chai"); 18 | const chaiAsPromised = require("chai-as-promised"); 19 | const { should, use } = require("chai"); 20 | 21 | should(); 22 | use(sinonChai); 23 | use(chaiAsPromised); -------------------------------------------------------------------------------- /TypeScriptVIS/test/mocharc.custom.json: -------------------------------------------------------------------------------- 1 | { 2 | "require": [ 3 | "test/mocha.setup.js", 4 | "ts-node/register", 5 | "source-map-support/register" 6 | ], 7 | "watch-files": [ 8 | "src/**/*.test.ts" 9 | ] 10 | } -------------------------------------------------------------------------------- /TypeScriptVIS/test/package.js: -------------------------------------------------------------------------------- 1 | const path = require("path"); 2 | const { tests } = require("@iobroker/testing"); 3 | 4 | // Validate the package files 5 | tests.packageFiles(path.join(__dirname, "..")); 6 | -------------------------------------------------------------------------------- /TypeScriptVIS/test/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "noImplicitAny": false 5 | }, 6 | "include": [ 7 | "./**/*.js" 8 | ] 9 | } 10 | -------------------------------------------------------------------------------- /TypeScriptVIS/tsconfig.build.json: -------------------------------------------------------------------------------- 1 | // Specialized tsconfig to only compile .ts-files in the src dir 2 | { 3 | "extends": "./tsconfig.json", 4 | "compilerOptions": { 5 | "allowJs": false, 6 | "checkJs": false, 7 | "noEmit": false, 8 | "declaration": false 9 | }, 10 | "include": [ 11 | "src/**/*.ts" 12 | ], 13 | "exclude": [ 14 | "src/**/*.test.ts" 15 | ] 16 | } 17 | -------------------------------------------------------------------------------- /TypeScriptVIS/tsconfig.json: -------------------------------------------------------------------------------- 1 | // Root tsconfig to set the settings and power editor support for all TS files 2 | { 3 | // To update the compilation target, install a different version of @tsconfig/node... and reference it here 4 | // https://github.com/tsconfig/bases#node-20-tsconfigjson 5 | "extends": "@tsconfig/node20/tsconfig.json", 6 | "compilerOptions": { 7 | // do not compile anything, this file is just to configure type checking 8 | // the compilation is configured in tsconfig.build.json 9 | "noEmit": true, 10 | 11 | // check JS files, but do not compile them => tsconfig.build.json 12 | "allowJs": true, 13 | "checkJs": true, 14 | 15 | "noEmitOnError": true, 16 | "outDir": "./build/", 17 | "removeComments": false, 18 | 19 | // This is necessary for the automatic typing of the adapter config 20 | "resolveJsonModule": true, 21 | 22 | // If you want to disable the stricter type checks (not recommended), uncomment the following line 23 | // "strict": false, 24 | // And enable some of those features for more fine-grained control 25 | // "strictNullChecks": true, 26 | // "strictPropertyInitialization": true, 27 | // "strictBindCallApply": true, 28 | // "noImplicitAny": true, 29 | // "noUnusedLocals": true, 30 | // "noUnusedParameters": true, 31 | // Uncomment this if you want the old behavior of catch variables being `any` 32 | // "useUnknownInCatchVariables": false, 33 | 34 | "sourceMap": true, 35 | "inlineSourceMap": false 36 | }, 37 | "include": [ 38 | "src/**/*.ts", 39 | "test/**/*.ts" 40 | ], 41 | "exclude": [ 42 | "build/**", 43 | "node_modules/**", 44 | "widgets/**" 45 | ] 46 | } -------------------------------------------------------------------------------- /TypeScriptVIS/widgets/.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "browser": true, 4 | "es6": false 5 | }, 6 | "rules": { 7 | // Visualizations may run in very old browsers without `let` and `const` 8 | "no-var": "off", 9 | // The example code does not use some parameters. If unused variables should be 10 | // an error, delete the following rule 11 | "no-unused-vars": [ 12 | "warn", 13 | { 14 | "ignoreRestSiblings": true, 15 | "argsIgnorePattern": "^_" 16 | } 17 | ] 18 | } 19 | } -------------------------------------------------------------------------------- /TypeScriptVIS/widgets/template/css/style.css: -------------------------------------------------------------------------------- 1 | /* Style your widget here */ 2 | .template-class { 3 | font-style: italic; 4 | } -------------------------------------------------------------------------------- /TypeScriptVIS/widgets/template/js/template.js: -------------------------------------------------------------------------------- 1 | /* 2 | ioBroker.vis template Widget-Set 3 | 4 | version: "0.0.1" 5 | 6 | Copyright 2024 Author author@mail.com 7 | */ 8 | "use strict"; 9 | 10 | /* global $, vis, systemDictionary */ 11 | 12 | // add translations for edit mode 13 | $.extend( 14 | true, 15 | systemDictionary, 16 | { 17 | // Add your translations here, e.g.: 18 | // "size": { 19 | // "en": "Size", 20 | // "de": "Größe", 21 | // "ru": "Размер", 22 | // "pt": "Tamanho", 23 | // "nl": "Grootte", 24 | // "fr": "Taille", 25 | // "it": "Dimensione", 26 | // "es": "Talla", 27 | // "pl": "Rozmiar", 28 | // "uk": "Розмір" 29 | // "zh-cn": "尺寸" 30 | // } 31 | } 32 | ); 33 | 34 | // this code can be placed directly in template.html 35 | vis.binds["template"] = { 36 | version: "0.0.1", 37 | showVersion: function () { 38 | if (vis.binds["template"].version) { 39 | console.log("Version template: " + vis.binds["template"].version); 40 | vis.binds["template"].version = null; 41 | } 42 | }, 43 | createWidget: function (widgetID, view, data, style) { 44 | var $div = $("#" + widgetID); 45 | // if nothing found => wait 46 | if (!$div.length) { 47 | return setTimeout(function () { 48 | vis.binds["template"].createWidget(widgetID, view, data, style); 49 | }, 100); 50 | } 51 | 52 | var text = ""; 53 | text += "OID: " + data.oid + "
"; 54 | text += 'OID value: ' + vis.states[data.oid + ".val"] + "
"; 55 | text += 'Color: ' + data.myColor + "
"; 56 | text += "extraAttr: " + data.extraAttr + "
"; 57 | text += "Browser instance: " + vis.instance + "
"; 58 | text += 'htmlText:
"; 59 | 60 | $("#" + widgetID).html(text); 61 | 62 | // subscribe on updates of value 63 | function onChange(e, newVal, oldVal) { 64 | $div.find(".template-value").html(newVal); 65 | } 66 | if (data.oid) { 67 | vis.states.bind(data.oid + ".val", onChange); 68 | //remember bound state that vis can release if didnt needed 69 | $div.data("bound", [data.oid + ".val"]); 70 | //remember onchange handler to release bound states 71 | $div.data("bindHandler", onChange); 72 | } 73 | } 74 | }; 75 | 76 | vis.binds["template"].showVersion(); -------------------------------------------------------------------------------- /VIS/.create-adapter.json: -------------------------------------------------------------------------------- 1 | { 2 | "cli": true, 3 | "target": "directory", 4 | "adapterName": "template", 5 | "description": "Template for adapter development", 6 | "authorName": "Author", 7 | "authorGithub": "Author", 8 | "authorEmail": "author@mail.com", 9 | "gitRemoteProtocol": "HTTPS", 10 | "dependabot": "yes", 11 | "license": "MIT License", 12 | "releaseScript": "yes", 13 | "gitCommit": "no", 14 | "defaultBranch": "main", 15 | "features": [ 16 | "vis" 17 | ], 18 | "title": "Template (VIS only)", 19 | "type": "visualization-widgets", 20 | "creatorVersion": "2.6.5" 21 | } -------------------------------------------------------------------------------- /VIS/.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Something is not working as it should 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | --- 8 | 9 | **Describe the bug** 10 | A clear and concise description of what the bug is. 11 | 12 | **To Reproduce** 13 | Steps to reproduce the behavior: 14 | 1. Go to '...' 15 | 2. Click on '...' 16 | 3. Scroll down to '....' 17 | 4. See error 18 | 19 | **Expected behavior** 20 | A clear and concise description of what you expected to happen. 21 | 22 | **Screenshots & Logfiles** 23 | If applicable, add screenshots and logfiles to help explain your problem. 24 | 25 | **Versions:** 26 | - Adapter version: 27 | - JS-Controller version: 28 | - Node version: 29 | - Operating system: 30 | 31 | **Additional context** 32 | Add any other context about the problem here. 33 | -------------------------------------------------------------------------------- /VIS/.github/auto-merge.yml: -------------------------------------------------------------------------------- 1 | # Configure here which dependency updates should be merged automatically. 2 | # The recommended configuration is the following: 3 | - match: 4 | # Only merge patches for production dependencies 5 | dependency_type: production 6 | update_type: "semver:patch" 7 | - match: 8 | # Except for security fixes, here we allow minor patches 9 | dependency_type: production 10 | update_type: "security:minor" 11 | - match: 12 | # and development dependencies can have a minor update, too 13 | dependency_type: development 14 | update_type: "semver:minor" 15 | 16 | # The syntax is based on the legacy dependabot v1 automerged_updates syntax, see: 17 | # https://dependabot.com/docs/config-file/#automerged_updates 18 | -------------------------------------------------------------------------------- /VIS/.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: npm 4 | directory: "/" 5 | schedule: 6 | interval: monthly 7 | time: "04:00" 8 | timezone: Europe/Berlin 9 | open-pull-requests-limit: 5 10 | assignees: 11 | - Author 12 | versioning-strategy: increase 13 | 14 | - package-ecosystem: github-actions 15 | directory: "/" 16 | schedule: 17 | interval: monthly 18 | time: "04:00" 19 | timezone: Europe/Berlin 20 | open-pull-requests-limit: 5 21 | assignees: 22 | - Author 23 | -------------------------------------------------------------------------------- /VIS/.github/workflows/dependabot-auto-merge.yml: -------------------------------------------------------------------------------- 1 | # Automatically merge Dependabot PRs when version comparison is within the range 2 | # that is configured in .github/auto-merge.yml 3 | 4 | name: Auto-Merge Dependabot PRs 5 | 6 | on: 7 | # WARNING: This needs to be run in the PR base, DO NOT build untrusted code in this action 8 | # details under https://github.blog/changelog/2021-02-19-github-actions-workflows-triggered-by-dependabot-prs-will-run-with-read-only-permissions/ 9 | pull_request_target: 10 | 11 | jobs: 12 | auto-merge: 13 | if: github.actor == 'dependabot[bot]' 14 | runs-on: ubuntu-latest 15 | steps: 16 | - name: Checkout code 17 | uses: actions/checkout@v2 18 | 19 | - name: Check if PR should be auto-merged 20 | uses: ahmadnassri/action-dependabot-auto-merge@v2 21 | with: 22 | # In order to use this, you need to go to https://github.com/settings/tokens and 23 | # create a Personal Access Token with the permission "public_repo". 24 | # Enter this token in your repository settings under "Secrets" and name it AUTO_MERGE_TOKEN 25 | github-token: ${{ secrets.AUTO_MERGE_TOKEN }} 26 | # By default, squash and merge, so Github chooses nice commit messages 27 | command: squash and merge 28 | -------------------------------------------------------------------------------- /VIS/.github/workflows/test-and-release.yml: -------------------------------------------------------------------------------- 1 | name: Test and Release 2 | 3 | # Run this job on all pushes and pull requests 4 | # as well as tags with a semantic version 5 | on: 6 | push: 7 | branches: 8 | - "main" 9 | tags: 10 | # normal versions 11 | - "v[0-9]+.[0-9]+.[0-9]+" 12 | # pre-releases 13 | - "v[0-9]+.[0-9]+.[0-9]+-**" 14 | pull_request: {} 15 | 16 | # Cancel previous PR/branch runs when a new commit is pushed 17 | concurrency: 18 | group: ${{ github.ref }} 19 | cancel-in-progress: true 20 | 21 | jobs: 22 | # Performs quick checks before the expensive test runs 23 | check-and-lint: 24 | if: contains(github.event.head_commit.message, '[skip ci]') == false 25 | 26 | runs-on: ubuntu-latest 27 | 28 | steps: 29 | - uses: ioBroker/testing-action-check@v1 30 | with: 31 | node-version: '20.x' 32 | # Uncomment the following line if your adapter cannot be installed using 'npm ci' 33 | # install-command: 'npm install' 34 | 35 | 36 | # TODO: To enable automatic npm releases, create a token on npmjs.org 37 | # Enter this token as a GitHub secret (with name NPM_TOKEN) in the repository options 38 | # Then uncomment the following block: 39 | 40 | # # Deploys the final package to NPM 41 | # deploy: 42 | # needs: [check-and-lint] 43 | # 44 | # # Trigger this step only when a commit on any branch is tagged with a version number 45 | # if: | 46 | # contains(github.event.head_commit.message, '[skip ci]') == false && 47 | # github.event_name == 'push' && 48 | # startsWith(github.ref, 'refs/tags/v') 49 | # 50 | # runs-on: ubuntu-latest 51 | # 52 | # # Write permissions are required to create Github releases 53 | # permissions: 54 | # contents: write 55 | # 56 | # steps: 57 | # - uses: ioBroker/testing-action-deploy@v1 58 | # with: 59 | # node-version: '20.x' 60 | # # Uncomment the following line if your adapter cannot be installed using 'npm ci' 61 | # # install-command: 'npm install' 62 | # npm-token: ${{ secrets.NPM_TOKEN }} 63 | # github-token: ${{ secrets.GITHUB_TOKEN }} 64 | # 65 | # # When using Sentry for error reporting, Sentry can be informed about new releases 66 | # # To enable create a API-Token in Sentry (User settings, API keys) 67 | # # Enter this token as a GitHub secret (with name SENTRY_AUTH_TOKEN) in the repository options 68 | # # Then uncomment and customize the following block: 69 | # sentry: true 70 | # sentry-token: ${{ secrets.SENTRY_AUTH_TOKEN }} 71 | # sentry-project: "iobroker-template" 72 | # sentry-version-prefix: "iobroker.template" 73 | # # If your sentry project is linked to a GitHub repository, you can enable the following option 74 | # # sentry-github-integration: true 75 | -------------------------------------------------------------------------------- /VIS/.gitignore: -------------------------------------------------------------------------------- 1 | # No dot-directories except github/vscode 2 | .*/ 3 | !.vscode/ 4 | !.github/ 5 | 6 | *.code-workspace 7 | node_modules 8 | nbproject 9 | 10 | # npm package files 11 | iobroker.*.tgz 12 | 13 | Thumbs.db 14 | 15 | # i18n intermediate files 16 | admin/i18n/flat.txt 17 | admin/i18n/*/flat.txt -------------------------------------------------------------------------------- /VIS/.releaseconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "plugins": [ 3 | "iobroker", 4 | "license", 5 | "manual-review" 6 | ] 7 | } -------------------------------------------------------------------------------- /VIS/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2024 Author 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 all 13 | 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 THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /VIS/admin/template.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ioBroker/ioBroker.example/46e3823aafe0d918fea64ed9dd5d56a64e009b19/VIS/admin/template.png -------------------------------------------------------------------------------- /VIS/admin/words.js: -------------------------------------------------------------------------------- 1 | /* eslint no-unused-vars: off */ 2 | /* eslint no-global-assign: off */ 3 | /* global systemDictionary */ 4 | 'use strict'; 5 | 6 | systemDictionary = { 7 | "myColor": { 8 | "en": "myColor", 9 | "de": "meineColor", 10 | "ru": "Мой цвет", 11 | "pt": "minhaCor", 12 | "nl": "mijnKleur", 13 | "fr": "maCouleur", 14 | "it": "mioColore", 15 | "es": "miColor", 16 | "pl": "mójKolor", 17 | "uk": "мійКолір", 18 | "zh-cn": "我的颜色" 19 | }, 20 | "myColor_tooltip": { 21 | "en": "Description of\nmyColor", 22 | "de": "Beschreibung von\nmyColor", 23 | "ru": "Описание\nmyColor", 24 | "pt": "Descrição de\nmyColor", 25 | "nl": "Beschrijving van\nmyColor", 26 | "fr": "Description de\nmyColor", 27 | "it": "Descrizione di\nmyColor", 28 | "es": "Descripción de\nmyColor", 29 | "pl": "Opis\nmyColor", 30 | "uk": "Опис\nmyColor", 31 | "zh-cn": "\nmyColor的描述" 32 | }, 33 | "htmlText": { 34 | "en": "htmlText", 35 | "de": "htmlText", 36 | "ru": "htmlText", 37 | "pt": "htmlText", 38 | "nl": "htmlText", 39 | "fr": "htmlText", 40 | "it": "htmlText", 41 | "es": "htmlText", 42 | "pl": "htmlText", 43 | "uk": "htmlText", 44 | "zh-cn": "htmlText" 45 | }, 46 | "group_extraMyset": { 47 | "en": "extraMyset", 48 | "de": "extraMyset", 49 | "ru": "extraMyset", 50 | "pt": "extraMyset", 51 | "nl": "extraMyset", 52 | "fr": "extraMyset", 53 | "it": "extraMyset", 54 | "es": "extraMyset", 55 | "pl": "extraMyset", 56 | "uk": "extraMyset", 57 | "zh-cn": "extraMyset" 58 | }, 59 | "extraAttr": { 60 | "en": "extraAttr", 61 | "de": "extraAttr", 62 | "ru": "extraAttr", 63 | "pt": "extraAttr", 64 | "nl": "extraAttr", 65 | "fr": "extraAttr", 66 | "it": "extraAttr", 67 | "es": "extraAttr", 68 | "pl": "extraAttr", 69 | "uk": "extraAttr", 70 | "zh-cn": "extraAttr" 71 | }, 72 | "Instance": { 73 | "en": "Instance", 74 | "de": "Instanz", 75 | "ru": "Инстанция", 76 | "pt": "Instância", 77 | "nl": "Instantie", 78 | "fr": "Instance", 79 | "it": "Esempio", 80 | "es": "Instancia", 81 | "pl": "Instancja", 82 | "uk": "Інстанція", 83 | "zh-cn": "例" 84 | } 85 | }; -------------------------------------------------------------------------------- /VIS/io-package.json: -------------------------------------------------------------------------------- 1 | { 2 | "common": { 3 | "name": "template", 4 | "version": "0.0.1", 5 | "news": { 6 | "0.0.1": { 7 | "en": "initial release", 8 | "de": "Erstveröffentlichung", 9 | "ru": "Начальная версия", 10 | "pt": "lançamento inicial", 11 | "nl": "Eerste uitgave", 12 | "fr": "Première version", 13 | "it": "Versione iniziale", 14 | "es": "Versión inicial", 15 | "pl": "Pierwsze wydanie", 16 | "uk": "Початкова версія", 17 | "zh-cn": "首次出版" 18 | } 19 | }, 20 | "titleLang": { 21 | "en": "Template (VIS only)", 22 | "de": "Vorlage (nur VIS)", 23 | "ru": "Шаблон (только VIS)", 24 | "pt": "Modelo (somente VIS)", 25 | "nl": "Sjabloon (alleen VIS)", 26 | "fr": "Modèle (VIS uniquement)", 27 | "it": "Modello (solo VIS)", 28 | "es": "Plantilla (solo VIS)", 29 | "pl": "Szablon (tylko VIS)", 30 | "uk": "Шаблон (лише VIS)", 31 | "zh-cn": "模板(仅 VIS)" 32 | }, 33 | "desc": { 34 | "en": "Template for adapter development", 35 | "de": "Vorlage für die Adapterentwicklung", 36 | "ru": "Шаблон для разработки адаптера", 37 | "pt": "Modelo para desenvolvimento de adaptador", 38 | "nl": "Sjabloon voor adapterontwikkeling", 39 | "fr": "Modèle pour le développement d'adaptateurs", 40 | "it": "Modello per lo sviluppo dell'adattatore", 41 | "es": "Plantilla para el desarrollo de adaptadores.", 42 | "pl": "Szablon do opracowania adaptera", 43 | "uk": "Шаблон для розробки адаптера", 44 | "zh-cn": "适配器开发模板" 45 | }, 46 | "authors": [ 47 | "Author " 48 | ], 49 | "keywords": [ 50 | "ioBroker", 51 | "template", 52 | "Smart Home", 53 | "home automation" 54 | ], 55 | "licenseInformation": { 56 | "type": "free", 57 | "license": "MIT" 58 | }, 59 | "platform": "Javascript/Node.js", 60 | "icon": "template.png", 61 | "enabled": true, 62 | "extIcon": "https://raw.githubusercontent.com/Author/ioBroker.template/main/admin/template.png", 63 | "readme": "https://github.com/Author/ioBroker.template/blob/main/README.md", 64 | "loglevel": "info", 65 | "tier": 3, 66 | "restartAdapters": [ 67 | "vis" 68 | ], 69 | "onlyWWW": true, 70 | "noConfig": true, 71 | "singleton": true, 72 | "type": "visualization-widgets", 73 | "mode": "once", 74 | "dependencies": [ 75 | "vis" 76 | ], 77 | "globalDependencies": [] 78 | }, 79 | "native": { 80 | "option1": true, 81 | "option2": "42" 82 | }, 83 | "objects": [], 84 | "instanceObjects": [] 85 | } -------------------------------------------------------------------------------- /VIS/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "iobroker.template", 3 | "version": "0.0.1", 4 | "description": "Template for adapter development", 5 | "author": { 6 | "name": "Author", 7 | "email": "author@mail.com" 8 | }, 9 | "homepage": "https://github.com/Author/ioBroker.template", 10 | "license": "MIT", 11 | "keywords": [ 12 | "ioBroker", 13 | "template", 14 | "Smart Home", 15 | "home automation" 16 | ], 17 | "repository": { 18 | "type": "git", 19 | "url": "https://github.com/Author/ioBroker.template.git" 20 | }, 21 | "engines": { 22 | "node": ">= 20" 23 | }, 24 | "dependencies": {}, 25 | "devDependencies": { 26 | "@alcalzone/release-script": "^3.8.0", 27 | "@alcalzone/release-script-plugin-iobroker": "^3.7.2", 28 | "@alcalzone/release-script-plugin-license": "^3.7.0", 29 | "@alcalzone/release-script-plugin-manual-review": "^3.7.0", 30 | "@iobroker/adapter-dev": "^1.3.0", 31 | "@iobroker/testing": "^4.1.3" 32 | }, 33 | "main": "widgets/template.html", 34 | "files": [ 35 | "widgets/**/!(tsconfig|tsconfig.*|.eslintrc).json", 36 | "widgets/**/*.{html,css,png,svg,jpg,js}", 37 | "www/", 38 | "io-package.json", 39 | "LICENSE" 40 | ], 41 | "scripts": { 42 | "test:package": "mocha test/package --exit", 43 | "test": "npm run test:package", 44 | "translate": "translate-adapter", 45 | "release": "release-script" 46 | }, 47 | "bugs": { 48 | "url": "https://github.com/Author/ioBroker.template/issues" 49 | }, 50 | "readmeFilename": "README.md" 51 | } -------------------------------------------------------------------------------- /VIS/test/mocha.setup.js: -------------------------------------------------------------------------------- 1 | // Don't silently swallow unhandled rejections 2 | process.on("unhandledRejection", (e) => { 3 | throw e; 4 | }); 5 | 6 | // enable the should interface with sinon 7 | // and load chai-as-promised and sinon-chai by default 8 | const sinonChai = require("sinon-chai"); 9 | const chaiAsPromised = require("chai-as-promised"); 10 | const { should, use } = require("chai"); 11 | 12 | should(); 13 | use(sinonChai); 14 | use(chaiAsPromised); -------------------------------------------------------------------------------- /VIS/test/mocharc.custom.json: -------------------------------------------------------------------------------- 1 | { 2 | "require": [ 3 | "test/mocha.setup.js" 4 | ], 5 | "watch-files": [ 6 | "!(node_modules|test)/**/*.test.js", 7 | "*.test.js", 8 | "test/**/test!(PackageFiles|Startup).js" 9 | ] 10 | } -------------------------------------------------------------------------------- /VIS/test/package.js: -------------------------------------------------------------------------------- 1 | const path = require("path"); 2 | const { tests } = require("@iobroker/testing"); 3 | 4 | // Validate the package files 5 | tests.packageFiles(path.join(__dirname, "..")); 6 | -------------------------------------------------------------------------------- /VIS/widgets/.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "browser": true, 4 | "es6": false 5 | }, 6 | "rules": { 7 | // Visualizations may run in very old browsers without `let` and `const` 8 | "no-var": "off", 9 | // The example code does not use some parameters. If unused variables should be 10 | // an error, delete the following rule 11 | "no-unused-vars": [ 12 | "warn", 13 | { 14 | "ignoreRestSiblings": true, 15 | "argsIgnorePattern": "^_" 16 | } 17 | ] 18 | } 19 | } -------------------------------------------------------------------------------- /VIS/widgets/template/css/style.css: -------------------------------------------------------------------------------- 1 | /* Style your widget here */ 2 | .template-class { 3 | font-style: italic; 4 | } -------------------------------------------------------------------------------- /VIS/widgets/template/js/template.js: -------------------------------------------------------------------------------- 1 | /* 2 | ioBroker.vis template Widget-Set 3 | 4 | version: "0.0.1" 5 | 6 | Copyright 2024 Author author@mail.com 7 | */ 8 | "use strict"; 9 | 10 | /* global $, vis, systemDictionary */ 11 | 12 | // add translations for edit mode 13 | $.extend( 14 | true, 15 | systemDictionary, 16 | { 17 | // Add your translations here, e.g.: 18 | // "size": { 19 | // "en": "Size", 20 | // "de": "Größe", 21 | // "ru": "Размер", 22 | // "pt": "Tamanho", 23 | // "nl": "Grootte", 24 | // "fr": "Taille", 25 | // "it": "Dimensione", 26 | // "es": "Talla", 27 | // "pl": "Rozmiar", 28 | // "uk": "Розмір" 29 | // "zh-cn": "尺寸" 30 | // } 31 | } 32 | ); 33 | 34 | // this code can be placed directly in template.html 35 | vis.binds["template"] = { 36 | version: "0.0.1", 37 | showVersion: function () { 38 | if (vis.binds["template"].version) { 39 | console.log('Version template: ' + vis.binds["template"].version); 40 | vis.binds["template"].version = null; 41 | } 42 | }, 43 | createWidget: function (widgetID, view, data, style) { 44 | var $div = $('#' + widgetID); 45 | // if nothing found => wait 46 | if (!$div.length) { 47 | return setTimeout(function () { 48 | vis.binds["template"].createWidget(widgetID, view, data, style); 49 | }, 100); 50 | } 51 | 52 | var text = ''; 53 | text += 'OID: ' + data.oid + '
'; 54 | text += 'OID value: ' + vis.states[data.oid + '.val'] + '
'; 55 | text += 'Color: ' + data.myColor + '
'; 56 | text += 'extraAttr: ' + data.extraAttr + '
'; 57 | text += 'Browser instance: ' + vis.instance + '
'; 58 | text += 'htmlText:
'; 59 | 60 | $('#' + widgetID).html(text); 61 | 62 | // subscribe on updates of value 63 | function onChange(e, newVal, oldVal) { 64 | $div.find('.template-value').html(newVal); 65 | } 66 | if (data.oid) { 67 | vis.states.bind(data.oid + '.val', onChange); 68 | //remember bound state that vis can release if didnt needed 69 | $div.data('bound', [data.oid + '.val']); 70 | //remember onchange handler to release bound states 71 | $div.data('bindHandler', onChange); 72 | } 73 | } 74 | }; 75 | 76 | vis.binds["template"].showVersion(); -------------------------------------------------------------------------------- /icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ioBroker/ioBroker.example/46e3823aafe0d918fea64ed9dd5d56a64e009b19/icon.png --------------------------------------------------------------------------------