Skip to content

Commit 53cac04

Browse files
author
Stefan Köhler
committed
Initial version
0 parents  commit 53cac04

34 files changed

+5283
-0
lines changed

.create-adapter.json

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
"cli": true,
3+
"target": "directory",
4+
"adapterName": "han",
5+
"title": "Smartmeter HAN",
6+
"description": "Adapter to connect smartmeter via HAN interface to ioBroker",
7+
"expert": "yes",
8+
"features": [
9+
"adapter"
10+
],
11+
"adminFeatures": [],
12+
"type": "energy",
13+
"startMode": "daemon",
14+
"connectionType": "local",
15+
"dataSource": "poll",
16+
"connectionIndicator": "yes",
17+
"language": "JavaScript",
18+
"nodeVersion": "16",
19+
"adminUi": "json",
20+
"tools": [
21+
"type checking"
22+
],
23+
"releaseScript": "yes",
24+
"devServer": "yes",
25+
"devServerPort": 8081,
26+
"indentation": "Space (4)",
27+
"quotes": "single",
28+
"es6class": "yes",
29+
"authorName": "Stefan Köhler",
30+
"authorGithub": "tukey42",
31+
"authorEmail": "[email protected]",
32+
"gitRemoteProtocol": "HTTPS",
33+
"gitCommit": "no",
34+
"defaultBranch": "main",
35+
"license": "MIT License",
36+
"dependabot": "no",
37+
"creatorVersion": "2.3.0"
38+
}

.github/ISSUE_TEMPLATE/bug_report.md

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
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: <adapter-version>
27+
- JS-Controller version: <js-controller-version> <!-- determine this with `iobroker -v` on the console -->
28+
- Node version: <node-version> <!-- determine this with `node -v` on the console -->
29+
- Operating system: <os-name>
30+
31+
**Additional context**
32+
Add any other context about the problem here.
+91
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
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: '16.x'
32+
# Uncomment the following line if your adapter cannot be installed using 'npm ci'
33+
# install-command: 'npm install'
34+
35+
# Runs adapter tests on all supported node versions and OSes
36+
adapter-tests:
37+
if: contains(github.event.head_commit.message, '[skip ci]') == false
38+
39+
runs-on: ${{ matrix.os }}
40+
strategy:
41+
matrix:
42+
node-version: [14.x, 16.x, 18.x]
43+
os: [ubuntu-latest, windows-latest, macos-latest]
44+
45+
steps:
46+
- uses: ioBroker/testing-action-adapter@v1
47+
with:
48+
node-version: ${{ matrix.node-version }}
49+
os: ${{ matrix.os }}
50+
# Uncomment the following line if your adapter cannot be installed using 'npm ci'
51+
# install-command: 'npm install'
52+
53+
# TODO: To enable automatic npm releases, create a token on npmjs.org
54+
# Enter this token as a GitHub secret (with name NPM_TOKEN) in the repository options
55+
# Then uncomment the following block:
56+
57+
# # Deploys the final package to NPM
58+
# deploy:
59+
# needs: [check-and-lint, adapter-tests]
60+
#
61+
# # Trigger this step only when a commit on any branch is tagged with a version number
62+
# if: |
63+
# contains(github.event.head_commit.message, '[skip ci]') == false &&
64+
# github.event_name == 'push' &&
65+
# startsWith(github.ref, 'refs/tags/v')
66+
#
67+
# runs-on: ubuntu-latest
68+
#
69+
# # Write permissions are required to create Github releases
70+
# permissions:
71+
# contents: write
72+
#
73+
# steps:
74+
# - uses: ioBroker/testing-action-deploy@v1
75+
# with:
76+
# node-version: '16.x'
77+
# # Uncomment the following line if your adapter cannot be installed using 'npm ci'
78+
# # install-command: 'npm install'
79+
# npm-token: ${{ secrets.NPM_TOKEN }}
80+
# github-token: ${{ secrets.GITHUB_TOKEN }}
81+
#
82+
# # When using Sentry for error reporting, Sentry can be informed about new releases
83+
# # To enable create a API-Token in Sentry (User settings, API keys)
84+
# # Enter this token as a GitHub secret (with name SENTRY_AUTH_TOKEN) in the repository options
85+
# # Then uncomment and customize the following block:
86+
# sentry: true
87+
# sentry-token: ${{ secrets.SENTRY_AUTH_TOKEN }}
88+
# sentry-project: "iobroker-han"
89+
# sentry-version-prefix: "iobroker.han"
90+
# # If your sentry project is linked to a GitHub repository, you can enable the following option
91+
# # sentry-github-integration: true

.gitignore

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
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

.releaseconfig.json

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"plugins": [
3+
"iobroker",
4+
"license",
5+
"manual-review"
6+
]
7+
}

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2024 Stefan Köhler <[email protected]>
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.

README.md

+130
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
![Logo](admin/han.png)
2+
# ioBroker.han
3+
4+
[![NPM version](https://img.shields.io/npm/v/iobroker.han.svg)](https://www.npmjs.com/package/iobroker.han)
5+
[![Downloads](https://img.shields.io/npm/dm/iobroker.han.svg)](https://www.npmjs.com/package/iobroker.han)
6+
![Number of Installations](https://iobroker.live/badges/han-installed.svg)
7+
![Current version in stable repository](https://iobroker.live/badges/han-stable.svg)
8+
9+
[![NPM](https://nodei.co/npm/iobroker.han.png?downloads=true)](https://nodei.co/npm/iobroker.han/)
10+
11+
**Tests:** ![Test and Release](https://github.com/tukey42/ioBroker.han/workflows/Test%20and%20Release/badge.svg)
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.

Untitled-1.json

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"value": 15678.1189,
3+
"unit": "kWh",
4+
"timestamp": "2024-03-24 15:30:00",
5+
"isvalid": "1",
6+
"name": "Elektro Wirkarbeit Verbrauch Zählerstand",
7+
"obis": "1-0:1.8.0",
8+
"fwversion": "32474-32475",
9+
"meterid": "1itr0310098113.sm",
10+
"updateinterval": 900
11+
}

admin/han.png

60.9 KB
Loading

admin/i18n/de/translations.json

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"han adapter settings": "Adaptereinstellungen für han",
3+
"option1": "Option 1",
4+
"option2": "Option 2"
5+
}

admin/i18n/en/translations.json

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"han adapter settings": "Adapter settings for han",
3+
"option1": "option1",
4+
"option2": "option2"
5+
}

admin/i18n/es/translations.json

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"han adapter settings": "Ajustes del adaptador para han",
3+
"option1": "Opción 1",
4+
"option2": "opcion 2"
5+
}

admin/i18n/fr/translations.json

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"han adapter settings": "Paramètres d'adaptateur pour han",
3+
"option1": "Option 1",
4+
"option2": "Option 2"
5+
}

admin/i18n/it/translations.json

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"han adapter settings": "Impostazioni dell'adattatore per han",
3+
"option1": "opzione 1",
4+
"option2": "opzione 2"
5+
}

0 commit comments

Comments
 (0)