mirror of
https://github.com/esphome/esphome.git
synced 2024-11-14 02:58:11 +01:00
fixes
This commit is contained in:
parent
6a5cea171e
commit
9bdd802c7a
1 changed files with 11 additions and 5 deletions
|
@ -4,10 +4,11 @@ from datetime import datetime
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
from aioesphomeapi import APIClient, ReconnectLogic, APIConnectionError, LogLevel
|
from aioesphomeapi import APIClient, ReconnectLogic, APIConnectionError, LogLevel
|
||||||
|
from aioesphomeapi.api_pb2 import SubscribeLogsResponse
|
||||||
import zeroconf
|
import zeroconf
|
||||||
|
|
||||||
from esphome.const import CONF_KEY, CONF_PORT, CONF_PASSWORD, __version__
|
from esphome.const import CONF_KEY, CONF_PORT, CONF_PASSWORD, __version__
|
||||||
from esphome.util import safe_print
|
from esphome.core import CORE
|
||||||
from . import CONF_ENCRYPTION
|
from . import CONF_ENCRYPTION
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
@ -29,11 +30,16 @@ async def async_run_logs(config, address):
|
||||||
noise_psk=noise_psk,
|
noise_psk=noise_psk,
|
||||||
)
|
)
|
||||||
first_connect = True
|
first_connect = True
|
||||||
|
dashboard = CORE.dashboard
|
||||||
|
|
||||||
def on_log(msg):
|
def on_log(msg: SubscribeLogsResponse) -> None:
|
||||||
time_ = datetime.now().time().strftime("[%H:%M:%S]")
|
"""Handle a new log message."""
|
||||||
text = msg.message.decode("utf8", "backslashreplace")
|
time_ = datetime.now()
|
||||||
safe_print(time_ + text)
|
message: bytes = msg.message
|
||||||
|
text = message.decode("utf8", "backslashreplace")
|
||||||
|
if dashboard:
|
||||||
|
text = text.replace("\033", "\\033")
|
||||||
|
print(f"[{time_.hour:02}:{time_.minute:02}:{time_.second:02}]{text}")
|
||||||
|
|
||||||
async def on_connect():
|
async def on_connect():
|
||||||
nonlocal first_connect
|
nonlocal first_connect
|
||||||
|
|
Loading…
Reference in a new issue