Skip to content

Commit

Permalink
new api
Browse files Browse the repository at this point in the history
  • Loading branch information
TA2k committed Nov 5, 2023
1 parent 6acc1ba commit 65673d2
Show file tree
Hide file tree
Showing 6 changed files with 361 additions and 862 deletions.
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,25 @@ Adapter for Zehnder Cloud API

## Loginablauf

Bei Zehnder cloud API anmelden und ein subscription key beantragen
1. https://developer.beta.zehnder.cloud/profile

Register in the zehnder cloud and create a subscription. Copy the primary key in the adapter settings

2. https://mydevices.beta.zehnder.cloud/customer/settings/application

Create API Key
Enter API Name and Key in the Adapter Settings

## Diskussion und Fragen

<https://forum.iobroker.net/topic/47856/test-adapter-zehnder-cloud-v-0-0-1>

## Changelog

### 2.0.0

- (TA2k) switch to new api from zehnder

### 0.0.8

- (TA2k) improve error messages
Expand Down
192 changes: 101 additions & 91 deletions admin/index_m.html
Original file line number Diff line number Diff line change
@@ -1,102 +1,112 @@
<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" />
<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="../../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>
<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>
<!-- 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();
}
<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 if ($this.attr("type") === "number") {
obj[$this.attr("id")] = parseFloat($this.val());
} else {
obj[$this.attr("id")] = $this.val();
}
});
callback(obj);
}
</script>
</head>
// 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 if ($this.attr('type') === 'number') {
obj[$this.attr('id')] = parseFloat($this.val());
} 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="zehnder-cloud.png" class="logo" />
</div>
</div>
<body>
<div class="m adapter-container">
<div class="row">
<div class="col s12 m4 l2">
<img src="zehnder-cloud.png" class="logo" />
</div>
</div>

<!-- Put your content here -->
<!-- Put your content here -->

<!-- For example columns with settings: -->
<div class="row">
<div class="col s6 input-field">
<input type="text" class="value" id="username" />
<label for="username" class="translate">Zehnder Cloud Email</label>
</div>
</div>
<div class="row">
<div class="col s6 input-field">
<input type="password" class="value" id="password" />
<label for="password" class="translate">Zehnder Cloud Password</label>
</div>
</div>
<div class="row">
<div class="col s12">
<a href="https://portal.zehnder.cloudapi.ch/profile" target="_blank">Hier Klicken für Zehnder Cloud API Website</a>
</div>
</div>
<div class="row">
<div class="col s6 input-field">
<input type="text" class="value" id="subKey" />
<label for="subKey" class="translate">Zehnder Subscription/Primary key</label>
</div>
</div>
<div class="row">
<div class="col s2 input-field">
<input type="number" class="value" id="interval" />
<label for="interval" class="translate">Update interval in minutes</label>
</div>
</div>
<!-- For example columns with settings: -->
<div class="row">
<div class="col s12">
<a href="https://mydevices.beta.zehnder.cloud/customer/settings/application" target="_blank"
>Hier Klicken für Zehnder Cloud API Key</a
>
</div>
</div>
<div class="row">
<div class="col s6 input-field">
<input type="text" class="value" id="apiname" />
<label for="apiname" class="translate">Zehnder API Name</label>
</div>
</div>
<div class="row">
<div class="col s6 input-field">
<input type="password" class="value" id="apikey" />
<label for="apikey" class="translate">Zehnder API Key/Secret</label>
</div>
</div>
<div class="row">
<div class="col s12">
<a href="https://developer.beta.zehnder.cloud/profile" target="_blank"
>Hier Klicken für Zehnder Cloud Subscription</a
>
</div>
</div>
<div class="row">
<div class="col s6 input-field">
<input type="text" class="value" id="subKeyNew" />
<label for="subKeyNew" class="translate">Zehnder Subscription/Primary key</label>
</div>
</div>
<div class="row">
<div class="col s2 input-field">
<input type="number" class="value" id="interval" />
<label for="interval" class="translate">Update interval in minutes</label>
</div>
</body>
</div>
</div>
</body>
</html>
15 changes: 9 additions & 6 deletions io-package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
{
"common": {
"name": "zehnder-cloud",
"version": "0.0.8",
"version": "2.0.0",

"news": {
"2.0.0": {
"en": "switch to new zehnder api"
},
"0.0.8": {
"en": "error improvments and dependencies update"
},
Expand Down Expand Up @@ -79,12 +82,12 @@
}
]
},
"encryptedNative": ["password"],
"protectedNative": ["password"],
"encryptedNative": ["apikey"],
"protectedNative": ["apikey"],
"native": {
"username": "",
"password": "",
"subKey": "",
"apiname": "",
"apikey": "",
"subKeyNew": "",
"interval": 5
},
"objects": [],
Expand Down
Loading

0 comments on commit 65673d2

Please sign in to comment.