|
| 1 | + |
| 2 | +# ioBroker.han |
| 3 | + |
| 4 | +[](https://www.npmjs.com/package/iobroker.han) |
| 5 | +[](https://www.npmjs.com/package/iobroker.han) |
| 6 | + |
| 7 | + |
| 8 | + |
| 9 | +[](https://nodei.co/npm/iobroker.han/) |
| 10 | + |
| 11 | +**Tests:**  |
| 12 | + |
| 13 | +## han adapter for ioBroker |
| 14 | + |
| 15 | +Adapter to connect smartmeter via HAN interface to ioBroker |
| 16 | + |
| 17 | +## Developer manual |
| 18 | +This section is intended for the developer. It can be deleted later. |
| 19 | + |
| 20 | +### DISCLAIMER |
| 21 | + |
| 22 | +This adapter uses code from Dustin Wiemer (see https://github.com/duswie/node-red-contrib-smgw) |
| 23 | + |
| 24 | +### Getting started |
| 25 | + |
| 26 | +You are almost done, only a few steps left: |
| 27 | +1. Create a new repository on GitHub with the name `ioBroker.han` |
| 28 | +1. Initialize the current folder as a new git repository: |
| 29 | + ```bash |
| 30 | + git init -b main |
| 31 | + git add . |
| 32 | + git commit -m "Initial commit" |
| 33 | + ``` |
| 34 | +1. Link your local repository with the one on GitHub: |
| 35 | + ```bash |
| 36 | + git remote add origin https://github.com/tukey42/ioBroker.han |
| 37 | + ``` |
| 38 | + |
| 39 | +1. Push all files to the GitHub repo: |
| 40 | + ```bash |
| 41 | + git push origin main |
| 42 | + ``` |
| 43 | + |
| 44 | +1. Head over to [main.js](main.js) and start programming! |
| 45 | + |
| 46 | +### Best Practices |
| 47 | +We've collected some [best practices](https://github.com/ioBroker/ioBroker.repositories#development-and-coding-best-practices) regarding ioBroker development and coding in general. If you're new to ioBroker or Node.js, you should |
| 48 | +check them out. If you're already experienced, you should also take a look at them - you might learn something new :) |
| 49 | +
|
| 50 | +### Scripts in `package.json` |
| 51 | +Several npm scripts are predefined for your convenience. You can run them using `npm run <scriptname>` |
| 52 | +| Script name | Description | |
| 53 | +|-------------|-------------| |
| 54 | +| `test:js` | Executes the tests you defined in `*.test.js` files. | |
| 55 | +| `test:package` | Ensures your `package.json` and `io-package.json` are valid. | |
| 56 | +| `test:integration` | Tests the adapter startup with an actual instance of ioBroker. | |
| 57 | +| `test` | Performs a minimal test run on package files and your tests. | |
| 58 | +| `check` | Performs a type-check on your code (without compiling anything). | |
| 59 | +| `translate` | Translates texts in your adapter to all required languages, see [`@iobroker/adapter-dev`](https://github.com/ioBroker/adapter-dev#manage-translations) for more details. | |
| 60 | +| `release` | Creates a new release, see [`@alcalzone/release-script`](https://github.com/AlCalzone/release-script#usage) for more details. | |
| 61 | +
|
| 62 | +### Writing tests |
| 63 | +When done right, testing code is invaluable, because it gives you the |
| 64 | +confidence to change your code while knowing exactly if and when |
| 65 | +something breaks. A good read on the topic of test-driven development |
| 66 | +is https://hackernoon.com/introduction-to-test-driven-development-tdd-61a13bc92d92. |
| 67 | +Although writing tests before the code might seem strange at first, but it has very |
| 68 | +clear upsides. |
| 69 | +
|
| 70 | +The template provides you with basic tests for the adapter startup and package files. |
| 71 | +It is recommended that you add your own tests into the mix. |
| 72 | +
|
| 73 | +### Publishing the adapter |
| 74 | +Using GitHub Actions, you can enable automatic releases on npm whenever you push a new git tag that matches the form |
| 75 | +`v<major>.<minor>.<patch>`. We **strongly recommend** that you do. The necessary steps are described in `.github/workflows/test-and-release.yml`. |
| 76 | +
|
| 77 | +Since you installed the release script, you can create a new |
| 78 | +release simply by calling: |
| 79 | +```bash |
| 80 | +npm run release |
| 81 | +``` |
| 82 | +Additional command line options for the release script are explained in the |
| 83 | +[release-script documentation](https://github.com/AlCalzone/release-script#command-line). |
| 84 | +
|
| 85 | +To get your adapter released in ioBroker, please refer to the documentation |
| 86 | +of [ioBroker.repositories](https://github.com/ioBroker/ioBroker.repositories#requirements-for-adapter-to-get-added-to-the-latest-repository). |
| 87 | +
|
| 88 | +### Test the adapter manually with dev-server |
| 89 | +Since you set up `dev-server`, you can use it to run, test and debug your adapter. |
| 90 | +
|
| 91 | +You may start `dev-server` by calling from your dev directory: |
| 92 | +```bash |
| 93 | +dev-server watch |
| 94 | +``` |
| 95 | +
|
| 96 | +The ioBroker.admin interface will then be available at http://localhost:8081/ |
| 97 | +
|
| 98 | +Please refer to the [`dev-server` documentation](https://github.com/ioBroker/dev-server#command-line) for more details. |
| 99 | +
|
| 100 | +## Changelog |
| 101 | +<!-- |
| 102 | + Placeholder for the next version (at the beginning of the line): |
| 103 | + ### **WORK IN PROGRESS** |
| 104 | +--> |
| 105 | +
|
| 106 | +### **WORK IN PROGRESS** |
| 107 | +* (Stefan Köhler) initial release |
| 108 | +
|
| 109 | +## License |
| 110 | +MIT License |
| 111 | +
|
| 112 | +Copyright (c) 2024 Stefan Köhler <[email protected]> |
| 113 | +
|
| 114 | +Permission is hereby granted, free of charge, to any person obtaining a copy |
| 115 | +of this software and associated documentation files (the "Software"), to deal |
| 116 | +in the Software without restriction, including without limitation the rights |
| 117 | +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 118 | +copies of the Software, and to permit persons to whom the Software is |
| 119 | +furnished to do so, subject to the following conditions: |
| 120 | +
|
| 121 | +The above copyright notice and this permission notice shall be included in all |
| 122 | +copies or substantial portions of the Software. |
| 123 | +
|
| 124 | +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 125 | +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 126 | +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 127 | +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 128 | +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 129 | +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 130 | +SOFTWARE. |
0 commit comments