Skip to content

Commit

Permalink
Add option for adding raw data
Browse files Browse the repository at this point in the history
  • Loading branch information
sebilm committed Dec 22, 2023
1 parent 7d6e578 commit 0fe6b51
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 3 deletions.
7 changes: 7 additions & 0 deletions admin/index_m.html
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,13 @@ <h6 class="translate sub-title">Settings</h6>
<span class="translate">The language for naming the data objects.</span>
</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>
</div>
</div>
</div>

Expand Down
24 changes: 24 additions & 0 deletions admin/words.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,4 +158,28 @@ systemDictionary = {
pl: 'Język nazewnictwa obiektów danych.',
'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',
ru: 'Добавьте объект с необработанными данными JSON',
pt: 'Adicionar objeto com os dados JSON em bruto',
nl: 'Object toevoegen met de ruwe JSON-gegevens',
fr: 'Ajouter un objet avec les données JSON brutes',
it: 'Aggiungere un oggetto con i dati JSON grezzi',
es: 'Añadir objeto con los datos JSON sin procesar',
pl: 'Dodaj obiekt z nieprzetworzonymi danymi JSON',
'zh-cn': '添加包含原始 JSON 数据的对象',
},
'An object containing the received data as a JSON string is added to the object tree.': {
en: 'An object containing the received data as a JSON string is added to the object tree.',
de: 'Ein Objekt, das die empfangenen Daten als JSON-String enthält, wird dem Objektbaum hinzugefügt.',
ru: 'Объект, содержащий полученные данные в виде строки JSON, добавляется в дерево объектов.',
pt: 'Um objeto que contém os dados recebidos como uma cadeia JSON é adicionado à árvore de objectos.',
nl: 'Een object met de ontvangen gegevens als een JSON-string wordt toegevoegd aan het objectscherm.',
fr: "Un objet contenant les données reçues sous forme de chaîne JSON est ajouté à l'arbre des objets.",
it: "Un oggetto contenente i dati ricevuti come stringa JSON viene aggiunto all'albero degli oggetti.",
es: 'Se añade al árbol de objetos un objeto que contiene los datos recibidos como cadena JSON.',
pl: 'Obiekt zawierający otrzymane dane jako ciąg JSON jest dodawany do drzewa obiektów.',
'zh-cn': '一个包含接收到的 JSON 字符串数据的对象会被添加到对象树中。',
},
};
4 changes: 3 additions & 1 deletion build/main.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion build/main.js.map

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/lib/adapter-config.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ declare global {
Interval: number;
Language: string;
Secret: string;
AddRawData: boolean;
}
}
}
Expand Down
4 changes: 3 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,9 @@ class Myuplink extends utils.Adapter {
}

const devicePoints = await this.myUplinkRepository?.getDevicePoints(device.id, accessToken);
await createStringStateAsync(this, `${devPath}.rawData`, 'Received raw JSON of parameter data', JSON.stringify(devicePoints, null, ''));
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);
});
Expand Down

0 comments on commit 0fe6b51

Please sign in to comment.