I added a few more metrics, Total daliy traffic, total daily upload and total daily download.
I'm sorry i put here the code but I can't open PR.
import Domoticz
import math
import os
import sys
module_paths = [x[0] for x in os.walk(os.path.join(os.path.dirname(file), '.', '.env/lib/')) if x[0].endswith('site-packages')]
for mp in module_paths:
sys.path.append(mp)
from miktapi.sentence import sentence_pack, SentenceUnpacker
from miktapi.helper import SentenceParser
from miktapi.exceptions import UnpackerException, ParseException, PackException
def UpdateDevice(Unit, nValue, sValue, AlwaysUpdate=False, ShowInLog=False, interface=None):
if interface:
unitKey = (Unit, interface)
else:
unitKey = Unit
if unitKey not in Devices:
return
if Devices[unitKey].nValue != nValue or Devices[unitKey].sValue != sValue or AlwaysUpdate:
Devices[unitKey].Update(nValue, str(sValue))
if ShowInLog:
Domoticz.Log("%s: nValue %s - sValue %s" % (
Devices[unitKey].Name,
nValue,
sValue
))
global _plugin
_plugin = BasePlugin()
def onStart():
global _plugin
_plugin.onStart()
def onStop():
global _plugin
_plugin.onStop()
def onConnect(Connection, Status, Description):
global _plugin
_plugin.onConnect(Connection, Status, Description)
def onMessage(Connection, Data):
global _plugin
_plugin.onMessage(Connection, Data)
I added a few more metrics, Total daliy traffic, total daily upload and total daily download. I'm sorry i put here the code but I can't open PR.
import Domoticz import math import os import sys
module_paths = [x[0] for x in os.walk(os.path.join(os.path.dirname(file), '.', '.env/lib/')) if x[0].endswith('site-packages')] for mp in module_paths: sys.path.append(mp)
from miktapi.sentence import sentence_pack, SentenceUnpacker from miktapi.helper import SentenceParser from miktapi.exceptions import UnpackerException, ParseException, PackException
class BasePlugin: bwOptions = {"Custom": "1;Mbit/s"} iconName = 'mikrotik-routeros-winbox' bwUpUnit = 1 bwDownUnit = 2 statusUnit = 3 totalTrafficUnit = 4 dailyDownloadUnit = 5 dailyUploadUnit = 6
def bitToMbyte(value): return math.ceil(value / (8 * 10 * 6) 100) / 100
def UpdateDevice(Unit, nValue, sValue, AlwaysUpdate=False, ShowInLog=False, interface=None): if interface: unitKey = (Unit, interface) else: unitKey = Unit
global _plugin _plugin = BasePlugin()
def onStart(): global _plugin _plugin.onStart()
def onStop(): global _plugin _plugin.onStop()
def onConnect(Connection, Status, Description): global _plugin _plugin.onConnect(Connection, Status, Description)
def onMessage(Connection, Data): global _plugin _plugin.onMessage(Connection, Data)
def onCommand(Unit, Command, Level, Hue): global _plugin _plugin.onCommand(Unit, Command, Level, Hue)
def onDisconnect(Connection): global _plugin _plugin.onDisconnect(Connection)
def onHeartbeat(): global _plugin _plugin.onHeartbeat()
def DumpConfigToLog(): for x in Parameters: if Parameters[x] != "": Domoticz.Debug("'" + x + "':'" + str(Parameters[x]) + "'") Domoticz.Debug("Device count: " + str(len(Devices))) for x in Devices: Domoticz.Debug("Device: " + str(x) + " - " + str(Devices[x])) Domoticz.Debug("Device ID: '" + str(Devices[x].ID) + "'") Domoticz.Debug("Device Name: '" + Devices[x].Name + "'") Domoticz.Debug("Device nValue: " + str(Devices[x].nValue)) Domoticz.Debug("Device sValue: '" + Devices[x].sValue + "'") Domoticz.Debug("Device LastLevel: " + str(Devices[x].LastLevel)) return