Skip to content

Commit 6b2e0d8

Browse files
committed
Add a notice to the loggers name to make to easier to identify actions taken by a user manually
1 parent 9f52061 commit 6b2e0d8

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

inverter

+5-3
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,14 @@ SCRIPT_DIR="$(dirname "$(readlink -f "$0")")"
55
source "${SCRIPT_DIR}"/.venv/bin/activate
66
cd "${SCRIPT_DIR}"/source || exit 1
77

8-
read -r -d '' inverter_setup_code <<'EOF'
8+
read -r -d '' inverter_setup_code <<EOF
9+
from logger import LoggerMixin
910
from goodwe.et import OperationMode
1011
from inverter import Inverter
1112
12-
inverter = Inverter()
13-
inverter.log.info("Inverter is manually controlled by a user")
13+
LoggerMixin().log.info("Inverter is manually controlled by the user ${USER}")
14+
15+
inverter = Inverter(True)
1416
EOF
1517

1618

source/inverter.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,19 @@
1010

1111

1212
class Inverter(LoggerMixin):
13-
def __init__(self):
13+
def __init__(self, controlled_by_bash_script: bool = False):
1414
super().__init__()
1515

1616
self._device = None
1717
self.hostname = EnvironmentVariableGetter.get("INVERTER_HOSTNAME")
1818

1919
self.sems_portal_api_handler = SemsPortalApiHandler()
20+
21+
# Add a notice to the loggers name to make to easier to identify actions taken by a user manually
22+
if controlled_by_bash_script:
23+
self.log.name += " USER"
24+
self.sems_portal_api_handler.log.name += " USER"
25+
2026
self.battery_capacity = None
2127
# We have to pull the battery capacity at startup since there are functions here that require it which are
2228
# called when using the bash script to control the inverter manually

0 commit comments

Comments
 (0)