Skip to content

Commit

Permalink
Fixed mydata DIY - fixes klein0r#34
Browse files Browse the repository at this point in the history
  • Loading branch information
klein0r committed Jan 28, 2021
1 parent 4ba9ee1 commit 1d258a1
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class LaMetric extends utils.Adapter {
this.refreshStateTimeout = null;
this.refreshAppTimeout = null;

this.myDataDiyRegex = /\{([_a-zA-Z0-9\.#]+)\}/g;
this.myDataDiyForeignStates = [];

this.on('ready', this.onReady.bind(this));
Expand Down Expand Up @@ -907,7 +908,7 @@ class LaMetric extends utils.Adapter {
// Collect all IDs in texts
frames.forEach(f => {
f.text.replace(
/\{([_a-zA-Z0-9\.]+)\}/g,
this.myDataDiyRegex,
(m, id) => {
if (foreignStates.indexOf(id) === -1) {
foreignStates.push(id);
Expand Down Expand Up @@ -958,7 +959,7 @@ class LaMetric extends utils.Adapter {
const clonedFrames = JSON.parse(JSON.stringify(this.config.mydatadiy)); // TODO: Better way to clone?!
const newFrames = clonedFrames.map(f => {
f.text = f.text.replace(
/\{([_a-zA-Z0-9\.]+)\}/g,
this.myDataDiyRegex,
(m, id) => {
this.log.debug('My Data (DIY) replacing {' + id + '} in frame');

Expand Down

0 comments on commit 1d258a1

Please sign in to comment.