Page 1 of 1

Dashticz - latest beta - Request new type for graph (Mikrotik)

Posted: Friday 14 January 2022 16:30
by Maikel76
Could you add the following graph-type in the graphs module?
The domoticz device is a Mikrotik Router (https://github.com/mrin/domoticz-routeros-plugin) with value for axis-label Mbit/s. Upstream and downstream are seperate devices
This is the JSON data for device idx 100 (upstream in Mbit/s, downstream is idx 101 also in Mbit/s)

Code: Select all

http://ip:port/json.htm?type=devices&rid=100

Code: Select all

{
	"ActTime" : 1642160390,
	"AstrTwilightEnd" : "19:23",
	"AstrTwilightStart" : "05:30",
	"CivTwilightEnd" : "18:31",
	"CivTwilightStart" : "06:22",
	"DayLength" : "11:23",
	"NautTwilightEnd" : "18:57",
	"NautTwilightStart" : "05:56",
	"ServerTime" : "2022-01-14 18:39:50",
	"SunAtSouth" : "12:27",
	"Sunrise" : "06:45",
	"Sunset" : "18:08",
	"app_version" : "2021.1",
	"result" : 
	[
		{
			"AddjMulti" : 1.0,
			"AddjMulti2" : 1.0,
			"AddjValue" : 0.0,
			"AddjValue2" : 0.0,
			"BatteryLevel" : 255,
			"CustomImage" : 106,
			"Data" : "0.07 Mbit/s",
			"Description" : "",
			"Favorite" : 0,
			"HardwareDisabled" : false,
			"HardwareID" : 9,
			"HardwareName" : "MikroTik",
			"HardwareType" : "Mikrotik RouterOS",
			"HardwareTypeVal" : 94,
			"HaveTimeout" : false,
			"ID" : "00090001",
			"Image" : "mikrotik-routeros-winbox",
			"LastUpdate" : "2022-01-14 18:39:23",
			"Name" : "MikroTik - Bandwidth UP",
			"Notifications" : "false",
			"PlanID" : "0",
			"PlanIDs" : 
			[
				0
			],
			"Protected" : false,
			"SensorType" : 1,
			"SensorUnit" : "Mbit/s",
			"ShowNotifications" : true,
			"SignalLevel" : "-",
			"SubType" : "Custom Sensor",
			"Timers" : "false",
			"Type" : "General",
			"TypeImg" : "mikrotik-routeros-winbox",
			"Unit" : 1,
			"Used" : 1,
			"XOffset" : "0",
			"YOffset" : "0",
			"idx" : "100"
		}
	],
	"status" : "OK",
	"title" : "Devices"
}
If you have any questions please let me know
Thanks again for all your effort

Re: Dashticz - latest beta - Request new type for graph (Mikrotik)

Posted: Friday 14 January 2022 16:50
by Lokonli
You see the block itself in Dashticz?

If you click on the block, then what happens?

I need some help from you:

Open Domoticz webpage.
Open DevTools by pressing F12
In Domoticz click on the 'log' button of the Mikrotik device. The graph window should open.
In DevTools->Network tab filter on 'range'

You should see three lines.
Copy the url of the first one by right click on the network request ->copy -> copy link address.

Please post the url here, including the parameters.
It should look like:
http://domoticz-ip:8080/json.htm?idx=2& ... type=graph

Open this url in a browser tab and post the result here.
It should look like:

Code: Select all

{
	"result" : 
	[
		{
			"d" : "2022-01-13 16:40",
			"te" : 26.800000000000001
		},
		{
			"d" : "2022-01-13 16:45",
			"te" : 26.800000000000001
		},
		{
			"d" : "2022-01-14 16:40",
			"te" : 26.800000000000001
		}
	],
	"status" : "OK",
	"title" : "Graph temp day"
}

[/quote]

Re: Dashticz - latest beta - Request new type for graph (Mikrotik)

Posted: Friday 14 January 2022 17:12
by Maikel76
Lokonli wrote: Friday 14 January 2022 16:50 You see the block itself in Dashticz?

If you click on the block, then what happens?

I need some help from you:

Open Domoticz webpage.
Open DevTools by pressing F12
In Domoticz click on the 'log' button of the Mikrotik device. The graph window should open.
In DevTools->Network tab filter on 'range'

You should see three lines.
Copy the url of the first one by right click on the network request ->copy -> copy link address.

Please post the url here, including the parameters.
It should look like:
http://domoticz-ip:8080/json.htm?idx=2& ... type=graph

Open this url in a browser tab and post the result here.
It should look like:

Code: Select all

{
	"result" : 
	[
		{
			"d" : "2022-01-13 16:40",
			"te" : 26.800000000000001
		},
		{
			"d" : "2022-01-13 16:45",
			"te" : 26.800000000000001
		},
		{
			"d" : "2022-01-14 16:40",
			"te" : 26.800000000000001
		}
	],
	"status" : "OK",
	"title" : "Graph temp day"
}

[/quote]
[/quote]
Yes, I see a block but only with the title given in 
[code]title: 'Internet',
If i click on the block nothing happens. The reason for that is probably because all three devices are not supported; first two are the devices we talka bout here (Mbit/s) the last one is a virtual on-off switch. For my other graph I made a extra virtual device with a dimmer 0-100 range that is supported as 'l'. Is a swich supported now?

Here the information you asked

Code: Select all

http://ip:port/json.htm?idx=100&range=day&sensor=Percentage&type=graph
results of JSON;

Code: Select all

{
	"result" : 
	[
		{
			"d" : "2022-01-13 23:00",
			"v" : "0.01"
		},
		{
			"d" : "2022-01-13 23:05",
			"v" : "0.05"
		},
		{
			"d" : "2022-01-13 23:10",
			"v" : "0.05"
		},
		{
			"d" : "2022-01-13 23:15",
			"v" : "0.12"
		},
		{
			"d" : "2022-01-13 23:20",
			"v" : "0.08"
		},
		{
			"d" : "2022-01-13 23:25",
			"v" : "0.05"
		},
		{
			"d" : "2022-01-13 23:30",
			"v" : "0.01"
		},
		{
			"d" : "2022-01-13 23:35",
			"v" : "0.09"
		},
		{
			"d" : "2022-01-13 23:40",
			"v" : "0.14"
		},
		{
			"d" : "2022-01-13 23:45",
			"v" : "0.01"
		},
		{
			"d" : "2022-01-13 23:50",
			"v" : "0.01"
		},
		{
			"d" : "2022-01-13 23:55",
			"v" : "0.12"
		},
		{
			"d" : "2022-01-14 00:00",
			"v" : "0.01"
		},
		{
			"d" : "2022-01-14 00:05",
			"v" : "0.07"
		},
		{
			"d" : "2022-01-14 00:10",
			"v" : "0.02"
		},
		{
			"d" : "2022-01-14 00:15",
			"v" : "0.01"
		},
		{
			"d" : "2022-01-14 00:20",
			"v" : "0.01"
		},
		{
			"d" : "2022-01-14 00:25",
			"v" : "0.06"
		},
		{
			"d" : "2022-01-14 00:30",
			"v" : "0.0"
		},
		{
			"d" : "2022-01-14 00:35",
			"v" : "0.0"
		},
		{
			"d" : "2022-01-14 00:40",
			"v" : "0.01"
		},
		{
			"d" : "2022-01-14 00:45",
			"v" : "0.0"
		},
		{
			"d" : "2022-01-14 00:50",
			"v" : "0.02"
		},
		{
			"d" : "2022-01-14 00:55",
			"v" : "0.01"
		},
		{
			"d" : "2022-01-14 01:00",
			"v" : "0.01"
		},
		{
			"d" : "2022-01-14 01:05",
			"v" : "0.01"
		},
		{
			"d" : "2022-01-14 01:10",
			"v" : "0.02"
		},
		{
			"d" : "2022-01-14 01:15",
			"v" : "0.01"
		},
		{
			"d" : "2022-01-14 01:20",
			"v" : "0.01"
		},
		{
			"d" : "2022-01-14 01:25",
			"v" : "0.01"
		},
		{
			"d" : "2022-01-14 01:30",
			"v" : "0.02"
		},
		{
			"d" : "2022-01-14 01:35",
			"v" : "0.01"
		},
		{
			"d" : "2022-01-14 01:40",
			"v" : "0.01"
		},
		{
			"d" : "2022-01-14 01:45",
			"v" : "0.01"
		},
		{
			"d" : "2022-01-14 01:50",
			"v" : "0.01"
		},
		{
			"d" : "2022-01-14 01:55",
			"v" : "0.01"
		},
		{
			"d" : "2022-01-14 02:00",
			"v" : "0.01"
		},
		{
			"d" : "2022-01-14 02:05",
			"v" : "0.01"
		},
		...
		... (deleted same looking rows)
		...
	],
	"status" : "OK",
	"title" : "Graph Percentage day"
}
for idx 101 (downstream) the format looks exactly the same
Thanks again

Re: Dashticz - latest beta - Request new type for graph (Mikrotik)

Posted: Friday 14 January 2022 17:32
by Maikel76
Ah just changed my CONFIG.js code to this and I have a graph now;

Code: Select all

blocks['graphMT'] = {
        title: 'Internet',
        devices: [100, 101], //, 104],
        graph: 'line',
        graphTypes: ['v','v'], //,'l'],
        lineTension: 0.4,
        width: 8,
        height: '125px',
        legend: {
           v_100:"Up",
           v_101:"Down" 
           //l_104: 'wifi'
        },
        legend: true,
        //lineFill: [false,false,true],
        datasetColors: ['orange','red'], //,'grey'],
        debug: false
}
Looks like this is woking, only somehow it cannot translate v_100 to Up and v_101 to Down

I tried the same trick with F12-network on the virtual on-off switch but I don't get any of the data expected

Re: Dashticz - latest beta - Request new type for graph (Mikrotik)

Posted: Friday 14 January 2022 18:12
by Lokonli
You can only have one legend parameter in the block. Remove 'legend: true'.

Re: Dashticz - latest beta - Request new type for graph (Mikrotik)

Posted: Saturday 15 January 2022 7:22
by Maikel76
Lokonli wrote: Friday 14 January 2022 18:12 You can only have one legend parameter in the block. Remove 'legend: true'.
Thanks that did it
Have a great weekend and thanks for everything