diff --git a/custom_components/mikrotik_router/binary_sensor.py b/custom_components/mikrotik_router/binary_sensor.py index 7250f7a..9fc4083 100644 --- a/custom_components/mikrotik_router/binary_sensor.py +++ b/custom_components/mikrotik_router/binary_sensor.py @@ -49,9 +49,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities): mikrotik_controller.listeners.append( async_dispatcher_connect(hass, mikrotik_controller.signal_update, update_controller) ) - update_controller() - return # --------------------------- @@ -75,8 +73,6 @@ def update_items(inst, mikrotik_controller, async_add_entities, sensors): if new_sensors: async_add_entities(new_sensors, True) - return - class MikrotikControllerBinarySensor(BinarySensorDevice): """Define an Mikrotik Controller Binary Sensor.""" @@ -129,12 +125,10 @@ class MikrotikControllerBinarySensor(BinarySensorDevice): async def async_update(self): """Synchronize state with controller.""" - return async def async_added_to_hass(self): """Port entity created.""" _LOGGER.debug("New sensor %s (%s)", self._inst, self._sensor) - return @property def is_on(self): diff --git a/custom_components/mikrotik_router/config_flow.py b/custom_components/mikrotik_router/config_flow.py index 25a2eec..61c7002 100644 --- a/custom_components/mikrotik_router/config_flow.py +++ b/custom_components/mikrotik_router/config_flow.py @@ -51,7 +51,6 @@ class MikrotikControllerConfigFlow(ConfigFlow, domain=DOMAIN): def __init__(self): """Initialize MikrotikControllerConfigFlow.""" - return @staticmethod @callback diff --git a/custom_components/mikrotik_router/device_tracker.py b/custom_components/mikrotik_router/device_tracker.py index 2d57c4b..0035e85 100644 --- a/custom_components/mikrotik_router/device_tracker.py +++ b/custom_components/mikrotik_router/device_tracker.py @@ -66,7 +66,6 @@ async def async_setup_entry(hass, config_entry, async_add_entities): ) update_controller() - return # --------------------------- @@ -91,8 +90,6 @@ def update_items(inst, mikrotik_controller, async_add_entities, tracked): if new_tracked: async_add_entities(new_tracked) - return - # --------------------------- # MikrotikControllerPortDeviceTracker @@ -118,11 +115,9 @@ class MikrotikControllerPortDeviceTracker(ScannerEntity): async def async_added_to_hass(self): """Port entity created.""" _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): """Synchronize state with controller.""" - return @property def is_connected(self): diff --git a/custom_components/mikrotik_router/mikrotik_controller.py b/custom_components/mikrotik_router/mikrotik_controller.py index 71ccf36..f0a62d5 100644 --- a/custom_components/mikrotik_router/mikrotik_controller.py +++ b/custom_components/mikrotik_router/mikrotik_controller.py @@ -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_fwupdate_check, timedelta(hours=1)) - return - # --------------------------- # force_update # --------------------------- async def force_update(self, _now=None): """Trigger update by timer""" await self.async_update() - return # --------------------------- # force_fwupdate_check @@ -65,7 +62,6 @@ class MikrotikControllerData(): async def force_fwupdate_check(self, _now=None): """Trigger hourly update by timer""" await self.async_fwupdate_check() - return # --------------------------- # 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_resource) self.lock.release() - return # --------------------------- # async_fwupdate_check @@ -120,9 +115,7 @@ class MikrotikControllerData(): async def async_fwupdate_check(self): """Update Mikrotik data""" await self.hass.async_add_executor_job(self.get_firmware_update) - async_dispatcher_send(self.hass, self.signal_update) - return # --------------------------- # async_update @@ -146,7 +139,6 @@ class MikrotikControllerData(): async_dispatcher_send(self.hass, self.signal_update) self.lock.release() - return # --------------------------- # async_reset @@ -176,8 +168,6 @@ class MikrotikControllerData(): except ApiEntryNotFound as error: _LOGGER.error("Failed to run script: %s", error) - return - # --------------------------- # get_interface # --------------------------- @@ -209,8 +199,6 @@ class MikrotikControllerData(): ] ) - return - # --------------------------- # get_interface_traffic # --------------------------- @@ -231,7 +219,6 @@ class MikrotikControllerData(): {'name': 'tx-bits-per-second', 'default': 0}, ] ) - return # --------------------------- # 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-mac-address'] = from_entry(self.data['arp'][uid], 'mac-address') - return - # --------------------------- # update_arp # --------------------------- @@ -337,8 +322,6 @@ class MikrotikControllerData(): 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 "" - return - # --------------------------- # get_iface_from_entry # --------------------------- @@ -384,7 +367,6 @@ class MikrotikControllerData(): {'key': 'action', 'value': 'dst-nat'} ] ) - return # --------------------------- # get_system_routerboard @@ -401,7 +383,6 @@ class MikrotikControllerData(): {'name': 'firmware', 'default': 'unknown'} ] ) - return # --------------------------- # get_system_resource @@ -434,8 +415,6 @@ class MikrotikControllerData(): else: self.data['resource']['hdd-usage'] = "unknown" - return - # --------------------------- # get_system_routerboard # --------------------------- @@ -457,8 +436,6 @@ class MikrotikControllerData(): else: self.data['fw-update']['available'] = False - return - # --------------------------- # get_script # --------------------------- @@ -474,4 +451,3 @@ class MikrotikControllerData(): {'name': 'run-count', 'default': 'unknown'} ] ) - return diff --git a/custom_components/mikrotik_router/sensor.py b/custom_components/mikrotik_router/sensor.py index 99e8976..68011ab 100644 --- a/custom_components/mikrotik_router/sensor.py +++ b/custom_components/mikrotik_router/sensor.py @@ -92,7 +92,6 @@ async def async_setup_entry(hass, config_entry, async_add_entities): ) update_controller() - return # --------------------------- @@ -129,8 +128,6 @@ def update_items(inst, mikrotik_controller, async_add_entities, sensors): if new_sensors: async_add_entities(new_sensors, True) - return - # --------------------------- # MikrotikControllerSensor @@ -211,12 +208,10 @@ class MikrotikControllerSensor(Entity): async def async_update(self): """Synchronize state with controller.""" - return async def async_added_to_hass(self): """Port entity created.""" _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): """Port entity created.""" _LOGGER.debug("New sensor %s (%s %s)", self._inst, self._data['default-name'], self._sensor) - return diff --git a/custom_components/mikrotik_router/switch.py b/custom_components/mikrotik_router/switch.py index e594539..5c8361c 100644 --- a/custom_components/mikrotik_router/switch.py +++ b/custom_components/mikrotik_router/switch.py @@ -81,7 +81,6 @@ async def async_setup_entry(hass, config_entry, async_add_entities): ) update_controller() - return # --------------------------- @@ -110,8 +109,6 @@ def update_items(inst, mikrotik_controller, async_add_entities, switches): if new_switches: async_add_entities(new_switches) - return - # --------------------------- # MikrotikControllerSwitch @@ -128,11 +125,9 @@ class MikrotikControllerSwitch(SwitchDevice, RestoreEntity): async def async_added_to_hass(self): """Switch entity created.""" _LOGGER.debug("New switch %s (%s)", self._inst, self._uid) - return async def async_update(self): """Synchronize state with controller.""" - return @property def available(self) -> bool: @@ -158,7 +153,6 @@ class MikrotikControllerPortSwitch(MikrotikControllerSwitch): async def async_added_to_hass(self): """Port entity created.""" _LOGGER.debug("New port switch %s (%s %s)", self._inst, self._data['default-name'], self._data['port-mac-address']) - return @property def name(self) -> str: @@ -214,7 +208,6 @@ class MikrotikControllerPortSwitch(MikrotikControllerSwitch): mod_value = False self._ctrl.set_value(path, param, value, mod_param, mod_value) await self._ctrl.force_update() - return async def async_turn_off(self): """Turn on the switch.""" @@ -225,7 +218,6 @@ class MikrotikControllerPortSwitch(MikrotikControllerSwitch): mod_value = True self._ctrl.set_value(path, param, value, mod_param, mod_value) await self._ctrl.async_update() - return @property def is_on(self): @@ -251,7 +243,6 @@ class MikrotikControllerNATSwitch(MikrotikControllerSwitch): async def async_added_to_hass(self): """NAT switch entity created.""" _LOGGER.debug("New port switch %s (%s)", self._inst, self._data['name']) - return @property def name(self) -> str: @@ -308,7 +299,6 @@ class MikrotikControllerNATSwitch(MikrotikControllerSwitch): mod_value = False self._ctrl.set_value(path, param, value, mod_param, mod_value) await self._ctrl.force_update() - return async def async_turn_off(self): """Turn on the switch.""" @@ -323,7 +313,6 @@ class MikrotikControllerNATSwitch(MikrotikControllerSwitch): mod_value = True self._ctrl.set_value(path, param, value, mod_param, mod_value) await self._ctrl.async_update() - return @property def is_on(self): @@ -349,7 +338,6 @@ class MikrotikControllerScriptSwitch(MikrotikControllerSwitch): async def async_added_to_hass(self): """Script switch entity created.""" _LOGGER.debug("New script switch %s (%s)", self._inst, self._data['name']) - return @property def name(self) -> str: @@ -392,11 +380,9 @@ class MikrotikControllerScriptSwitch(MikrotikControllerSwitch): """Turn on the switch.""" self._ctrl.run_script(self._data['name']) await self._ctrl.force_update() - return async def async_turn_off(self): """Turn off the switch.""" - return @property def is_on(self):