PM8 code optimization

This commit is contained in:
Andrey Khrolenok 2020-03-21 19:02:28 +03:00
parent f0b4c5e723
commit 7ccaf0d9c3
No known key found for this signature in database
GPG key ID: 9D4D4A25BDFFA655
10 changed files with 557 additions and 536 deletions

View file

@ -2,20 +2,13 @@
import logging
from homeassistant.components.switch import SwitchDevice
from homeassistant.const import (CONF_NAME, ATTR_ATTRIBUTION)
from homeassistant.core import callback
from homeassistant.helpers.device_registry import CONNECTION_NETWORK_MAC
from homeassistant.helpers.dispatcher import async_dispatcher_connect
from homeassistant.helpers.restore_state import RestoreEntity
from homeassistant.const import (
CONF_NAME,
ATTR_ATTRIBUTION,
)
from .const import (
DOMAIN,
DATA_CLIENT,
ATTRIBUTION,
)
from .const import (DOMAIN, DATA_CLIENT, ATTRIBUTION)
_LOGGER = logging.getLogger(__name__)
@ -192,7 +185,8 @@ class MikrotikControllerPortSwitch(MikrotikControllerSwitch):
def device_info(self):
"""Return a port description for device registry."""
info = {
"connections": {(CONNECTION_NETWORK_MAC, self._data["port-mac-address"])},
"connections": {
(CONNECTION_NETWORK_MAC, self._data["port-mac-address"])},
"manufacturer": self._ctrl.data["resource"]["platform"],
"model": self._ctrl.data["resource"]["board-name"],
"name": self._data["default-name"],
@ -362,7 +356,8 @@ 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"])
_LOGGER.debug("New script switch %s (%s)", self._inst,
self._data["name"])
@property
def name(self) -> str: