mirror of
https://github.com/lumapu/ahoy.git
synced 2025-08-04 00:48:24 +02:00
Merge pull request #910 from betacentauri/main
Raspberry Pi: Add log file rotation
This commit is contained in:
commit
685a2c81bd
3 changed files with 16 additions and 1 deletions
|
@ -7,6 +7,8 @@ ahoy:
|
|||
filename: 'hoymiles.log'
|
||||
# DEBUG, INFO, WARNING, ERROR, FATAL
|
||||
level: 'INFO'
|
||||
max_log_filesize: 1000000
|
||||
max_log_files: 1
|
||||
|
||||
sunset:
|
||||
disabled: false
|
||||
|
|
|
@ -19,6 +19,7 @@ import yaml
|
|||
from yaml.loader import SafeLoader
|
||||
import hoymiles
|
||||
import logging
|
||||
from logging.handlers import RotatingFileHandler
|
||||
|
||||
################################################################################
|
||||
""" Signal Handler """
|
||||
|
@ -298,6 +299,8 @@ def init_logging(ahoy_config):
|
|||
log_config = ahoy_config.get('logging')
|
||||
fn = 'hoymiles.log'
|
||||
lvl = logging.ERROR
|
||||
max_log_filesize = 1000000
|
||||
max_log_files = 1
|
||||
if log_config:
|
||||
fn = log_config.get('filename', fn)
|
||||
level = log_config.get('level', 'ERROR')
|
||||
|
@ -311,9 +314,11 @@ def init_logging(ahoy_config):
|
|||
lvl = logging.ERROR
|
||||
elif level == 'FATAL':
|
||||
lvl = logging.FATAL
|
||||
max_log_filesize = log_config.get('max_log_filesize', max_log_filesize)
|
||||
max_log_files = log_config.get('max_log_files', max_log_files)
|
||||
if hoymiles.HOYMILES_TRANSACTION_LOGGING:
|
||||
lvl = logging.DEBUG
|
||||
logging.basicConfig(filename=fn, format='%(asctime)s %(levelname)s: %(message)s', datefmt='%Y-%m-%d %H:%M:%S', level=lvl)
|
||||
logging.basicConfig(handlers=[RotatingFileHandler(fn, maxBytes=max_log_filesize, backupCount=max_log_files)], format='%(asctime)s %(levelname)s: %(message)s', datefmt='%Y-%m-%d %H:%M:%S', level=lvl)
|
||||
dtu_name = ahoy_config.get('dtu',{}).get('name','hoymiles-dtu')
|
||||
logging.info(f'start logging for {dtu_name} with level: {logging.root.level}')
|
||||
|
||||
|
|
|
@ -515,9 +515,17 @@ class Hm300Decode0B(StatusResponse):
|
|||
""" reactive power """
|
||||
return self.unpack('>H', 20)[0]/10
|
||||
@property
|
||||
def powerfactor(self):
|
||||
""" Powerfactor """
|
||||
return self.unpack('>H', 24)[0]/1000
|
||||
@property
|
||||
def temperature(self):
|
||||
""" Inverter temperature in °C """
|
||||
return self.unpack('>h', 26)[0]/10
|
||||
@property
|
||||
def event_count(self):
|
||||
""" Event counter """
|
||||
return self.unpack('>H', 28)[0]
|
||||
|
||||
class Hm300Decode0C(Hm300Decode0B):
|
||||
""" 1121-series mirco-inverters status data """
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue