Page 14 of 15

Re: Multiple sources in one graph

Posted: Sunday 20 December 2020 23:23
by Lokonli
JanvdW wrote: Saturday 19 December 2020 21:20 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?
3.
Implemented in latest beta. Define aggregate as an array as follows:

Code: Select all

   aggregate: ['avg', 'sum']
Can you test?

Re: Multiple sources in one graph

Posted: Monday 21 December 2020 8:55
by JanvdW
1. My conclusion that recent data for the outside temperature is in Domoticz was wrong. I concluded this because I saw the value in Dashticz and Domoticz, but it appeared to be the value of 30 November; sorry for that :roll:. I found a similar problem, which solved the issue.
2. You're right: it's solved. Great!
3. The aggregate parameter doesn't work as expected when two values are defined. With ['avg', 'sum'], the temp value is correct, but gas usage looks like it's the average value. I experimented with the options and it's a kind of weird: when I define two values for the aggregate parameter it shows always the avg value for both datasets. So, ['sum', 'sum'] or ['avg', 'sum'] or ['sum', 'avg'] doesn't make any difference for the result.

I have two additional questions about graphs:
4. My solar device in Domoticz holds two datasets: energieverbruik (which is the generated power) and power usage. Power usage has a stable value of 1. During dark or cloudy hours energieverbruik is zero and (just during these times) my day graph shows bars with value 1, instead of 0. The month and year graphs don't have this problem: they show the value 0, as expected.
5. Finally a feature request: the GroupBy function can group data by hour, day, week or month. It would be nice to be able to group data by year as well.

Re: Multiple sources in one graph

Posted: Monday 11 January 2021 19:03
by JanvdW
@lokonli, did I describe the issue/ status clear enough?

Re: Multiple sources in one graph

Posted: Monday 11 January 2021 19:26
by Lokonli
3)
Can you post your graph block definition. I'll test.

4) Do you see the same in Domoticz, or is it only a Dashticz issue?
Can you add a debug button, and post the debug graph data (within a spoiler block), for the day graph as well as the month graph.

5)
I'll add that to the feature request list.

Re: Multiple sources in one graph

Posted: Monday 11 January 2021 19:37
by Lokonli
3)
I've checked this one: It's a bug.
I'll create a fix.

Re: Multiple sources in one graph

Posted: Monday 11 January 2021 20:10
by JanvdW
This is a Dashticz problem: the bar pattern in the Dashticz day graph is compliant with the Domoticz 'Power Usage' graph and the Dashticz month graph is compliant with the Domoticz 'Energieverbruik' graph (which is generated power).

Current debug graph data is:

Code: Select all

{
  "mountPoint": "#block_100",
  "block": {
    "width": 12,
    "datasetColors": [
      "green"
    ],
    "axisRight": false,
    "axisAlternate": true,
    "barWidth": 0.9,
    "beginAtZero": true,
    "borderDash": [],
    "borderWidth": 2,
    "buttonsBorder": "white",
    "buttonsColor": "black",
    "buttonsFill": "white",
    "buttonsIcon": "#686868",
    "buttonsMarginX": 2,
    "buttonsMarginY": 0,
    "buttonsPadX": 6,
    "buttonsPadY": 2,
    "buttonsRadius": 0,
    "buttonsShadow": false,
    "buttonsSize": 14,
    "buttonsText": false,
    "cartesian": "linear",
    "custom": {
      "Dag": {
        "range": "day",
        "filter": "18 hours",
        "data": {
          "Vermogen": "d.v_23"
        }
      },
      "Maand": {
        "range": "month",
        "data": {
          "Vermogen": "d.v_23"
        }
      },
      "Jaar": {
        "range": "year",
        "groupBy": "month",
        "aggregate": "sum",
        "data": {
          "Vermogen": "d.v_23"
        }
      }
    },
    "customHeader": false,
    "debugButton": true,
    "displayFormats": false,
    "drawOrderDay": false,
    "drawOrderLast": false,
    "drawOrderMonth": false,
    "flash": false,
    "fontColor": "white",
    "format": true,
    "gradients": false,
    "graph": "bar",
    "graphTypes": false,
    "groupBy": false,
    "groupByDevice": false,
    "height": false,
    "iconColour": "grey",
    "interval": 1,
    "legend": false,
    "lineFill": false,
    "lineTension": 0.1,
    "maxTicksLimit": null,
    "method": 1,
    "pointBorderColor": [
      "grey"
    ],
    "pointBorderWidth": 0,
    "pointRadius": 0,
    "pointStyle": false,
    "range": "Maand",
    "refresh": 300,
    "reverseTime": false,
    "sortDevices": false,
    "spanGaps": false,
    "stacked": false,
    "title": "Vermogen",
    "tooltiptotal": false,
    "zoom": false,
    "devices": [
      23
    ],
    "key": "graph_23"
  },
  "key": "graph_23",
  "name": "graph",
  "graphDevices": [
    {
      "AddjMulti": 1,
      "AddjMulti2": 1,
      "AddjValue": 0,
      "AddjValue2": 0,
      "BatteryLevel": 255,
      "CounterToday": "0.210 kWh",
      "CustomImage": 0,
      "Data": "4229.994 kWh",
      "Description": "",
      "EnergyMeterMode": "",
      "Favorite": 0,
      "HardwareDisabled": false,
      "HardwareID": 4,
      "HardwareName": "PVOutput import",
      "HardwareType": "PVOutput (Input)",
      "HardwareTypeVal": 30,
      "HaveTimeout": false,
      "ID": "00000001",
      "LastUpdate": "2021-01-11 19:55:23",
      "Name": "PVOutput SolarMain",
      "Notifications": "false",
      "PlanID": "0",
      "PlanIDs": [
        0
      ],
      "Protected": false,
      "ShowNotifications": true,
      "SignalLevel": "-",
      "SubType": "kWh",
      "SwitchTypeVal": 0,
      "Timers": "false",
      "Type": "General",
      "TypeImg": "current",
      "Unit": 1,
      "Usage": "0 Watt",
      "Used": 1,
      "XOffset": "0",
      "YOffset": "0",
      "idx": 23,
      "currentValue": "0,21 kWh",
      "name": "PVOutput SolarMain",
      "sensor": "counter",
      "subtype": "kWh",
      "title": "PVOutput SolarMain",
      "txtUnit": "kWh",
      "txtUnits": [],
      "type": "General",
      "decimals": 2,
      "method": 1
    }
  ],
  "decimals": 2,
  "graphIdx": "block_100",
  "lastRefreshTime": 1610391428,
  "range": "month",
  "title": "Vermogen",
  "params": [
    "type=graph&sensor=counter&idx=23&range=month&method=1"
  ],
  "subtype": "kWh",
  "txtUnits": [
    "kWh"
  ],
  "data": {
    "result": [
      {
        "c_23": "4215.175",
        "d": "2020-12-11",
        "v_23": "0.020"
      },
      {
        "c_23": "4215.195",
        "d": "2020-12-12",
        "v_23": "0.088"
      },
      {
        "c_23": "4215.283",
        "d": "2020-12-13",
        "v_23": "0.010"
      },
      {
        "c_23": "4215.293",
        "d": "2020-12-14",
        "v_23": "0.136"
      },
      {
        "c_23": "4215.429",
        "d": "2020-12-15",
        "v_23": "0.000"
      },
      {
        "c_23": "4215.429",
        "d": "2020-12-16",
        "v_23": "1.630"
      },
      {
        "c_23": "4217.059",
        "d": "2020-12-17",
        "v_23": "0.881"
      },
      {
        "c_23": "4217.940",
        "d": "2020-12-18",
        "v_23": "0.433"
      },
      {
        "c_23": "4218.373",
        "d": "2020-12-19",
        "v_23": "0.243"
      },
      {
        "c_23": "4218.616",
        "d": "2020-12-20",
        "v_23": "0.000"
      },
      {
        "c_23": "4218.616",
        "d": "2020-12-21",
        "v_23": "0.004"
      },
      {
        "c_23": "4218.620",
        "d": "2020-12-22",
        "v_23": "0.256"
      },
      {
        "c_23": "4218.876",
        "d": "2020-12-23",
        "v_23": "0.094"
      },
      {
        "c_23": "4218.970",
        "d": "2020-12-24",
        "v_23": "0.383"
      },
      {
        "c_23": "4219.353",
        "d": "2020-12-25",
        "v_23": "1.310"
      },
      {
        "c_23": "4220.663",
        "d": "2020-12-26",
        "v_23": "0.296"
      },
      {
        "c_23": "4220.959",
        "d": "2020-12-27",
        "v_23": "0.039"
      },
      {
        "c_23": "4220.998",
        "d": "2020-12-28",
        "v_23": "0.542"
      },
      {
        "c_23": "4221.540",
        "d": "2020-12-29",
        "v_23": "0.334"
      },
      {
        "c_23": "4221.874",
        "d": "2020-12-30",
        "v_23": "0.787"
      },
      {
        "c_23": "4222.661",
        "d": "2020-12-31",
        "v_23": "0.200"
      },
      {
        "c_23": "4222.861",
        "d": "2021-01-01",
        "v_23": "0.734"
      },
      {
        "c_23": "4223.595",
        "d": "2021-01-02",
        "v_23": "0.575"
      },
      {
        "c_23": "4224.170",
        "d": "2021-01-03",
        "v_23": "0.206"
      },
      {
        "c_23": "4224.376",
        "d": "2021-01-04",
        "v_23": "0.082"
      },
      {
        "c_23": "4224.458",
        "d": "2021-01-05",
        "v_23": "0.203"
      },
      {
        "c_23": "4224.661",
        "d": "2021-01-06",
        "v_23": "0.207"
      },
      {
        "c_23": "4224.868",
        "d": "2021-01-07",
        "v_23": "0.009"
      },
      {
        "c_23": "4224.877",
        "d": "2021-01-08",
        "v_23": "0.755"
      },
      {
        "c_23": "4225.632",
        "d": "2021-01-09",
        "v_23": "2.321"
      },
      {
        "c_23": "4227.953",
        "d": "2021-01-10",
        "v_23": "1.831"
      },
      {
        "c_23": "4229.784",
        "d": "2021-01-11",
        "v_23": "0.210"
      }
    ],
    "status": "OK",
    "title": "Graph day",
    "Vermogen": "d.v_23"
  },
  "realrange": "month",
  "dataFilterCount": 0,
  "dataFilterUnit": "",
  "groupBy": false,
  "graphConfig": {
    "range": "month",
    "data": {
      "Vermogen": "d.v_23"
    }
  },
  "customRange": true,
  "keys": [
    "v"
  ],
  "ykeys": [
    "Vermogen"
  ],
  "txtUnit": "kWh",
  "ylabels": [
    "kWh"
  ],
  "chartctx": "graphoutput_block_100",
  "_width": 607,
  "loadingTooltip": false,
  "filter": "18 hours"
}

Re: Multiple sources in one graph

Posted: Tuesday 12 January 2021 21:54
by Lokonli
JanvdW wrote: Monday 21 December 2020 8:55 1. My conclusion that recent data for the outside temperature is in Domoticz was wrong. I concluded this because I saw the value in Dashticz and Domoticz, but it appeared to be the value of 30 November; sorry for that :roll:. I found a similar problem, which solved the issue.
2. You're right: it's solved. Great!
3. The aggregate parameter doesn't work as expected when two values are defined. With ['avg', 'sum'], the temp value is correct, but gas usage looks like it's the average value. I experimented with the options and it's a kind of weird: when I define two values for the aggregate parameter it shows always the avg value for both datasets. So, ['sum', 'sum'] or ['avg', 'sum'] or ['sum', 'avg'] doesn't make any difference for the result.

I have two additional questions about graphs:
4. My solar device in Domoticz holds two datasets: energieverbruik (which is the generated power) and power usage. Power usage has a stable value of 1. During dark or cloudy hours energieverbruik is zero and (just during these times) my day graph shows bars with value 1, instead of 0. The month and year graphs don't have this problem: they show the value 0, as expected.
5. Finally a feature request: the GroupBy function can group data by hour, day, week or month. It would be nice to be able to group data by year as well.
I've created a fix for 3) in latest beta. Could you test?

It was rather complex, and I had to restructure the code a bit, so there could be some side effects ...

In case of groupBy per month, based on year data, the first month will have incomplete data, because Domoticz reports data until exactly one year ago.

Re: Multiple sources in one graph

Posted: Tuesday 12 January 2021 22:42
by JanvdW
I tested the fix for 3, and this works fine. I get the proper values for gas and the temp values are the same as the values that I had calculated with the month aggregate sum value divided by 30 resp. 31. I haven't seen any unexpected side effects till now, but let you know if I notice one. Good work!

You are right that my data set contains an incomplete year, because I have set up the energy devices somewhere in April last year.

Re: Multiple sources in one graph

Posted: Saturday 30 January 2021 18:08
by JanvdW
Have you already had the opportunity to look at point 4, @Lokonli; I am curious.

Re: Multiple sources in one graph

Posted: Saturday 30 January 2021 19:47
by Lokonli
JanvdW wrote: Saturday 30 January 2021 18:08 Have you already had the opportunity to look at point 4, @Lokonli; I am curious.
I've a similar device. No issues as far as I know.

Can you post your block definition for the device, and graph?

Could you also attach a screenshot and indicate what the issue is?

Re: Multiple sources in one graph

Posted: Saturday 30 January 2021 21:50
by JanvdW
In first instance I reacted by mail, but it appeared that this doesn't show up on the forum. I am struggling to upload the images, so hereby at least the description of the problem (images are in the mail).

The week/ month graphs are not the best example, because of some rainy days, but the Domoticz week graph clearly corresponds with the Dashticz month graph. The value for 'Energy Usage' in Domoticz (0.473) matches with Dashticz (0.47).

In the day graphs it's evident that the Domoticz yellow line corresponds with the Dashticz graph. The yellow Dashticz line is 'Power Usage', not 'Energy Usage' as in the month graph.

My block definition in Dashticz:

Code: Select all

blocks['graph_23'] = { range: 'Maand', devices: [23], title: 'Vermogen', graph: 'bar', datasetColors: ['green'], legend: false, width: 12, beginAtZero: true, custom: {
        "Dag": { range: 'day', filter: '18 hours', data: { Vermogen: 'd.v_23' } },
		"Maand": { range: 'month', data: { Vermogen: 'd.v_23' } },
		"Jaar": { range: 'year', groupBy: 'month', aggregate: 'sum', data: { Vermogen: 'd.v_23' } } } }

Re: Multiple sources in one graph

Posted: Saturday 30 January 2021 22:35
by Lokonli
If you reply via the 'Full Editor & Preview' button you can drag/drop the images, and then place them inline.

The pictures probably will help me to understand the issue.

Re: Multiple sources in one graph

Posted: Saturday 30 January 2021 22:57
by JanvdW
Week/month graphs:
Domoticz week graph.PNG
Domoticz week graph.PNG (44.68 KiB) Viewed 1051 times
Dashticz month graph.PNG
Dashticz month graph.PNG (43.29 KiB) Viewed 1051 times

Re: Multiple sources in one graph

Posted: Saturday 30 January 2021 22:58
by JanvdW
Day graphs:
Domoticz day graph.PNG
Domoticz day graph.PNG (51.08 KiB) Viewed 1051 times
Dashticz day graph.PNG
Dashticz day graph.PNG (46.19 KiB) Viewed 1051 times

Re: Multiple sources in one graph

Posted: Saturday 30 January 2021 23:26
by Lokonli
And what is the problem?

Sent from my SM-A320FL using Tapatalk


Re: Multiple sources in one graph

Posted: Saturday 30 January 2021 23:40
by JanvdW
Dashticz shows different data sets in the two graphs:
  • the month/ week graph shows the 'Energy Usage' (blue bar)
  • the day graph shows the 'Power Usage' (yellow line)
I would expect that the day graphs show the 'blue bar values' as well

Re: Multiple sources in one graph

Posted: Sunday 31 January 2021 22:19
by Lokonli
JanvdW wrote: Saturday 30 January 2021 23:40 Dashticz shows different data sets in the two graphs:
  • the month/ week graph shows the 'Energy Usage' (blue bar)
  • the day graph shows the 'Power Usage' (yellow line)
I would expect that the day graphs show the 'blue bar values' as well
ok, I understand now.

I did some tests, but it's not so easy to add.

Probably it needs quite some restructuring/redesign of the graph code.

I'll add it to the list.

Re: Multiple sources in one graph

Posted: Wednesday 17 February 2021 0:00
by JanvdW
Any news on the planning for the remaining issues, @lokonli?

in the meantime I found another issue with the month graphs, which shows the max temperature value instead of the average value. I had defined the following block definition:

Code: Select all

blocks['graph_gas_gebruik'] = { range: 'Maand', devices: [127,199], title: 'Gasgebruik', graph: ['line','bar'], datasetColors: ['yellow','red',], legend: false, beginAtZero: [false, true] ,custom: {
        "Dag": { range: 'day', data: { Temperatuur: 'd.te_199', Gas: 'd.v_127' } },
	"Maand": { range: 'month', data: { Temperatuur: 'd.te_199', Gas: 'd.v_127', } },
	"Jaar": { range: 'year', groupBy: 'month', aggregate: ['avg', 'sum'], data: { Temperatuur: 'd.te_199', Gas: 'd.v_127' } } } }
The 'Jaar' graph shows the correct average temp values, but the 'Maand' graph presents the max temp values. I suppose that this is also the case in the 'Dag' graph (due to the short time frames I am not sure). I tested the following month definition:

Code: Select all

	"Maand": { range: 'month', groupBy: 'day', aggregate: ['avg', 'sum'], data: { Temperatuur: 'd.te_199', Gas: 'd.v_127', } },
But this didn't make any difference. Despite the explicit avg definition the max temp value is presented.

Re: Multiple sources in one graph

Posted: Wednesday 17 February 2021 9:13
by Lokonli
With range 'month' then for each day Domoticz will send the min, max and/or average value (depending on the device type) of that day.

So, groupBy: 'day' in that case doesn't do anything, because you already have the data per day.

For most temperature devices Domoticz provides the following fields per day:
ta: average temp
te: max temp
tm: min temp

So if you want to show the daily average instead of the daily max use the following:

Code: Select all

"Maand": { range: 'month', data: { Temperatuur: 'd.ta_199', Gas: 'd.v_127', } },

Re: Multiple sources in one graph

Posted: Wednesday 17 February 2021 9:25
by JanvdW
Great; that solved it. Thanks