mirror of
https://github.com/tomaae/homeassistant-mikrotik_router.git
synced 2025-07-24 04:24:29 +02:00
improved debug messages
fixed TrafficSensor unique id
This commit is contained in:
parent
f1a239f118
commit
81f25765f7
4 changed files with 11 additions and 5 deletions
|
@ -117,7 +117,7 @@ class MikrotikControllerPortDeviceTracker(ScannerEntity):
|
||||||
|
|
||||||
async def async_added_to_hass(self):
|
async def async_added_to_hass(self):
|
||||||
"""Port entity created."""
|
"""Port entity created."""
|
||||||
_LOGGER.debug("New port tracker %s (%s)", self._inst, self._data['port-mac-address'])
|
_LOGGER.debug("New port tracker %s (%s %s)", self._inst, self._data['default-name'], self._data['port-mac-address'])
|
||||||
return
|
return
|
||||||
|
|
||||||
async def async_update(self):
|
async def async_update(self):
|
||||||
|
|
|
@ -122,7 +122,7 @@ class MikrotikAPI:
|
||||||
|
|
||||||
try:
|
try:
|
||||||
response = self._connection.path(path)
|
response = self._connection.path(path)
|
||||||
tuple(response)
|
_LOGGER.debug("API response ({}): {}".format(path, tuple(response)))
|
||||||
except librouteros_custom.exceptions.ConnectionClosed:
|
except librouteros_custom.exceptions.ConnectionClosed:
|
||||||
_LOGGER.error("Mikrotik %s connection closed", self._host)
|
_LOGGER.error("Mikrotik %s connection closed", self._host)
|
||||||
self._connected = False
|
self._connected = False
|
||||||
|
@ -251,6 +251,7 @@ class MikrotikAPI:
|
||||||
args = {'interface': interfaces, 'once': True}
|
args = {'interface': interfaces, 'once': True}
|
||||||
try:
|
try:
|
||||||
traffic = response('monitor-traffic', **args)
|
traffic = response('monitor-traffic', **args)
|
||||||
|
_LOGGER.debug("API response ({}): {}".format("/interface/monitor-traffic", tuple(response)))
|
||||||
except librouteros_custom.exceptions.ConnectionClosed:
|
except librouteros_custom.exceptions.ConnectionClosed:
|
||||||
_LOGGER.error("Mikrotik %s connection closed", self._host)
|
_LOGGER.error("Mikrotik %s connection closed", self._host)
|
||||||
self._connected = False
|
self._connected = False
|
||||||
|
|
|
@ -239,7 +239,7 @@ class MikrotikControllerTrafficSensor(MikrotikControllerSensor):
|
||||||
@property
|
@property
|
||||||
def unique_id(self):
|
def unique_id(self):
|
||||||
"""Return a unique_id for this entity."""
|
"""Return a unique_id for this entity."""
|
||||||
return "{}-{}-{}".format(self._inst.lower(), self._sensor.lower(), self._data['name'].lower())
|
return "{}-{}-{}".format(self._inst.lower(), self._sensor.lower(), self._data['default-name'].lower())
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def device_info(self):
|
def device_info(self):
|
||||||
|
@ -251,3 +251,8 @@ class MikrotikControllerTrafficSensor(MikrotikControllerSensor):
|
||||||
"name": self._data['default-name'],
|
"name": self._data['default-name'],
|
||||||
}
|
}
|
||||||
return info
|
return info
|
||||||
|
|
||||||
|
async def async_added_to_hass(self):
|
||||||
|
"""Port entity created."""
|
||||||
|
_LOGGER.debug("New sensor %s (%s %s)", self._inst, self._data['default-name'], self._sensor)
|
||||||
|
return
|
|
@ -94,7 +94,7 @@ def update_items(inst, mikrotik_controller, async_add_entities, switches):
|
||||||
|
|
||||||
# Add switches
|
# Add switches
|
||||||
for sid, sid_func in zip(
|
for sid, sid_func in zip(
|
||||||
["interface", "nat", "script"],
|
["interface", "nat", "script"],
|
||||||
[MikrotikControllerPortSwitch, MikrotikControllerNATSwitch, MikrotikControllerScriptSwitch]
|
[MikrotikControllerPortSwitch, MikrotikControllerNATSwitch, MikrotikControllerScriptSwitch]
|
||||||
):
|
):
|
||||||
for uid in mikrotik_controller.data[sid]:
|
for uid in mikrotik_controller.data[sid]:
|
||||||
|
@ -157,7 +157,7 @@ class MikrotikControllerPortSwitch(MikrotikControllerSwitch):
|
||||||
|
|
||||||
async def async_added_to_hass(self):
|
async def async_added_to_hass(self):
|
||||||
"""Port entity created."""
|
"""Port entity created."""
|
||||||
_LOGGER.debug("New port switch %s (%s)", self._inst, self._data['port-mac-address'])
|
_LOGGER.debug("New port switch %s (%s %s)", self._inst, self._data['default-name'], self._data['port-mac-address'])
|
||||||
return
|
return
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue