v1.0.0 - 2025-03-13 EHS-Sentinel has been heavily modified to incorporate the control mechanism The read-in behavior of the modbus registers has been revised from chunks to single byte MessageProcessor now runs asynchronously MessageProducer added which takes over the writing communication with the WP Configuration of HASS entities has moved from hardcoded to NASA Repository NASA Repository has been fundamentally changed All FSV Values, NASA_POWER, VAR_IN_TEMP_WATER_LAW_TARGET_F, NASA_INDOOR_OPMODE are allowed for writing mode NASA_OUTDOOR_DEFROST_STEP DEFROST STEP 10 (b'0xa') added ENUM_IN_SG_READY_MODE_STATE ACTIVE (b'0x2') added New configuration point allowControl to allow control of the Samsung EHS heat pump (deactivated by default). [!CAUTION] This functionality requires that EHS-Sentinel actively communicates with the Samsung EHS, so EHS-Sentinel intervenes here in the Modbus data traffic between the components (it sends its own messages). The activation of this functionality is exclusively at your own risk. I assume no liability for any damage caused. new configuration points in logging controlMessage (default False) to print out the controlled mesagges invalidPacket (default False) prints out invalid messages (length not ok, x34 not at end...) Dashboard template has been split, ressources/dashboard_readonly_template.yaml is for readonly mode and the ressources/dashboard_controlmode_template.yaml for control mode
62 lines
2.2 KiB
Python
62 lines
2.2 KiB
Python
import logging
|
|
import inspect
|
|
|
|
class IndentFormatter(logging.Formatter):
|
|
"""
|
|
A custom logging formatter that adds indentation based on the call stack depth
|
|
and includes the function name in the log record.
|
|
Attributes:
|
|
baseline (int): The baseline stack depth when the formatter is initialized.
|
|
Methods:
|
|
__init__(fmt=None, datefmt=None):
|
|
Initializes the IndentFormatter with optional format and date format.
|
|
format(rec):
|
|
Formats the specified record as text, adding indentation and function name.
|
|
"""
|
|
grey = "\x1b[38;20m"
|
|
yellow = "\x1b[33;20m"
|
|
red = "\x1b[31;20m"
|
|
bold_red = "\x1b[31;1m"
|
|
reset = "\x1b[0m"
|
|
format = "%(asctime)s - %(name)s - %(levelname)s - %(message)s (%(filename)s:%(lineno)d)"
|
|
|
|
FORMATS = {
|
|
logging.DEBUG: grey + format + reset,
|
|
logging.INFO: grey + format + reset,
|
|
logging.WARNING: yellow + format + reset,
|
|
logging.ERROR: red + format + reset,
|
|
logging.CRITICAL: bold_red + format + reset
|
|
}
|
|
|
|
|
|
def __init__( self, fmt=None, datefmt=None ):
|
|
logging.Formatter.__init__(self, fmt, datefmt)
|
|
self.baseline = len(inspect.stack())
|
|
|
|
def format( self, rec ):
|
|
log_fmt = self.FORMATS.get(rec.levelno)
|
|
formatter = logging.Formatter(log_fmt)
|
|
|
|
stack = inspect.stack()
|
|
rec.indent = ' '*(len(stack)-self.baseline-3)
|
|
rec.function = stack[8][3]
|
|
out = logging.Formatter.format(self, rec)
|
|
del rec.indent; del rec.function
|
|
return out
|
|
|
|
# The following code sets up a custom logger with indentation support.
|
|
# It creates a custom formatter, a logger instance, and a stream handler.
|
|
# The custom formatter is set to the handler, which is then added to the logger.
|
|
# Finally, the logging level is set to INFO.
|
|
|
|
formatter = IndentFormatter("%(asctime)s - (%(filename)30s:%(lineno)-3d) - [%(levelname)-7s]: %(indent)s%(message)s ")
|
|
logger = logging.getLogger('logger')
|
|
handler = logging.StreamHandler()
|
|
handler.setFormatter(formatter)
|
|
logger.addHandler(handler)
|
|
logger.setLevel(logging.INFO)
|
|
|
|
def setDebugMode():
|
|
logger.setLevel(logging.DEBUG)
|
|
logger.debug("Debug mode is on...")
|