Re: Multiple sources in one graph
Posted: Sunday 01 March 2020 18:10
Correct.EdwinK wrote: Sunday 01 March 2020 18:06 I've copy-ed the example from Sjonnie, and changed aboce line. I guess I need to change this in a variable.
Open source Home Automation System
https://forum.domoticz.com/
Correct.EdwinK wrote: Sunday 01 March 2020 18:06 I've copy-ed the example from Sjonnie, and changed aboce line. I guess I need to change this in a variable.
Going to read up on that thenclinkadink wrote: Sunday 01 March 2020 18:10Correct.EdwinK wrote: Sunday 01 March 2020 18:06 I've copy-ed the example from Sjonnie, and changed aboce line. I guess I need to change this in a variable.
You just have to change this ...
Code: Select all
blocks[grafiek_gas]Code: Select all
blocks["your_graph_name"] Code: Select all
columns[1]['blocks'] = [ "your_graph_name" ]Code: Select all
var grafiek_gas = 'graph_200';Is it possible to chose with a parameter if the sum or average calculation will be used for the GroupBy function? I think that there are lots of custom sensors where the sum of all values should be calculated instead of the average value.clinkadink wrote: Sunday 23 February 2020 20:42 The GroupBy function will either:
- The “sum” of all values together for that group
It identifies what type of sensor it is to apply to appropriate calculation.
- Provide the “average” of all values for that group
- Counter, Rain – uses the “Add’ calculation
- Temperature, Custom Sensor and Percentage – uses the “Average” calculation
Code: Select all
blocks['graph_energiekosten'] = { devices: [164, 165, 166, 167, 168], title: 'Energiekosten', graph: ['line','line','bar','bar', 'line'], datasetColors:['red','yellow','#FF8A33','#FFBD33','green'], legend: true, custom : {
"Dag": {range: 'day', data: { Gebruik: 'd.v_max_168', Netto: 'd.v_max_166', Stroom: 'd.v_max_164', Gas: 'd.v_max_165', Solar: '-d.v_max_167' } },
"Maand": {range: 'month', data: { Gebruik: 'd.v_max_168', Netto: 'd.v_max_166', Stroom: 'd.v_max_164', Gas: 'd.v_max_165', Solar: '-d.v_max_167' } },
"Jaar": {range: 'year', data: { Gebruik: 'd.v_max_168', Netto: 'd.v_max_166', Stroom: 'd.v_max_164', Gas: 'd.v_max_165', Solar: '-d.v_max_167' } } } }

Since beta 3.4.7 you can use the block parameter 'aggregate' for this, which can have value 'sum' or 'avg'.JanvdW wrote:Is it possible to chose with a parameter if the sum or average calculation will be used for the GroupBy function? I think that there are lots of custom sensors where the sum of all values should be calculated instead of the average value.clinkadink wrote: Sunday 23 February 2020 20:42 The GroupBy function will either:
- The “sum” of all values together for that group
It identifies what type of sensor it is to apply to appropriate calculation.
- Provide the “average” of all values for that group
- Counter, Rain – uses the “Add’ calculation
- Temperature, Custom Sensor and Percentage – uses the “Average” calculation
In my case I wanted to use groupBy to summarize the values per day and month for my smart meter (gas and electricity), but it seems that the average values are presented. In first instance I didn't understood why the total amounts were not in the graph, but your post explains the reason.
I had missed this info; exactly what I was looking for. Thanks!Lokonli wrote: Thursday 21 May 2020 22:53Since beta 3.4.7 you can use the block parameter 'aggregate' for this, which can have value 'sum' or 'avg'.JanvdW wrote:Is it possible to chose with a parameter if the sum or average calculation will be used for the GroupBy function? I think that there are lots of custom sensors where the sum of all values should be calculated instead of the average value.clinkadink wrote: Sunday 23 February 2020 20:42 The GroupBy function will either:
- The “sum” of all values together for that group
It identifies what type of sensor it is to apply to appropriate calculation.
- Provide the “average” of all values for that group
- Counter, Rain – uses the “Add’ calculation
- Temperature, Custom Sensor and Percentage – uses the “Average” calculation
In my case I wanted to use groupBy to summarize the values per day and month for my smart meter (gas and electricity), but it seems that the average values are presented. In first instance I didn't understood why the total amounts were not in the graph, but your post explains the reason.
Sent from my SM-A320FL using Tapatalk
Graphs with range day probably dont have a max value, only the actual measurements. If you add debug:true to the graph block definition you get a debug button via which you can check the data.JanvdW wrote:I have created a graph to display the energy costs (Euro) which are calculated by a dzvents script and stored in a set of custom sensors.Code: Select all
blocks['graph_energiekosten'] = { devices: [164, 165, 166, 167, 168], title: 'Energiekosten', graph: ['line','line','bar','bar', 'line'], datasetColors:['red','yellow','#FF8A33','#FFBD33','green'], legend: true, custom : { "Dag": {range: 'day', data: { Gebruik: 'd.v_max_168', Netto: 'd.v_max_166', Stroom: 'd.v_max_164', Gas: 'd.v_max_165', Solar: '-d.v_max_167' } }, "Maand": {range: 'month', data: { Gebruik: 'd.v_max_168', Netto: 'd.v_max_166', Stroom: 'd.v_max_164', Gas: 'd.v_max_165', Solar: '-d.v_max_167' } }, "Jaar": {range: 'year', data: { Gebruik: 'd.v_max_168', Netto: 'd.v_max_166', Stroom: 'd.v_max_164', Gas: 'd.v_max_165', Solar: '-d.v_max_167' } } } }
There are some strange things in the graph which I do not understand:
1. In the day graph no data is presented at all
2.The sum values that are displayed on top of the graph are all '0.00 Euro'
3. The month and year graphs display the correct values, but (I believe this happened after the update to v3.4.8-beta) the values in the popo-up are rounded to whole numbers. The graph itself displays the correct values.
Code: Select all
format: falseIn the latest beta I've created a little fix. You should be able to set the number of decimals via the 'decimals' block parameter.JanvdW wrote: Friday 22 May 2020 0:37 Fixed the issue with the values at the top of the graph withBut decimals are still gone.Code: Select all
format: false
One additional question: the default graph is the first one (in my case it's 'Dag'). When I want to start with the month graph I have to change the button order in month, day, year. Which works, but is somewhat illogical. Can I define the default graph without changing the button order?
Code: Select all
blocks['graph_energiekosten'] = { devices: [168, 166, 164, 165, 167], title: 'Energiekosten', graph: ['line','line','bar','bar', 'line'], datasetColors:['red','yellow','#FF8A33','#FFBD33','green'], format: false, legend: true, custom : {
"Dag": {range: 'day', debug: true, data: { Gebruik: 'd.v_168', Netto: 'd.v_166', Stroom: 'd.v_164', Gas: 'd.v_165', Solar: '-d.v_167' } },
"Maand": {range: 'month', data: { Gebruik: 'd.v_max_168', Netto: 'd.v_max_166', Stroom: 'd.v_max_164', Gas: 'd.v_max_165', Solar: '-d.v_max_167' } },
"Jaar": {range: 'year', groupBy: 'week', aggregate: 'sum', data: { Gebruik: 'd.v_max_168', Netto: 'd.v_max_166', Stroom: 'd.v_max_164', Gas: 'd.v_max_165', Solar: '-d.v_max_167' } } } }
Code: Select all
blocks['totenergy3'] = {
range:'Maand',
devices: [168, 166, 164, 165, 167],
title: 'Energiekosten',
graph: ['line', 'line', 'bar', 'bar', 'line'],
datasetColors: ['red', 'yellow', '#FF8A33', '#FFBD33', 'green'],
format: false,
legend: true,
custom: {
Dag: {
range: 'day',
debug: true,
data: {
Gebruik: 'd.v_168',
Netto: 'd.v_166',
Stroom: 'd.v_164',
Gas: 'd.v_165',
Solar: '-d.v_167',
},
},
Maand: {
range: 'month',
data: {
Gebruik: 'd.v_max_168',
Netto: 'd.v_max_166',
Stroom: 'd.v_max_164',
Gas: 'd.v_max_165',
Solar: '-d.v_max_167',
},
},
Jaar: {
range: 'year',
groupBy: 'week',
aggregate: 'sum',
data: {
Gebruik: 'd.v_max_168',
Netto: 'd.v_max_166',
Stroom: 'd.v_max_164',
Gas: 'd.v_max_165',
Solar: '-d.v_max_167',
},
},
},
};

Domoticz sends/stores the graph data with some delay, normally every 5 minutes. Dashticz requests the graph data with a certain interval. This will give some additional delay.JanvdW wrote: Monday 22 June 2020 19:57 I noticed that there's a difference between the numbers in the graph and the numbers at the top as visualized in the graph below. I don't know why this happens. It seems that the numbers in the graph are lacking behind
![]()
Code: Select all
blocks['graph_gas_gebruik'] = { range: 'Maand', devices: [127,63], title: 'Gasgebruik', graph: ['line','bar'], datasetColors: ['yellow','red',], legend: false, beginAtZero: [false, true] ,custom: {
"Dag": { range: 'day', data: { Temperatuur: 'd.te_63', Gas: 'd.v_127/12' } },
"Maand": { range: 'month', data: { Temperatuur: 'd.te_63', Gas: 'd.v_127', } },
"Jaar": { range: 'year', groupBy: 'month', aggregate: 'sum', data: { Temperatuur: 'd.te_63/30', Gas: 'd.v_127' } } } }