Skip to content

Commit

Permalink
Add options for retrieving data and notifications
Browse files Browse the repository at this point in the history
  • Loading branch information
sebilm committed Dec 23, 2023
1 parent 5ef23da commit db81cba
Show file tree
Hide file tree
Showing 5 changed files with 179 additions and 28 deletions.
49 changes: 42 additions & 7 deletions admin/index_m.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
<!-- 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" src="scripts.js"></script>

<script type="text/javascript">
// This will be called by the admin adapter when the settings page loads
Expand Down Expand Up @@ -91,7 +90,7 @@
<div class="section">
<div class="row">
<div class="col s12">
<h6 class="translate sub-title">Authentication</h6>
<h5 class="translate sub-title">Authentication</h5>
</div>
</div>
<div class="row">
Expand Down Expand Up @@ -132,7 +131,7 @@ <h6 class="translate sub-title">Authentication</h6>
<div class="section">
<div class="row">
<div class="col s12">
<h6 class="translate sub-title">Settings</h6>
<h5 class="translate sub-title">Settings</h5>
</div>
</div>
<div class="row">
Expand All @@ -152,15 +151,51 @@ <h6 class="translate sub-title">Settings</h6>
</div>
</div>
<div class="row">
<div class="input-field col s12 m12 l12">
<input type="checkbox" class="value" id="AddRawData" />
<label for="AddRawData" class="translate">Add object with the raw JSON data</label>
<p><span class="translate">An object containing the received data as a JSON string is added to the object tree.</span></p>
<div class="section">
<div class="row">
<div class="col s12">
<h6 class="translate sub-title">Parameter data</h6>
</div>
</div>
<div class="row">
<div class="input-field col s12 m12 l6">
<input type="checkbox" class="value" id="AddData" />
<label for="AddData" class="translate">Retrieve parameter data</label>
<p><span class="translate">Parameter data will be retrieved and added to the object tree.</span></p>
</div>
<div class="input-field col s12 m12 l6">
<input type="checkbox" class="value" id="AddRawData" />
<label for="AddRawData" class="translate">Add object with the raw JSON data</label>
<p><span class="translate">An object containing the received data as a JSON string is added to the object tree.</span></p>
</div>
</div>
</div>
</div>
<div class="row">
<div class="section">
<div class="row">
<div class="col s12">
<h6 class="translate sub-title">Notifications</h6>
</div>
</div>
<div class="row">
<div class="input-field col s12 m12 l6">
<input type="checkbox" class="value" id="AddActiveNotifications" />
<label for="AddActiveNotifications" class="translate">Retrieve active notifications</label>
<p><span class="translate">Active notifications will be retrieved and added to the object tree.</span></p>
</div>
<div class="input-field col s12 m12 l6">
<input type="checkbox" class="value" id="AddRawActiveNotifications" />
<label for="AddRawActiveNotifications" class="translate">Add object with active notifications as raw JSON</label>
<p><span class="translate">An object containing the received active notifications as a JSON string is added to the object tree.</span></p>
</div>
</div>
</div>
</div>
</div>
</div>

<script type="text/javascript" src="scripts.js"></script>
<script>
var id = setInterval(function () {
clearInterval(id);
Expand Down
108 changes: 108 additions & 0 deletions admin/words.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,42 @@ systemDictionary = {
pl: 'Język nazewnictwa obiektów danych.',
'zh-cn': '命名数据对象的语言。',
},
'Parameter data': {
en: 'Parameter data',
de: 'Parameter-Daten',
ru: 'Данные о параметрах',
pt: 'Dados dos parâmetros',
nl: 'Parametergegevens',
fr: 'Données de paramètres',
it: 'Dati dei parametri',
es: 'Datos de los parámetros',
pl: 'Dane parametrów',
'zh-cn': '参数数据',
},
'Retrieve parameter data': {
en: 'Retrieve parameter data',
de: 'Parameter-Daten abrufen',
ru: 'Получение данных о параметрах',
pt: 'Recuperar dados de parâmetros',
nl: 'Parametergegevens ophalen',
fr: 'Récupérer les données des paramètres',
it: 'Recuperare i dati dei parametri',
es: 'Recuperar datos de parámetros',
pl: 'Pobieranie danych parametrów',
'zh-cn': '读取参数数据',
},
'Parameter data will be retrieved and added to the object tree.': {
en: 'Parameter data will be retrieved and added to the object tree.',
de: 'Parameter-Daten werden abgerufen und zum Objektbaum hinzugefügt.',
ru: 'Данные о параметрах будут извлечены и добавлены в дерево объектов.',
pt: 'Os dados do parâmetro serão recuperados e adicionados à árvore de objectos.',
nl: 'Parametergegevens worden opgehaald en toegevoegd aan het objectscherm.',
fr: "Les données des paramètres seront récupérées et ajoutées à l'arbre des objets.",
it: "I dati dei parametri verranno recuperati e aggiunti all'albero degli oggetti.",
es: 'Los datos de los parámetros se recuperarán y se añadirán al árbol de objetos.',
pl: 'Dane parametrów zostaną pobrane i dodane do drzewa obiektów.',
'zh-cn': '参数数据将被检索并添加到对象树中。',
},
'Add object with the raw JSON data': {
en: 'Add object with the raw JSON data',
de: 'Objekt mit den JSON-Rohdaten hinzufügen',
Expand All @@ -182,4 +218,76 @@ systemDictionary = {
pl: 'Obiekt zawierający otrzymane dane jako ciąg JSON jest dodawany do drzewa obiektów.',
'zh-cn': '一个包含接收到的 JSON 字符串数据的对象会被添加到对象树中。',
},
Notifications: {
en: 'Notifications',
de: 'Benachrichtigungen',
ru: 'Уведомления',
pt: 'Notificações',
nl: 'Meldingen',
fr: 'Notifications',
it: 'Notifiche',
es: 'Notificaciones',
pl: 'Powiadomienia',
'zh-cn': '通知',
},
'Retrieve active notifications': {
en: 'Retrieve active notifications',
de: 'Aktive Benachrichtigungen abrufen',
ru: 'Получение активных уведомлений',
pt: 'Recuperar notificações activas',
nl: 'Actieve meldingen ophalen',
fr: 'Récupérer les notifications actives',
it: 'Recuperare le notifiche attive',
es: 'Recuperar notificaciones activas',
pl: 'Pobieranie aktywnych powiadomień',
'zh-cn': '检索活动通知',
},
'Active notifications will be retrieved and added to the object tree.': {
en: 'Active notifications will be retrieved and added to the object tree.',
de: 'Aktive Benachrichtigungen werden abgerufen und dem Objektbaum hinzugefügt.',
ru: 'Активные уведомления будут извлечены и добавлены в дерево объектов.',
pt: 'As notificações activas serão recuperadas e adicionadas à árvore de objectos.',
nl: 'Actieve meldingen worden opgehaald en toegevoegd aan het objectscherm.',
fr: "Les notifications actives seront récupérées et ajoutées à l'arbre des objets.",
it: "Le notifiche attive verranno recuperate e aggiunte all'albero degli oggetti.",
es: 'Las notificaciones activas se recuperarán y se añadirán al árbol de objetos.',
pl: 'Aktywne powiadomienia zostaną pobrane i dodane do drzewa obiektów.',
'zh-cn': '活动通知将被检索并添加到对象树中。',
},
'Add object with active notifications as raw JSON': {
en: 'Add object with active notifications as raw JSON',
de: 'Objekt mit aktiven Benachrichtigungen als rohes JSON hinzufügen',
ru: 'Добавьте объект с активными уведомлениями в виде необработанного JSON',
pt: 'Adicionar objeto com notificações activas como JSON em bruto',
nl: 'Object met actieve meldingen toevoegen als onbewerkte JSON',
fr: 'Ajouter un objet contenant des notifications actives sous forme de JSON brut',
it: "Aggiungere l'oggetto con le notifiche attive come JSON grezzo",
es: 'Añadir objeto con notificaciones activas como JSON sin procesar',
pl: 'Dodaj obiekt z aktywnymi powiadomieniami jako nieprzetworzony JSON',
'zh-cn': '以原始 JSON 格式添加包含活动通知的对象',
},
'An object containing the received active notifications as a JSON string is added to the object tree.': {
en: 'An object containing the received active notifications as a JSON string is added to the object tree.',
de: 'Ein Objekt, das die empfangenen aktiven Benachrichtigungen als JSON-String enthält, wird dem Objektbaum hinzugefügt.',
ru: 'В дерево объектов добавляется объект, содержащий полученные активные уведомления в виде JSON-строки.',
pt: 'Um objeto que contém as notificações activas recebidas como uma cadeia JSON é adicionado à árvore de objectos.',
nl: 'Een object met de ontvangen actieve meldingen als een JSON-string wordt toegevoegd aan de objectboom.',
fr: "Un objet contenant les notifications actives reçues sous forme de chaîne JSON est ajouté à l'arbre des objets.",
it: "Un oggetto contenente le notifiche attive ricevute come stringa JSON viene aggiunto all'albero degli oggetti.",
es: 'Se añade al árbol de objetos un objeto que contiene las notificaciones activas recibidas en forma de cadena JSON.',
pl: 'Obiekt zawierający otrzymane aktywne powiadomienia jako ciąg JSON jest dodawany do drzewa obiektów.',
'zh-cn': '对象树中会添加一个对象,该对象以 JSON 字符串形式包含已收到的活动通知。',
},
'': {
en: '',
de: '',
ru: '',
pt: '',
nl: '',
fr: '',
it: '',
es: '',
pl: '',
'zh-cn': '',
},
};
19 changes: 6 additions & 13 deletions io-package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,7 @@
"zh-cn": "myUplink.com 适用于 Nibe 热泵"
},
"authors": ["Sebastian Haesselbarth <[email protected]>"],
"keywords": [
"myuplink",
"heat pump",
"NIBE",
"AIT",
"Cetetherm",
"ClimateMaster",
"Contura",
"CTA",
"CTC",
"Enertech Global"
],
"keywords": ["myuplink", "heat pump", "NIBE", "AIT", "Cetetherm", "ClimateMaster", "Contura", "CTA", "CTC", "Enertech Global"],
"license": "MIT",
"platform": "Javascript/Node.js",
"main": "build/main.js",
Expand Down Expand Up @@ -91,7 +80,11 @@
"AuthCode": "",
"Interval": 1,
"Language": "en",
"Configured": false
"Configured": false,
"AddData": true,
"AddRawData": false,
"AddActiveNotifications": true,
"AddRawActiveNotifications": false
},
"objects": [],
"instanceObjects": [
Expand Down
3 changes: 3 additions & 0 deletions src/lib/adapter-config.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ declare global {
Interval: number;
Language: string;
Secret: string;
AddData: boolean;
AddRawData: boolean;
AddActiveNotifications: boolean;
AddRawActiveNotifications: boolean;
}
}
}
Expand Down
28 changes: 20 additions & 8 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import * as utils from '@iobroker/adapter-core';
import * as fs from 'fs';
import * as path from 'path';
import { AuthRepository } from './authRepository';
import { Alarm } from './models/Alarm';
import { EnumValues } from './models/EnumValues';
import { ParameterData } from './models/ParameterData';
import { SystemDevice } from './models/SystemDevice';
Expand Down Expand Up @@ -255,8 +256,17 @@ class Myuplink extends utils.Adapter {
await this.setSystemDevice(dev, systemPath, accessToken);
});

const notifications = await this.myUplinkRepository?.getActiveNotifications(system.systemId, accessToken);
await createStringStateAsync(this, `${systemPath}.rawActiveNotifications`, 'Received raw JSON of active notifications', JSON.stringify(notifications, null, ''));
if (this.config.AddActiveNotifications) {
const notifications = await this.myUplinkRepository?.getActiveNotifications(system.systemId, accessToken);
if (this.config.AddRawActiveNotifications) {
await createStringStateAsync(this, `${systemPath}.rawActiveNotifications`, 'Received raw JSON of active notifications', JSON.stringify(notifications?.notifications, null, ''));
}
let notificationsDescriptions: string = '';
notifications?.notifications?.forEach((notification: Alarm) => {
notificationsDescriptions += `${notification.header}: ${notification.description}\n`;
});
await createStringStateAsync(this, `${systemPath}.activeNotifications`, 'Active notification descriptions', notificationsDescriptions);
}
}
}

Expand All @@ -277,13 +287,15 @@ class Myuplink extends utils.Adapter {
await createStringStateAsync(this, `${devPath}.serialNumber`, 'Serial Number', device.product.serialNumber);
}

const devicePoints = await this.myUplinkRepository?.getDevicePoints(device.id, accessToken);
if (this.config.AddRawData) {
await createStringStateAsync(this, `${devPath}.rawData`, 'Received raw JSON of parameter data', JSON.stringify(devicePoints, null, ''));
if (this.config.AddData) {
const devicePoints = await this.myUplinkRepository?.getDevicePoints(device.id, accessToken);
if (this.config.AddRawData) {
await createStringStateAsync(this, `${devPath}.rawData`, 'Received raw JSON of parameter data', JSON.stringify(devicePoints, null, ''));
}
devicePoints?.forEach(async (data: ParameterData) => {
await this.setParameterData(data, devPath);
});
}
devicePoints?.forEach(async (data: ParameterData) => {
await this.setParameterData(data, devPath);
});
}
}

Expand Down

0 comments on commit db81cba

Please sign in to comment.