mirror of
https://github.com/tomaae/homeassistant-mikrotik_router.git
synced 2025-07-09 17:04:29 +02:00
Fix some minor errors and add russian translation.
This commit is contained in:
parent
0a58db40cd
commit
f0b4c5e723
4 changed files with 58 additions and 8 deletions
41
custom_components/mikrotik_router/.translations/ru.json
Normal file
41
custom_components/mikrotik_router/.translations/ru.json
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
{
|
||||||
|
"config": {
|
||||||
|
"title": "Mikrotik Роутер",
|
||||||
|
"step": {
|
||||||
|
"user": {
|
||||||
|
"title": "Mikrotik Роутер",
|
||||||
|
"description": "Настройка интеграции роутера Mikrotik.",
|
||||||
|
"data": {
|
||||||
|
"name": "Название интеграции",
|
||||||
|
"host": "Хост",
|
||||||
|
"port": "Порт",
|
||||||
|
"username": "Имя пользователя",
|
||||||
|
"password": "Пароль",
|
||||||
|
"ssl": "Использовать SSL",
|
||||||
|
"unit_of_measurement": "Единицы измерения"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"error": {
|
||||||
|
"name_exists": "Имя уже используется.",
|
||||||
|
"cannot_connect": "Нет связи с Mikrotik.",
|
||||||
|
"ssl_handshake_failure": "Ошибка SSL-соединения",
|
||||||
|
"connection_timeout": "Таймаут подключения к Mikrotik.",
|
||||||
|
"wrong_login": "Неверные имя пользователя или пароль."
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"options": {
|
||||||
|
"step": {
|
||||||
|
"init": {
|
||||||
|
"data": {}
|
||||||
|
},
|
||||||
|
"device_tracker": {
|
||||||
|
"data": {
|
||||||
|
"scan_interval": "Период сканирования (требуется перезагрузка HA)",
|
||||||
|
"track_arp": "Показывать в интерфейсе MAC и IP клиентов",
|
||||||
|
"unit_of_measurement": "Единицы измерения"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -2,13 +2,15 @@
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
from voluptuous import Optional
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
# ---------------------------
|
# ---------------------------
|
||||||
# from_entry
|
# from_entry
|
||||||
# ---------------------------
|
# ---------------------------
|
||||||
def from_entry(entry, param, default="") -> dict:
|
def from_entry(entry, param, default="") -> str:
|
||||||
"""Validate and return str value from Mikrotik API dict"""
|
"""Validate and return str value from Mikrotik API dict"""
|
||||||
if param not in entry:
|
if param not in entry:
|
||||||
return default
|
return default
|
||||||
|
@ -88,7 +90,7 @@ def parse_api(
|
||||||
# ---------------------------
|
# ---------------------------
|
||||||
# get_uid
|
# get_uid
|
||||||
# ---------------------------
|
# ---------------------------
|
||||||
def get_uid(entry, key, key_search, keymap) -> str:
|
def get_uid(entry, key, key_search, keymap) -> Optional(str):
|
||||||
"""Get UID for data list"""
|
"""Get UID for data list"""
|
||||||
uid = None
|
uid = None
|
||||||
if not key_search:
|
if not key_search:
|
||||||
|
@ -111,7 +113,7 @@ def get_uid(entry, key, key_search, keymap) -> str:
|
||||||
# ---------------------------
|
# ---------------------------
|
||||||
# generate_keymap
|
# generate_keymap
|
||||||
# ---------------------------
|
# ---------------------------
|
||||||
def generate_keymap(data, key_search) -> dict:
|
def generate_keymap(data, key_search) -> Optional(dict):
|
||||||
"""Generate keymap"""
|
"""Generate keymap"""
|
||||||
if not key_search:
|
if not key_search:
|
||||||
return None
|
return None
|
||||||
|
|
|
@ -3,6 +3,8 @@
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
import asyncio
|
import asyncio
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
from homeassistant.core import callback
|
||||||
from homeassistant.helpers.dispatcher import async_dispatcher_send
|
from homeassistant.helpers.dispatcher import async_dispatcher_send
|
||||||
from homeassistant.helpers.event import async_track_time_interval
|
from homeassistant.helpers.event import async_track_time_interval
|
||||||
|
|
||||||
|
@ -72,6 +74,7 @@ class MikrotikControllerData:
|
||||||
# ---------------------------
|
# ---------------------------
|
||||||
# force_update
|
# force_update
|
||||||
# ---------------------------
|
# ---------------------------
|
||||||
|
@callback
|
||||||
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()
|
||||||
|
@ -79,6 +82,7 @@ class MikrotikControllerData:
|
||||||
# ---------------------------
|
# ---------------------------
|
||||||
# force_fwupdate_check
|
# force_fwupdate_check
|
||||||
# ---------------------------
|
# ---------------------------
|
||||||
|
@callback
|
||||||
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()
|
||||||
|
|
|
@ -4,6 +4,9 @@ import ssl
|
||||||
import logging
|
import logging
|
||||||
import time
|
import time
|
||||||
from threading import Lock
|
from threading import Lock
|
||||||
|
|
||||||
|
from voluptuous import Optional
|
||||||
|
|
||||||
from .exceptions import ApiEntryNotFound
|
from .exceptions import ApiEntryNotFound
|
||||||
from .const import (
|
from .const import (
|
||||||
DEFAULT_LOGIN_METHOD,
|
DEFAULT_LOGIN_METHOD,
|
||||||
|
@ -64,7 +67,7 @@ class MikrotikAPI:
|
||||||
# ---------------------------
|
# ---------------------------
|
||||||
# disconnect
|
# disconnect
|
||||||
# ---------------------------
|
# ---------------------------
|
||||||
def disconnect(self) -> bool:
|
def disconnect(self):
|
||||||
"""Disconnect from Mikrotik device."""
|
"""Disconnect from Mikrotik device."""
|
||||||
self._connected = False
|
self._connected = False
|
||||||
self._connection = None
|
self._connection = None
|
||||||
|
@ -161,7 +164,7 @@ class MikrotikAPI:
|
||||||
# ---------------------------
|
# ---------------------------
|
||||||
# path
|
# path
|
||||||
# ---------------------------
|
# ---------------------------
|
||||||
def path(self, path) -> list:
|
def path(self, path) -> Optional(list):
|
||||||
"""Retrieve data from Mikrotik API."""
|
"""Retrieve data from Mikrotik API."""
|
||||||
if not self._connected or not self._connection:
|
if not self._connected or not self._connection:
|
||||||
if self._connection_epoch > time.time() - self._connection_retry_sec:
|
if self._connection_epoch > time.time() - self._connection_retry_sec:
|
||||||
|
@ -238,7 +241,7 @@ class MikrotikAPI:
|
||||||
entry_found = False
|
entry_found = False
|
||||||
if not self._connected or not self._connection:
|
if not self._connected or not self._connection:
|
||||||
if self._connection_epoch > time.time() - self._connection_retry_sec:
|
if self._connection_epoch > time.time() - self._connection_retry_sec:
|
||||||
return None
|
return False
|
||||||
|
|
||||||
if not self.connect():
|
if not self.connect():
|
||||||
return False
|
return False
|
||||||
|
@ -313,7 +316,7 @@ class MikrotikAPI:
|
||||||
entry_found = False
|
entry_found = False
|
||||||
if not self._connected or not self._connection:
|
if not self._connected or not self._connection:
|
||||||
if self._connection_epoch > time.time() - self._connection_retry_sec:
|
if self._connection_epoch > time.time() - self._connection_retry_sec:
|
||||||
return None
|
return False
|
||||||
|
|
||||||
if not self.connect():
|
if not self.connect():
|
||||||
return False
|
return False
|
||||||
|
@ -382,7 +385,7 @@ class MikrotikAPI:
|
||||||
# ---------------------------
|
# ---------------------------
|
||||||
# get_traffic
|
# get_traffic
|
||||||
# ---------------------------
|
# ---------------------------
|
||||||
def get_traffic(self, interfaces) -> list:
|
def get_traffic(self, interfaces) -> Optional(list):
|
||||||
"""Get traffic stats"""
|
"""Get traffic stats"""
|
||||||
traffic = None
|
traffic = None
|
||||||
if not self._connected or not self._connection:
|
if not self._connected or not self._connection:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue