Skip to content

Commit

Permalink
v3.34.3
Browse files Browse the repository at this point in the history
  • Loading branch information
jemu75 committed Jul 9, 2022
1 parent 01a1117 commit d81a359
Show file tree
Hide file tree
Showing 42 changed files with 201 additions and 67 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -885,7 +885,7 @@ Da *Cam* kein Standard-Template ist, könnt ihr nur ausgewählte Eigenschaften
```
"setup": {
"size": "col-12 col-md-6 col-lg-6",
"source": "<stream_url>"
"source": ["reading:value:url"],
"status": {
"bar": ["reading:value:level:color"]
},
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "fhemapp",
"version": "3.34.2",
"version": "3.34.3",
"private": true,
"author": "jemu75",
"scripts": {
Expand Down
5 changes: 5 additions & 0 deletions public/cfg/config.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
{
"connection": {
"location": "http://fhem",
"port": "8083",
"path": "fhem"
},
"options": {
"maxChartPoints": 100,
"logBuffer": 500
Expand Down
2 changes: 1 addition & 1 deletion public/cfg/templ_shellyrgb_mqtt.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
{
"leftBtn": "mdi-lightbulb-outline",
"leftClick": ["gain::gain 0"],
"slider": ["gain::gain %v:%n:0:100"],
"slider": ["gain::gain %v:%n:0:100:1"],
"text": "Helligkeit",
"rightBtn": "mdi-lightbulb-on-outline",
"rightClick": ["gain::gain 100"]
Expand Down
17 changes: 9 additions & 8 deletions public/cfg/templ_water.json
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,28 +1,29 @@
{
"name": "water",
"author": "jemu75",
"date": "2021-06-14",
"date": "2022-06-26",
"status": {
"bar": ["state:on:100:success","state:off:0:success"],
"error": ["Connected.receiver.Readings.Activity.Value:^(?!alive):100:error:keine Verbindung"]
},
"main": [
{
"text": ["timedOn:running:läuft...","Connected.weekdaytimer.Attributes.disable:1:manuell","Connected.weekdaytimer.Attributes.comment::%s","state:off:aus"],
"rightBtn": "mdi-timer-outline",
"rightMenu": ["aus:off","15 Minuten:on-for-timer 900","30 Minuten:on-for-timer 1800","45 Minuten:on-for-timer 2700","60 Minuten:on-for-timer 3600","automatich:set Connected.weekdaytimer enable","manuell:set Connected.weekdaytimer disable"]
},
{
"leftBtn": "mdi-power-off",
"leftClick": ["state::off"],
"text": ["state:on:an","state:off:aus","state::%s"],
"rightBtn": "mdi-power-on",
"rightClick": ["state::on"]
},
{
"text": ["timedOn:running:läuft...","timedOn::aus"],
"rightBtn": "mdi-timer-outline",
"rightMenu": ["15 Minuten:on-for-timer 900","30 Minuten:on-for-timer 1800","60 Minuten:on-for-timer 3600"]
}
],
"info": {
"left1": ["state:off::mdi-water-off","state:on::mdi-watering-can"],
"left2": ["timedOn:running::mdi-timer-outline"],
"mid1": ["Readings.trigLast.Time::%t"]
"left2": ["Connected.weekdaytimer.Attributes.disable:1::","Connected.weekdaytimer.Attributes.disable:0::mdi-calendar-clock"],
"mid1": ["Readings.trigLast.Time::%t"],
"right2": ["timedOn:running::mdi-timer-outline"]
}
}
28 changes: 28 additions & 0 deletions public/cfg/templ_waterfall.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"name": "waterfall",
"author": "jemu75",
"date": "2022-06-27",
"status": {
"bar": ["state:on:100:success","state:off:0:success"],
"error": ["Connected.receiver.Readings.Activity.Value:^(?!alive):100:error:keine Verbindung"]
},
"main": [
{
"text": ["timedOn:running:läuft...","state:off:aus"],
"rightBtn": "mdi-timer-outline",
"rightMenu": ["aus:off","15 Minuten:on-for-timer 900","30 Minuten:on-for-timer 1800","45 Minuten:on-for-timer 2700","60 Minuten:on-for-timer 3600"]
},
{
"leftBtn": "mdi-power-off",
"leftClick": ["state::off"],
"text": ["state:on:an","state:off:aus","state::%s"],
"rightBtn": "mdi-power-on",
"rightClick": ["state::on"]
}
],
"info": {
"left1": ["state:off::mdi-water-off","state:on::mdi-watering-can"],
"mid1": ["Readings.trigLast.Time::%t"],
"right2": ["timedOn:running::mdi-timer-outline"]
}
}
4 changes: 3 additions & 1 deletion src/components/TemplCam.vue
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,9 @@
created() {
this.app.options = this.$fhem.app.options;
this.size = this.$fhem.getEl(this.item, 'Options', 'setup', 'size') || 'col-12 col-sm-12 col-md-6 col-lg-4';
this.source = this.$fhem.getEl(this.item, 'Options', 'setup', 'source') || '';
let srcUrl = this.$fhem.handleVals(this.item, this.$fhem.getEl(this.item, 'Options', 'setup', 'source') || '');
this.source = srcUrl[0];
if(this.$route.params.filter && this.$route.params.filter.match('&size=max')) {
this.maxSize = true;
Expand Down
3 changes: 2 additions & 1 deletion src/components/TemplDefault.vue
Original file line number Diff line number Diff line change
Expand Up @@ -590,9 +590,10 @@
this.main[lvl].sliderPrevent = true;
let cmd = this.createCmd(param[0]);
let decimal = (param[4] && param[4].match('.')) ? 1 : 0;
let decimal = (param[4] && param[4].match('\\.')) ? 1 : 0;
cmd = cmd.replace('%v', val.toFixed(decimal));
this.sendCmd(cmd);
}
}
Expand Down
67 changes: 55 additions & 12 deletions src/components/TemplWdTimer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,32 @@

<div v-if="item.Options.status.isActive">
<v-card-text>
<v-row align="center">
<v-col align="center">
<div class="headline font-weight-bold">
{{ text }}
</div>
</v-col>
</v-row>
</v-card-text>
<v-card-text class="pa-0">
<v-row v-if="expanded" align="center">
<v-col>
<v-expansion-panels accordion focusable flat>
<v-expansion-panel
v-for="(profile,i) in defs.profiles"
:key="i"
>
<v-expansion-panel-header color="secondary">
{{ profile.time }}
</v-expansion-panel-header>
<v-expansion-panel-content>
{{ profile.weekdays }}
</v-expansion-panel-content>
</v-expansion-panel>
</v-expansion-panels>
</v-col>
</v-row>
</v-card-text>
</div>

Expand Down Expand Up @@ -127,14 +153,18 @@
status: {
color: 'success',
level: 0
},
},
text: '',
app: {
options: {
debugMode: false
}
},
setup: {
defs: {
device: null,
globalWeekdays: null,
lang: null,
profiles: []
}
}),
Expand All @@ -143,19 +173,13 @@
immediate: true,
deep: true,
handler() {
//this.doList();
}
}
},
created() {
let setup = this.iconSet = this.$fhem.getEl(this.item, 'Options','setup');
this.app.options = this.$fhem.app.options;
if(this.$fhem.getEl(this.item, 'Options', 'setup', 'expanded')) this.expand();
if(setup) {
// achtung hier noch differenzieren!
this.setup = setup;
}
this.loadDefs();
},
Expand All @@ -171,10 +195,29 @@
},
loadDefs() {
this.defs = {
device: null,
globalWeekdays: null,
lang: null,
profiles: []
};
if(this.$fhem.getEl(this.item, 'Internals', 'TYPE') === 'WeekdayTimer') {
let def = this.$fhem.getEl(this.item, 'Internals', 'DEF') || '';
let defs = def.split(' ');
console.log(defs);
let defs = this.$fhem.getEl(this.item, 'Internals', 'DEF').split(' ');
if(defs.length > 1) {
for(var [idx, def] of defs.entries()) {
if(idx === 0) this.defs.device = def;
if(idx > 0 && /^[0-8]*$/.test(def)) this.defs.globalWeekdays = def;
if(idx > 0 && /^de|en|fr|nl$/.test(def)) this.defs.lang = def;
if(idx > 0 && /\|/.test(def)) {
let defParts = def.split('|');
let defPart = {};
if(/:|^{*}$/.test(defParts[0])) defParts.unshift(this.defs.globalWeekdays || '0123456');
if(defParts.length > 2) defPart = { weekdays: defParts[0].split(''), time: new Date('1900-01-01T' + defParts[1]), cmd: defParts[2] };
this.defs.profiles.push(defPart);
}
}
}
} else {
this.$fhem.log({ lvl: 1, msg: 'Template is not a FHEM-WeekdayTimer.', meta: this.item });
}
Expand Down
43 changes: 34 additions & 9 deletions src/plugins/fhem.js
Original file line number Diff line number Diff line change
Expand Up @@ -476,28 +476,52 @@ class Fhem extends EventEmitter {
}

// subFunction for readLogFile() - split timestamp and value and reduce data if large array
handleLogData(data) {
handleLogData(data, calc) {
let items = data.split('\n');
if(items.length > 3) items.splice(-3, 3);
let result = [];
let steps = items.length > this.app.options.maxChartPoints ? parseInt(items.length / this.app.options.maxChartPoints) : 1; // important for performance
let nextStep = steps;
let sumVal = 0;
let sumVal = null;
let idx = 1;
let lastTs = null;

for(const item of items) {
let itemPart = item.split(' ');
let timestamp = Date.parse(itemPart[0].replace('_','T'));
let ts = new Date(timestamp);
let calcTs = null;
let value = parseFloat(itemPart[1]);

sumVal += value;
if(calc) {
if(/-min/.test(calc) && (sumVal > value || !sumVal)) sumVal = value;
if(/-max/.test(calc) && sumVal < value) sumVal = value;
if(/-avg/.test(calc)) sumVal = (sumVal + value) / 2;
if(/-delta/.test(calc) && !sumVal) sumVal = value;

if(idx >= nextStep || idx === items.length) {
if(idx === items.length) steps = steps - (nextStep - idx);
if(/hour-/.test(calc)) calcTs = new Date(ts.getFullYear() +'-' + (ts.getMonth() + 1) + '-' + ts.getDate()).setHours(ts.getHours());
if(/day-/.test(calc)) calcTs = new Date(ts.getFullYear() +'-' + (ts.getMonth() + 1) + '-' + ts.getDate()).setHours(12);
if(/week-/.test(calc)) calcTs = new Date(ts.getFullYear() +'-' + (ts.getMonth() + 1) + '-' + ts.getDate()).setDate(ts.getDate() - ts.getDay() + 3);
if(/month-/.test(calc)) calcTs = new Date(ts.getFullYear() +'-' + (ts.getMonth() + 1) + '-1');
if(/year-/.test(calc)) calcTs = new Date(ts.getFullYear() + '-1-1');

result.push({ timestamp, value: sumVal / steps });
nextStep += steps;
sumVal = 0;
if(!lastTs) lastTs = calcTs;

if(calcTs > lastTs || idx === items.length) {
result.push({ timestamp: lastTs, value: sumVal });
sumVal = null;
lastTs = calcTs;
}
} else {
sumVal += value;

if(idx >= nextStep || idx === items.length) {
if(idx === items.length) steps = steps - (nextStep - idx);

result.push({ timestamp, value: sumVal / steps });
nextStep += steps;
sumVal = 0;
}
}

idx ++;
Expand Down Expand Up @@ -527,8 +551,9 @@ class Fhem extends EventEmitter {
cmd += select ? ' ' + select[0].replace(/\(|\)/g,'') : ' 4:' + defPart[1];

let logData = await this.request([{ param: 'cmd', value: cmd }, { param: 'XHR', value: '1' }],'text', { id: idx });
let calc = defPart[11] ? defPart[11] : null;

if(logData) data.push({ id: logData.id, data: this.handleLogData(await logData.data) });
if(logData) data.push({ id: logData.id, data: this.handleLogData(await logData.data, calc) });

idx ++;
}
Expand Down
2 changes: 1 addition & 1 deletion www/fhemapp/cfg/templ_shellyrgb_mqtt.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
{
"leftBtn": "mdi-lightbulb-outline",
"leftClick": ["gain::gain 0"],
"slider": ["gain::gain %v:%n:0:100"],
"slider": ["gain::gain %v:%n:0:100:1"],
"text": "Helligkeit",
"rightBtn": "mdi-lightbulb-on-outline",
"rightClick": ["gain::gain 100"]
Expand Down
17 changes: 9 additions & 8 deletions www/fhemapp/cfg/templ_water.json
Original file line number Diff line number Diff line change
@@ -1,28 +1,29 @@
{
"name": "water",
"author": "jemu75",
"date": "2021-06-14",
"date": "2022-06-26",
"status": {
"bar": ["state:on:100:success","state:off:0:success"],
"error": ["Connected.receiver.Readings.Activity.Value:^(?!alive):100:error:keine Verbindung"]
},
"main": [
{
"text": ["timedOn:running:läuft...","Connected.weekdaytimer.Attributes.disable:1:manuell","Connected.weekdaytimer.Attributes.comment::%s","state:off:aus"],
"rightBtn": "mdi-timer-outline",
"rightMenu": ["aus:off","15 Minuten:on-for-timer 900","30 Minuten:on-for-timer 1800","45 Minuten:on-for-timer 2700","60 Minuten:on-for-timer 3600","automatich:set Connected.weekdaytimer enable","manuell:set Connected.weekdaytimer disable"]
},
{
"leftBtn": "mdi-power-off",
"leftClick": ["state::off"],
"text": ["state:on:an","state:off:aus","state::%s"],
"rightBtn": "mdi-power-on",
"rightClick": ["state::on"]
},
{
"text": ["timedOn:running:läuft...","timedOn::aus"],
"rightBtn": "mdi-timer-outline",
"rightMenu": ["15 Minuten:on-for-timer 900","30 Minuten:on-for-timer 1800","60 Minuten:on-for-timer 3600"]
}
],
"info": {
"left1": ["state:off::mdi-water-off","state:on::mdi-watering-can"],
"left2": ["timedOn:running::mdi-timer-outline"],
"mid1": ["Readings.trigLast.Time::%t"]
"left2": ["Connected.weekdaytimer.Attributes.disable:1::","Connected.weekdaytimer.Attributes.disable:0::mdi-calendar-clock"],
"mid1": ["Readings.trigLast.Time::%t"],
"right2": ["timedOn:running::mdi-timer-outline"]
}
}
28 changes: 28 additions & 0 deletions www/fhemapp/cfg/templ_waterfall.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"name": "waterfall",
"author": "jemu75",
"date": "2022-06-27",
"status": {
"bar": ["state:on:100:success","state:off:0:success"],
"error": ["Connected.receiver.Readings.Activity.Value:^(?!alive):100:error:keine Verbindung"]
},
"main": [
{
"text": ["timedOn:running:läuft...","state:off:aus"],
"rightBtn": "mdi-timer-outline",
"rightMenu": ["aus:off","15 Minuten:on-for-timer 900","30 Minuten:on-for-timer 1800","45 Minuten:on-for-timer 2700","60 Minuten:on-for-timer 3600"]
},
{
"leftBtn": "mdi-power-off",
"leftClick": ["state::off"],
"text": ["state:on:an","state:off:aus","state::%s"],
"rightBtn": "mdi-power-on",
"rightClick": ["state::on"]
}
],
"info": {
"left1": ["state:off::mdi-water-off","state:on::mdi-watering-can"],
"mid1": ["Readings.trigLast.Time::%t"],
"right2": ["timedOn:running::mdi-timer-outline"]
}
}
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit d81a359

Please sign in to comment.