Multiple sources in one graph

Dashticz, alternative dashboard based on HTML, CSS, jQuery

Moderators: leecollings, htilburgs, robgeerts

User avatar
clinkadink
Posts: 417
Joined: Tuesday 31 December 2019 1:15
Target OS: Linux
Domoticz version: 2020.2
Location: Swindon, UK
Contact:

Re: Multiple sources in one graph

Post by clinkadink »

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.
Correct.
"UI is the saddle, the stirrups, & the reins. UX is the feeling you get being able to ride the horse."
User avatar
EdwinK
Posts: 1820
Joined: Sunday 22 January 2017 21:46
Target OS: Raspberry Pi / ODroid
Domoticz version: BETA
Location: Rhoon
Contact:

Re: Multiple sources in one graph

Post by EdwinK »

clinkadink wrote: Sunday 01 March 2020 18:10
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.
Correct.
Going to read up on that then
Running latest BETA on a Pi-3 | Toon® Thermostat (rooted) | Hue | Tuya | IKEA tradfri | Dashticz V3 on Lenovo Huawei Tablet | Conbee
User avatar
clinkadink
Posts: 417
Joined: Tuesday 31 December 2019 1:15
Target OS: Linux
Domoticz version: 2020.2
Location: Swindon, UK
Contact:

Re: Multiple sources in one graph

Post by clinkadink »

EdwinK wrote: Sunday 01 March 2020 18:25 Going to read up on that then
You just have to change this ...

Code: Select all

blocks[grafiek_gas]
To this ... with quotes ...

Code: Select all

blocks["your_graph_name"] 
Then add this to the column ...

Code: Select all

columns[1]['blocks'] = [ "your_graph_name" ]
"UI is the saddle, the stirrups, & the reins. UX is the feeling you get being able to ride the horse."
User avatar
Sjonnie2017
Posts: 364
Joined: Wednesday 02 August 2017 19:43
Target OS: Linux
Domoticz version: Latest ß
Location: The Netherlands
Contact:

Re: Multiple sources in one graph

Post by Sjonnie2017 »

I am sorry that my somewhat strange way of defining blocks causes you problems.

Maybe this will help:

At the start of the config.js I define all my blocks. So for the "grafiek_gas" I have:

Code: Select all

var grafiek_gas                = 'graph_200';
Not sure if this will help but worth a try :)

Greetz,

Sjonnie
ConBee II - TRÅDFRI lights + switches, loads of ChingLing dimmers and switches, Heiman and Xiaomi sensors
SolarEdge SE4000H (with active modbus_tcp)
YouLess Energy meter
Shelly 2.5 in roller shutter mode
Janco
Posts: 17
Joined: Monday 25 April 2016 10:27
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Multiple sources in one graph

Post by Janco »

Something I noted when experimenting with multiple sources in one graph: They tend to be very slow in loading on Android.

On MacOS and iOS there is hardly any speed loss, but on Android devices (phone and tablet) they can take up to thirty seconds to load (independent of the browser choice). While loading, the interface is completely frozen. Even the clock doesn't run.

Does anyone has any clue as to what could be the issue here?
JanvdW
Posts: 118
Joined: Saturday 21 December 2019 8:36
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Multiple sources in one graph

Post by JanvdW »

clinkadink wrote: Sunday 23 February 2020 20:42 The GroupBy function will either:
  • The “sum” of all values together for that group
  • Provide the “average” of all values for that group
It identifies what type of sensor it is to apply to appropriate calculation.
  • Counter, Rain – uses the “Add’ calculation
  • Temperature, Custom Sensor and Percentage – uses the “Average” calculation
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.

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.
JanvdW
Posts: 118
Joined: Saturday 21 December 2019 8:36
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Multiple sources in one graph

Post by JanvdW »

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' } } } }
Image

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.
Lokonli
Posts: 2287
Joined: Monday 29 August 2016 22:40
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Multiple sources in one graph

Post by Lokonli »

JanvdW wrote:
clinkadink wrote: Sunday 23 February 2020 20:42 The GroupBy function will either:
  • The “sum” of all values together for that group
  • Provide the “average” of all values for that group
It identifies what type of sensor it is to apply to appropriate calculation.
  • Counter, Rain – uses the “Add’ calculation
  • Temperature, Custom Sensor and Percentage – uses the “Average” calculation
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.

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.
Since beta 3.4.7 you can use the block parameter 'aggregate' for this, which can have value 'sum' or 'avg'.

Sent from my SM-A320FL using Tapatalk

JanvdW
Posts: 118
Joined: Saturday 21 December 2019 8:36
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Multiple sources in one graph

Post by JanvdW »

Lokonli wrote: Thursday 21 May 2020 22:53
JanvdW wrote:
clinkadink wrote: Sunday 23 February 2020 20:42 The GroupBy function will either:
  • The “sum” of all values together for that group
  • Provide the “average” of all values for that group
It identifies what type of sensor it is to apply to appropriate calculation.
  • Counter, Rain – uses the “Add’ calculation
  • Temperature, Custom Sensor and Percentage – uses the “Average” calculation
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.

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.
Since beta 3.4.7 you can use the block parameter 'aggregate' for this, which can have value 'sum' or 'avg'.

Sent from my SM-A320FL using Tapatalk
I had missed this info; exactly what I was looking for. Thanks!
Lokonli
Posts: 2287
Joined: Monday 29 August 2016 22:40
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Multiple sources in one graph

Post by Lokonli »

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' } } } }
Image

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.
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.

Ill check the decimals.

Sent from my SM-A320FL using Tapatalk

Lokonli
Posts: 2287
Joined: Monday 29 August 2016 22:40
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Multiple sources in one graph

Post by Lokonli »

Probably you have to add the block parameter 'decimals'

Sent from my SM-A320FL using Tapatalk

JanvdW
Posts: 118
Joined: Saturday 21 December 2019 8:36
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Multiple sources in one graph

Post by JanvdW »

Fixed the issue with the values at the top of the graph with

Code: Select all

format: false
But decimals are still gone.

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?
Lokonli
Posts: 2287
Joined: Monday 29 August 2016 22:40
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Multiple sources in one graph

Post by Lokonli »

JanvdW wrote: Friday 22 May 2020 0:37 Fixed the issue with the values at the top of the graph with

Code: Select all

format: false
But decimals are still gone.

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?
In the latest beta I've created a little fix. You should be able to set the number of decimals via the 'decimals' block parameter.
See:
https://dashticz.readthedocs.io/en/beta ... st-changes

You can change the default graph by setting the 'range' parameter, which can be 'last', 'day' or 'month', or one of the custom graph names you have defined.
JanvdW
Posts: 118
Joined: Saturday 21 December 2019 8:36
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Multiple sources in one graph

Post by JanvdW »

Thanks for the update: that fixes the decimal issue!

I don't understand how I can change the default graph with the range parameter, without changing the button order. I have now the following code:

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' } } } }
What do I need to change to make the month graph the default one?
Lokonli
Posts: 2287
Joined: Monday 29 August 2016 22:40
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Multiple sources in one graph

Post by Lokonli »

By adding range:'Maand' to the block definition, like this:

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',
        },
      },
    },
  };
JanvdW
Posts: 118
Joined: Saturday 21 December 2019 8:36
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Multiple sources in one graph

Post by JanvdW »

Super; this works; thanks!
JanvdW
Posts: 118
Joined: Saturday 21 December 2019 8:36
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Multiple sources in one graph

Post by JanvdW »

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
Image
Lokonli
Posts: 2287
Joined: Monday 29 August 2016 22:40
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Multiple sources in one graph

Post by Lokonli »

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
Image
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.

The numbers in the top are the actual data, which are updated almost instantaneous.
JanvdW
Posts: 118
Joined: Saturday 21 December 2019 8:36
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Multiple sources in one graph

Post by JanvdW »

I have some problems with one of my graphs. This graph displays the gas usage (bar) and the outside temperature (line) to see the correlation between gas usage and outside temperature. I work with the latest Domoticz (2020.2 (build 12705)) and Dashticz (3.7.1) versions. This is the block definition in Dashticz:

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' } } } }
1. The value for 'd.te_63' is shown till November 29th, but starting from the 30th nothing is shown for temperature. In Domoticz the correct value is still there... So, I am lost.

2. For the day graph the gas value is far to high. When I divide this value by 12, it gives more or less the right value. I don't understand the reason why this happens.

3. For the year value I have used the aggregate parameter, but I can't choose for different operations per dataset. For the short term I have chosen to sum the values (which is right for gas) and divide the temp value by 30. I would like to choose the aggregate parameter per dataset. Is that possible?
Lokonli
Posts: 2287
Joined: Monday 29 August 2016 22:40
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Multiple sources in one graph

Post by Lokonli »

1)
Is that the case for all three graph types? (dag, maand, jaar)

2) That is indeed a bug.
Should be fixed in latest beta. Could you check?

It relates how data is requested from Domoticz for usage devices which are updated with a low frequency (like gas).
Other device types may be impacted as well (water usage?)

3)
I'll add an option to set aggregation per dataset.
Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 1 guest