Skip to content

Commit

Permalink
Initial Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
dg-services committed Jan 27, 2020
0 parents commit d2e12ab
Show file tree
Hide file tree
Showing 29 changed files with 7,744 additions and 0 deletions.
35 changes: 35 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"env": {
"es6": true,
"node": true,
"mocha": true
},
"extends": "eslint:recommended",
"rules": {
"indent": [
"error",
"tab",
{
"SwitchCase": 1
}
],
"no-console": "off",
"no-var": "error",
"prefer-const": "error",
"quotes": [
"error",
"single",
{
"avoidEscape": true,
"allowTemplateLiterals": true
}
],
"semi": [
"error",
"always"
]
},
"parserOptions": {
"ecmaVersion": 2018
}
}
32 changes: 32 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
name: Bug report
about: Something is not working as it should
title: ''
labels: ''
assignees: ''
---

**Describe the bug**
A clear and concise description of what the bug is.

**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '...'
3. Scroll down to '....'
4. See error

**Expected behavior**
A clear and concise description of what you expected to happen.

**Screenshots & Logfiles**
If applicable, add screenshots and logfiles to help explain your problem.

**Versions:**
- Adapter version: <adapter-version>
- JS-Controller version: <js-controller-version> <!-- determine this with `iobroker -v` on the console -->
- Node version: <node-version> <!-- determine this with `node -v` on the console -->
- Operating system: <os-name>

**Additional context**
Add any other context about the problem here.
14 changes: 14 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
.git
.idea
*.code-workspace
node_modules
nbproject

# npm package files
iobroker.*.tgz

Thumbs.db

# i18n intermediate files
admin/i18n/flat.txt
admin/i18n/*/flat.txt
28 changes: 28 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
.git
.idea
node_modules/
nbproject/
.vs*/
*.code-workspace
Thumbs.db
gulpfile.js

test/
travis/
.travis.yml
appveyor.yml
.travis.yaml
appveyor.yaml

.eslintrc.json
.eslintrc.js

# npm package files
iobroker.*.tgz
package-lock.json

# i18n intermediate files
admin/i18n

# maintenance scripts
maintenance/**
5 changes: 5 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"recommendations": [
"dbaeumer.vscode-eslint"
]
}
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"eslint.enable": true
}
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2020 Dominik Gerstner <code@dg-home.de>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
108 changes: 108 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
![Logo](admin/smartgarden.png)
# ioBroker.smartgarden

[![NPM version](http://img.shields.io/npm/v/iobroker.smartgarden.svg)](https://www.npmjs.com/package/iobroker.smartgarden)
[![Downloads](https://img.shields.io/npm/dm/iobroker.smartgarden.svg)](https://www.npmjs.com/package/iobroker.smartgarden)
![Number of Installations (latest)](http://iobroker.live/badges/smartgarden-installed.svg)
![Number of Installations (stable)](http://iobroker.live/badges/smartgarden-stable.svg)
[![Dependency Status](https://img.shields.io/david/dg-services/iobroker.smartgarden.svg)](https://david-dm.org/dg-services/iobroker.smartgarden)
[![Known Vulnerabilities](https://snyk.io/test/github/dg-services/ioBroker.smartgarden/badge.svg)](https://snyk.io/test/github/dg-services/ioBroker.smartgarden)

[![NPM](https://nodei.co/npm/iobroker.smartgarden.png?downloads=true)](https://nodei.co/npm/iobroker.smartgarden/)

## smartgarden adapter for ioBroker

Control smart lawn mower from Gardena / Husqvara

## Developer manual
This section is intended for the developer. It can be deleted later

### Getting started

You are almost done, only a few steps left:
1. Create a new repository on GitHub with the name `ioBroker.smartgarden`
1. Initialize the current folder as a new git repository:
```bash
git init
git add .
git commit -m "Initial commit"
```
1. Link your local repository with the one on GitHub:
```bash
git remote add origin https://github.com/dg-services/ioBroker.smartgarden
```

1. Push all files to the GitHub repo:
```bash
git push origin master
```
1. Head over to [main.js](main.js) and start programming!

### Scripts in `package.json`
Several npm scripts are predefined for your convenience. You can run them using `npm run <scriptname>`
| Script name | Description |
|-------------|----------------------------------------------------------|
| `test:js` | Executes the tests you defined in `*.test.js` files. |
| `test:package` | Ensures your `package.json` and `io-package.json` are valid. |
| `test` | Performs a minimal test run on package files and your tests. |
| `lint` | Runs `ESLint` to check your code for formatting errors and potential bugs. |

### Writing tests
When done right, testing code is invaluable, because it gives you the
confidence to change your code while knowing exactly if and when
something breaks. A good read on the topic of test-driven development
is https://hackernoon.com/introduction-to-test-driven-development-tdd-61a13bc92d92.
Although writing tests before the code might seem strange at first, but it has very
clear upsides.

The template provides you with basic tests for the adapter startup and package files.
It is recommended that you add your own tests into the mix.

### Publishing the adapter
To get your adapter released in ioBroker, please refer to the documentation
of [ioBroker.repositories](https://github.com/ioBroker/ioBroker.repositories#requirements-for-adapter-to-get-added-to-the-latest-repository).

### Test the adapter manually on a local ioBroker installation
In order to install the adapter locally without publishing, the following steps are recommended:
1. Create a tarball from your dev directory:
```bash
npm pack
```
1. Upload the resulting file to your ioBroker host
1. Install it locally (The paths are different on Windows):
```bash
cd /opt/iobroker
npm i /path/to/tarball.tgz
```

For later updates, the above procedure is not necessary. Just do the following:
1. Overwrite the changed files in the adapter directory (`/opt/iobroker/node_modules/iobroker.smartgarden`)
1. Execute `iobroker upload smartgarden` on the ioBroker host

## Changelog

### 0.0.1
* (Dominik Gerstner) initial release

## License
MIT License

Copyright (c) 2020 Dominik Gerstner <code@dg-home.de>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
1 change: 1 addition & 0 deletions admin/admin.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
declare let systemDictionary: Record<string, Record<string, string>>;
93 changes: 93 additions & 0 deletions admin/index_m.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
<html>

<head>

<!-- Load ioBroker scripts and styles-->
<link rel="stylesheet" type="text/css" href="../../css/adapter.css" />
<link rel="stylesheet" type="text/css" href="../../lib/css/materialize.css">

<script type="text/javascript" src="../../lib/js/jquery-3.2.1.min.js"></script>
<script type="text/javascript" src="../../socket.io/socket.io.js"></script>

<script type="text/javascript" src="../../js/translate.js"></script>
<script type="text/javascript" src="../../lib/js/materialize.js"></script>
<script type="text/javascript" src="../../js/adapter-settings.js"></script>

<!-- Load our own files -->
<link rel="stylesheet" type="text/css" href="style.css" />
<script type="text/javascript" src="words.js"></script>

<script type="text/javascript">
// This will be called by the admin adapter when the settings page loads
function load(settings, onChange) {
// example: select elements with id=key and class=value and insert value
if (!settings) return;
$('.value').each(function () {
var $key = $(this);
var id = $key.attr('id');
if ($key.attr('type') === 'checkbox') {
// do not call onChange direct, because onChange could expect some arguments
$key.prop('checked', settings[id])
.on('change', () => onChange())
;
} else {
// do not call onChange direct, because onChange could expect some arguments
$key.val(settings[id])
.on('change', () => onChange())
.on('keyup', () => onChange())
;
}
});
onChange(false);
// reinitialize all the Materialize labels on the page if you are dynamically adding inputs:
if (M) M.updateTextFields();
}

// This will be called by the admin adapter when the user presses the save button
function save(callback) {
// example: select elements with class=value and build settings object
var obj = {};
$('.value').each(function () {
var $this = $(this);
if ($this.attr('type') === 'checkbox') {
obj[$this.attr('id')] = $this.prop('checked');
} else {
obj[$this.attr('id')] = $this.val();
}
});
callback(obj);
}
</script>

</head>

<body>

<div class="m adapter-container">

<div class="row">
<div class="col s12 m4 l2">
<img src="smartgarden.png" class="logo">
</div>
</div>

<!-- Put your content here -->

<!-- For example columns with settings: -->
<div class="row">
<div class="col s6 input-field">
<input type="checkbox" class="value" id="option1" />
<label for="option1" class="translate">option1</label>
</div>

<div class="col s6 input-field">
<input type="text" class="value" id="option2" />
<label for="option2" class="translate">option2</label>
</div>
</div>

</div>

</body>

</html>
Binary file added admin/smartgarden.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions admin/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/* You can delete those if you want. I just found them very helpful */
* {
box-sizing: border-box
}
.m {
/* Don't cut off dropdowns! */
overflow: initial;
}

/* Add your styles here */
7 changes: 7 additions & 0 deletions admin/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extends": "../tsconfig.json",
"include": [
"./**/*.d.ts",
"./**/*.js"
]
}
Loading

0 comments on commit d2e12ab

Please sign in to comment.