mirror of
https://github.com/esphome/esphome.git
synced 2024-11-12 18:27:46 +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 aioesphomeapi import APIClient, ReconnectLogic, APIConnectionError, LogLevel
|
||||
from aioesphomeapi.api_pb2 import SubscribeLogsResponse
|
||||
import zeroconf
|
||||
|
||||
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
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
@ -29,11 +30,16 @@ async def async_run_logs(config, address):
|
|||
noise_psk=noise_psk,
|
||||
)
|
||||
first_connect = True
|
||||
dashboard = CORE.dashboard
|
||||
|
||||
def on_log(msg):
|
||||
time_ = datetime.now().time().strftime("[%H:%M:%S]")
|
||||
text = msg.message.decode("utf8", "backslashreplace")
|
||||
safe_print(time_ + text)
|
||||
def on_log(msg: SubscribeLogsResponse) -> None:
|
||||
"""Handle a new log message."""
|
||||
time_ = datetime.now()
|
||||
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():
|
||||
nonlocal first_connect
|
||||
|
|
Loading…
Reference in a new issue