mirror of
https://github.com/tomaae/homeassistant-mikrotik_router.git
synced 2025-07-15 03:44:31 +02:00
removed redundant returns
This commit is contained in:
parent
0f2cb6d455
commit
9be5a15c54
6 changed files with 0 additions and 56 deletions
|
@ -49,9 +49,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
|
||||||
mikrotik_controller.listeners.append(
|
mikrotik_controller.listeners.append(
|
||||||
async_dispatcher_connect(hass, mikrotik_controller.signal_update, update_controller)
|
async_dispatcher_connect(hass, mikrotik_controller.signal_update, update_controller)
|
||||||
)
|
)
|
||||||
|
|
||||||
update_controller()
|
update_controller()
|
||||||
return
|
|
||||||
|
|
||||||
|
|
||||||
# ---------------------------
|
# ---------------------------
|
||||||
|
@ -75,8 +73,6 @@ def update_items(inst, mikrotik_controller, async_add_entities, sensors):
|
||||||
if new_sensors:
|
if new_sensors:
|
||||||
async_add_entities(new_sensors, True)
|
async_add_entities(new_sensors, True)
|
||||||
|
|
||||||
return
|
|
||||||
|
|
||||||
|
|
||||||
class MikrotikControllerBinarySensor(BinarySensorDevice):
|
class MikrotikControllerBinarySensor(BinarySensorDevice):
|
||||||
"""Define an Mikrotik Controller Binary Sensor."""
|
"""Define an Mikrotik Controller Binary Sensor."""
|
||||||
|
@ -129,12 +125,10 @@ class MikrotikControllerBinarySensor(BinarySensorDevice):
|
||||||
|
|
||||||
async def async_update(self):
|
async def async_update(self):
|
||||||
"""Synchronize state with controller."""
|
"""Synchronize state with controller."""
|
||||||
return
|
|
||||||
|
|
||||||
async def async_added_to_hass(self):
|
async def async_added_to_hass(self):
|
||||||
"""Port entity created."""
|
"""Port entity created."""
|
||||||
_LOGGER.debug("New sensor %s (%s)", self._inst, self._sensor)
|
_LOGGER.debug("New sensor %s (%s)", self._inst, self._sensor)
|
||||||
return
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_on(self):
|
def is_on(self):
|
||||||
|
|
|
@ -51,7 +51,6 @@ class MikrotikControllerConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
"""Initialize MikrotikControllerConfigFlow."""
|
"""Initialize MikrotikControllerConfigFlow."""
|
||||||
return
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@callback
|
@callback
|
||||||
|
|
|
@ -66,7 +66,6 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
|
||||||
)
|
)
|
||||||
|
|
||||||
update_controller()
|
update_controller()
|
||||||
return
|
|
||||||
|
|
||||||
|
|
||||||
# ---------------------------
|
# ---------------------------
|
||||||
|
@ -91,8 +90,6 @@ def update_items(inst, mikrotik_controller, async_add_entities, tracked):
|
||||||
if new_tracked:
|
if new_tracked:
|
||||||
async_add_entities(new_tracked)
|
async_add_entities(new_tracked)
|
||||||
|
|
||||||
return
|
|
||||||
|
|
||||||
|
|
||||||
# ---------------------------
|
# ---------------------------
|
||||||
# MikrotikControllerPortDeviceTracker
|
# MikrotikControllerPortDeviceTracker
|
||||||
|
@ -118,11 +115,9 @@ 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 %s)", self._inst, self._data['default-name'], 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
|
|
||||||
|
|
||||||
async def async_update(self):
|
async def async_update(self):
|
||||||
"""Synchronize state with controller."""
|
"""Synchronize state with controller."""
|
||||||
return
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_connected(self):
|
def is_connected(self):
|
||||||
|
|
|
@ -49,15 +49,12 @@ class MikrotikControllerData():
|
||||||
async_track_time_interval(self.hass, self.force_update, self.option_scan_interval)
|
async_track_time_interval(self.hass, self.force_update, self.option_scan_interval)
|
||||||
async_track_time_interval(self.hass, self.force_fwupdate_check, timedelta(hours=1))
|
async_track_time_interval(self.hass, self.force_fwupdate_check, timedelta(hours=1))
|
||||||
|
|
||||||
return
|
|
||||||
|
|
||||||
# ---------------------------
|
# ---------------------------
|
||||||
# force_update
|
# force_update
|
||||||
# ---------------------------
|
# ---------------------------
|
||||||
async def force_update(self, _now=None):
|
async def force_update(self, _now=None):
|
||||||
"""Trigger update by timer"""
|
"""Trigger update by timer"""
|
||||||
await self.async_update()
|
await self.async_update()
|
||||||
return
|
|
||||||
|
|
||||||
# ---------------------------
|
# ---------------------------
|
||||||
# force_fwupdate_check
|
# force_fwupdate_check
|
||||||
|
@ -65,7 +62,6 @@ class MikrotikControllerData():
|
||||||
async def force_fwupdate_check(self, _now=None):
|
async def force_fwupdate_check(self, _now=None):
|
||||||
"""Trigger hourly update by timer"""
|
"""Trigger hourly update by timer"""
|
||||||
await self.async_fwupdate_check()
|
await self.async_fwupdate_check()
|
||||||
return
|
|
||||||
|
|
||||||
# ---------------------------
|
# ---------------------------
|
||||||
# option_track_arp
|
# option_track_arp
|
||||||
|
@ -112,7 +108,6 @@ class MikrotikControllerData():
|
||||||
await self.hass.async_add_executor_job(self.get_system_routerboard)
|
await self.hass.async_add_executor_job(self.get_system_routerboard)
|
||||||
await self.hass.async_add_executor_job(self.get_system_resource)
|
await self.hass.async_add_executor_job(self.get_system_resource)
|
||||||
self.lock.release()
|
self.lock.release()
|
||||||
return
|
|
||||||
|
|
||||||
# ---------------------------
|
# ---------------------------
|
||||||
# async_fwupdate_check
|
# async_fwupdate_check
|
||||||
|
@ -120,9 +115,7 @@ class MikrotikControllerData():
|
||||||
async def async_fwupdate_check(self):
|
async def async_fwupdate_check(self):
|
||||||
"""Update Mikrotik data"""
|
"""Update Mikrotik data"""
|
||||||
await self.hass.async_add_executor_job(self.get_firmware_update)
|
await self.hass.async_add_executor_job(self.get_firmware_update)
|
||||||
|
|
||||||
async_dispatcher_send(self.hass, self.signal_update)
|
async_dispatcher_send(self.hass, self.signal_update)
|
||||||
return
|
|
||||||
|
|
||||||
# ---------------------------
|
# ---------------------------
|
||||||
# async_update
|
# async_update
|
||||||
|
@ -146,7 +139,6 @@ class MikrotikControllerData():
|
||||||
|
|
||||||
async_dispatcher_send(self.hass, self.signal_update)
|
async_dispatcher_send(self.hass, self.signal_update)
|
||||||
self.lock.release()
|
self.lock.release()
|
||||||
return
|
|
||||||
|
|
||||||
# ---------------------------
|
# ---------------------------
|
||||||
# async_reset
|
# async_reset
|
||||||
|
@ -176,8 +168,6 @@ class MikrotikControllerData():
|
||||||
except ApiEntryNotFound as error:
|
except ApiEntryNotFound as error:
|
||||||
_LOGGER.error("Failed to run script: %s", error)
|
_LOGGER.error("Failed to run script: %s", error)
|
||||||
|
|
||||||
return
|
|
||||||
|
|
||||||
# ---------------------------
|
# ---------------------------
|
||||||
# get_interface
|
# get_interface
|
||||||
# ---------------------------
|
# ---------------------------
|
||||||
|
@ -209,8 +199,6 @@ class MikrotikControllerData():
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
return
|
|
||||||
|
|
||||||
# ---------------------------
|
# ---------------------------
|
||||||
# get_interface_traffic
|
# get_interface_traffic
|
||||||
# ---------------------------
|
# ---------------------------
|
||||||
|
@ -231,7 +219,6 @@ class MikrotikControllerData():
|
||||||
{'name': 'tx-bits-per-second', 'default': 0},
|
{'name': 'tx-bits-per-second', 'default': 0},
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
return
|
|
||||||
|
|
||||||
# ---------------------------
|
# ---------------------------
|
||||||
# get_interface_client
|
# get_interface_client
|
||||||
|
@ -262,8 +249,6 @@ class MikrotikControllerData():
|
||||||
self.data['interface'][uid]['client-ip-address'] = from_entry(self.data['arp'][uid], 'address')
|
self.data['interface'][uid]['client-ip-address'] = from_entry(self.data['arp'][uid], 'address')
|
||||||
self.data['interface'][uid]['client-mac-address'] = from_entry(self.data['arp'][uid], 'mac-address')
|
self.data['interface'][uid]['client-mac-address'] = from_entry(self.data['arp'][uid], 'mac-address')
|
||||||
|
|
||||||
return
|
|
||||||
|
|
||||||
# ---------------------------
|
# ---------------------------
|
||||||
# update_arp
|
# update_arp
|
||||||
# ---------------------------
|
# ---------------------------
|
||||||
|
@ -337,8 +322,6 @@ class MikrotikControllerData():
|
||||||
self.data['arp'][uid]['mac-address'] = from_entry(entry, 'mac-address')
|
self.data['arp'][uid]['mac-address'] = from_entry(entry, 'mac-address')
|
||||||
self.data['arp'][uid]['address'] = mac2ip[self.data['arp'][uid]['mac-address']] if self.data['arp'][uid]['mac-address'] in mac2ip else ""
|
self.data['arp'][uid]['address'] = mac2ip[self.data['arp'][uid]['mac-address']] if self.data['arp'][uid]['mac-address'] in mac2ip else ""
|
||||||
|
|
||||||
return
|
|
||||||
|
|
||||||
# ---------------------------
|
# ---------------------------
|
||||||
# get_iface_from_entry
|
# get_iface_from_entry
|
||||||
# ---------------------------
|
# ---------------------------
|
||||||
|
@ -384,7 +367,6 @@ class MikrotikControllerData():
|
||||||
{'key': 'action', 'value': 'dst-nat'}
|
{'key': 'action', 'value': 'dst-nat'}
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
return
|
|
||||||
|
|
||||||
# ---------------------------
|
# ---------------------------
|
||||||
# get_system_routerboard
|
# get_system_routerboard
|
||||||
|
@ -401,7 +383,6 @@ class MikrotikControllerData():
|
||||||
{'name': 'firmware', 'default': 'unknown'}
|
{'name': 'firmware', 'default': 'unknown'}
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
return
|
|
||||||
|
|
||||||
# ---------------------------
|
# ---------------------------
|
||||||
# get_system_resource
|
# get_system_resource
|
||||||
|
@ -434,8 +415,6 @@ class MikrotikControllerData():
|
||||||
else:
|
else:
|
||||||
self.data['resource']['hdd-usage'] = "unknown"
|
self.data['resource']['hdd-usage'] = "unknown"
|
||||||
|
|
||||||
return
|
|
||||||
|
|
||||||
# ---------------------------
|
# ---------------------------
|
||||||
# get_system_routerboard
|
# get_system_routerboard
|
||||||
# ---------------------------
|
# ---------------------------
|
||||||
|
@ -457,8 +436,6 @@ class MikrotikControllerData():
|
||||||
else:
|
else:
|
||||||
self.data['fw-update']['available'] = False
|
self.data['fw-update']['available'] = False
|
||||||
|
|
||||||
return
|
|
||||||
|
|
||||||
# ---------------------------
|
# ---------------------------
|
||||||
# get_script
|
# get_script
|
||||||
# ---------------------------
|
# ---------------------------
|
||||||
|
@ -474,4 +451,3 @@ class MikrotikControllerData():
|
||||||
{'name': 'run-count', 'default': 'unknown'}
|
{'name': 'run-count', 'default': 'unknown'}
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
return
|
|
||||||
|
|
|
@ -92,7 +92,6 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
|
||||||
)
|
)
|
||||||
|
|
||||||
update_controller()
|
update_controller()
|
||||||
return
|
|
||||||
|
|
||||||
|
|
||||||
# ---------------------------
|
# ---------------------------
|
||||||
|
@ -129,8 +128,6 @@ def update_items(inst, mikrotik_controller, async_add_entities, sensors):
|
||||||
if new_sensors:
|
if new_sensors:
|
||||||
async_add_entities(new_sensors, True)
|
async_add_entities(new_sensors, True)
|
||||||
|
|
||||||
return
|
|
||||||
|
|
||||||
|
|
||||||
# ---------------------------
|
# ---------------------------
|
||||||
# MikrotikControllerSensor
|
# MikrotikControllerSensor
|
||||||
|
@ -211,12 +208,10 @@ class MikrotikControllerSensor(Entity):
|
||||||
|
|
||||||
async def async_update(self):
|
async def async_update(self):
|
||||||
"""Synchronize state with controller."""
|
"""Synchronize state with controller."""
|
||||||
return
|
|
||||||
|
|
||||||
async def async_added_to_hass(self):
|
async def async_added_to_hass(self):
|
||||||
"""Port entity created."""
|
"""Port entity created."""
|
||||||
_LOGGER.debug("New sensor %s (%s)", self._inst, self._sensor)
|
_LOGGER.debug("New sensor %s (%s)", self._inst, self._sensor)
|
||||||
return
|
|
||||||
|
|
||||||
|
|
||||||
# ---------------------------
|
# ---------------------------
|
||||||
|
@ -255,4 +250,3 @@ class MikrotikControllerTrafficSensor(MikrotikControllerSensor):
|
||||||
async def async_added_to_hass(self):
|
async def async_added_to_hass(self):
|
||||||
"""Port entity created."""
|
"""Port entity created."""
|
||||||
_LOGGER.debug("New sensor %s (%s %s)", self._inst, self._data['default-name'], self._sensor)
|
_LOGGER.debug("New sensor %s (%s %s)", self._inst, self._data['default-name'], self._sensor)
|
||||||
return
|
|
||||||
|
|
|
@ -81,7 +81,6 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
|
||||||
)
|
)
|
||||||
|
|
||||||
update_controller()
|
update_controller()
|
||||||
return
|
|
||||||
|
|
||||||
|
|
||||||
# ---------------------------
|
# ---------------------------
|
||||||
|
@ -110,8 +109,6 @@ def update_items(inst, mikrotik_controller, async_add_entities, switches):
|
||||||
if new_switches:
|
if new_switches:
|
||||||
async_add_entities(new_switches)
|
async_add_entities(new_switches)
|
||||||
|
|
||||||
return
|
|
||||||
|
|
||||||
|
|
||||||
# ---------------------------
|
# ---------------------------
|
||||||
# MikrotikControllerSwitch
|
# MikrotikControllerSwitch
|
||||||
|
@ -128,11 +125,9 @@ class MikrotikControllerSwitch(SwitchDevice, RestoreEntity):
|
||||||
async def async_added_to_hass(self):
|
async def async_added_to_hass(self):
|
||||||
"""Switch entity created."""
|
"""Switch entity created."""
|
||||||
_LOGGER.debug("New switch %s (%s)", self._inst, self._uid)
|
_LOGGER.debug("New switch %s (%s)", self._inst, self._uid)
|
||||||
return
|
|
||||||
|
|
||||||
async def async_update(self):
|
async def async_update(self):
|
||||||
"""Synchronize state with controller."""
|
"""Synchronize state with controller."""
|
||||||
return
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def available(self) -> bool:
|
def available(self) -> bool:
|
||||||
|
@ -158,7 +153,6 @@ 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 %s)", self._inst, self._data['default-name'], 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
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self) -> str:
|
def name(self) -> str:
|
||||||
|
@ -214,7 +208,6 @@ class MikrotikControllerPortSwitch(MikrotikControllerSwitch):
|
||||||
mod_value = False
|
mod_value = False
|
||||||
self._ctrl.set_value(path, param, value, mod_param, mod_value)
|
self._ctrl.set_value(path, param, value, mod_param, mod_value)
|
||||||
await self._ctrl.force_update()
|
await self._ctrl.force_update()
|
||||||
return
|
|
||||||
|
|
||||||
async def async_turn_off(self):
|
async def async_turn_off(self):
|
||||||
"""Turn on the switch."""
|
"""Turn on the switch."""
|
||||||
|
@ -225,7 +218,6 @@ class MikrotikControllerPortSwitch(MikrotikControllerSwitch):
|
||||||
mod_value = True
|
mod_value = True
|
||||||
self._ctrl.set_value(path, param, value, mod_param, mod_value)
|
self._ctrl.set_value(path, param, value, mod_param, mod_value)
|
||||||
await self._ctrl.async_update()
|
await self._ctrl.async_update()
|
||||||
return
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_on(self):
|
def is_on(self):
|
||||||
|
@ -251,7 +243,6 @@ class MikrotikControllerNATSwitch(MikrotikControllerSwitch):
|
||||||
async def async_added_to_hass(self):
|
async def async_added_to_hass(self):
|
||||||
"""NAT switch entity created."""
|
"""NAT switch entity created."""
|
||||||
_LOGGER.debug("New port switch %s (%s)", self._inst, self._data['name'])
|
_LOGGER.debug("New port switch %s (%s)", self._inst, self._data['name'])
|
||||||
return
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self) -> str:
|
def name(self) -> str:
|
||||||
|
@ -308,7 +299,6 @@ class MikrotikControllerNATSwitch(MikrotikControllerSwitch):
|
||||||
mod_value = False
|
mod_value = False
|
||||||
self._ctrl.set_value(path, param, value, mod_param, mod_value)
|
self._ctrl.set_value(path, param, value, mod_param, mod_value)
|
||||||
await self._ctrl.force_update()
|
await self._ctrl.force_update()
|
||||||
return
|
|
||||||
|
|
||||||
async def async_turn_off(self):
|
async def async_turn_off(self):
|
||||||
"""Turn on the switch."""
|
"""Turn on the switch."""
|
||||||
|
@ -323,7 +313,6 @@ class MikrotikControllerNATSwitch(MikrotikControllerSwitch):
|
||||||
mod_value = True
|
mod_value = True
|
||||||
self._ctrl.set_value(path, param, value, mod_param, mod_value)
|
self._ctrl.set_value(path, param, value, mod_param, mod_value)
|
||||||
await self._ctrl.async_update()
|
await self._ctrl.async_update()
|
||||||
return
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_on(self):
|
def is_on(self):
|
||||||
|
@ -349,7 +338,6 @@ class MikrotikControllerScriptSwitch(MikrotikControllerSwitch):
|
||||||
async def async_added_to_hass(self):
|
async def async_added_to_hass(self):
|
||||||
"""Script switch entity created."""
|
"""Script switch entity created."""
|
||||||
_LOGGER.debug("New script switch %s (%s)", self._inst, self._data['name'])
|
_LOGGER.debug("New script switch %s (%s)", self._inst, self._data['name'])
|
||||||
return
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self) -> str:
|
def name(self) -> str:
|
||||||
|
@ -392,11 +380,9 @@ class MikrotikControllerScriptSwitch(MikrotikControllerSwitch):
|
||||||
"""Turn on the switch."""
|
"""Turn on the switch."""
|
||||||
self._ctrl.run_script(self._data['name'])
|
self._ctrl.run_script(self._data['name'])
|
||||||
await self._ctrl.force_update()
|
await self._ctrl.force_update()
|
||||||
return
|
|
||||||
|
|
||||||
async def async_turn_off(self):
|
async def async_turn_off(self):
|
||||||
"""Turn off the switch."""
|
"""Turn off the switch."""
|
||||||
return
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_on(self):
|
def is_on(self):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue