Skip to content

Commit ec347f9

Browse files
authored
issue METER_NO_SERIAL_NUMBER msg only in log (#2786)
* issue METER_NO_SERIAL_NUMBER msg only in log * pytest * falke8
1 parent 3293ced commit ec347f9

2 files changed

Lines changed: 8 additions & 8 deletions

File tree

packages/modules/common/hardware_check.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import logging
12
import pymodbus
23
from typing import Any, Optional, Protocol, Tuple, Union
34

@@ -6,6 +7,9 @@
67
from modules.common.fault_state import FaultState
78
from modules.common.modbus import ModbusSerialClient_, ModbusTcpClient_
89

10+
log = logging.getLogger(__name__)
11+
12+
913
EVSE_MIN_FIRMWARE = 7
1014

1115
OPEN_TICKET = (" Bitte nehme bei anhaltenden Problemen über die Support-Funktion in den Einstellungen Kontakt mit " +
@@ -97,9 +101,7 @@ def request_and_check_hardware(self: ClientHandlerProtocol,
97101
else:
98102
raise Exception(meter_error_msg + OPEN_TICKET)
99103
elif evse_check_passed and meter_check_passed and meter_error_msg is not None:
100-
if meter_error_msg != METER_NO_SERIAL_NUMBER:
101-
meter_error_msg += OPEN_TICKET
102-
fault_state.warning(meter_error_msg)
104+
fault_state.warning(meter_error_msg + OPEN_TICKET)
103105
if evse_check_passed is False:
104106
if meter_error_msg is not None:
105107
raise Exception(EVSE_BROKEN + " " + meter_error_msg + OPEN_TICKET)
@@ -112,7 +114,7 @@ def check_meter(self: ClientHandlerProtocol) -> Tuple[bool, Optional[str], Count
112114
with self.client:
113115
counter_state = self.meter_client.get_counter_state()
114116
if counter_state.serial_number == "0" or counter_state.serial_number is None:
115-
return True, METER_NO_SERIAL_NUMBER, counter_state
117+
log.warning(METER_NO_SERIAL_NUMBER)
116118
return True, _check_meter_values(counter_state), counter_state
117119
except Exception:
118120
return False, METER_PROBLEM, None

packages/modules/common/hardware_check_test.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@
88
from modules.common.component_state import CounterState, EvseState
99
from modules.common.evse import Evse
1010
from modules.common.hardware_check import (
11-
EVSE_BROKEN, LAN_ADAPTER_BROKEN, METER_BROKEN_VOLTAGES, METER_NO_SERIAL_NUMBER,
12-
METER_PROBLEM, OPEN_TICKET, USB_ADAPTER_BROKEN,
11+
EVSE_BROKEN, LAN_ADAPTER_BROKEN, METER_BROKEN_VOLTAGES, METER_PROBLEM, OPEN_TICKET, USB_ADAPTER_BROKEN,
1312
SeriesHardwareCheckMixin, _check_meter_values)
1413
from modules.common.modbus import NO_CONNECTION, ModbusSerialClient_, ModbusTcpClient_
1514
from modules.conftest import SAMPLE_IP, SAMPLE_PORT
@@ -112,8 +111,7 @@ def test_check_meter_values_voltages(voltages, power, expected_msg, monkeypatch)
112111

113112
@patch('modules.common.hardware_check.ClientHandlerProtocol')
114113
@pytest.mark.parametrize("serial_number, voltages, expected",
115-
[("0", [230]*3, (True, METER_NO_SERIAL_NUMBER, CounterState)),
116-
(12345, [230]*3, (True, None, CounterState)),
114+
[(12345, [230]*3, (True, None, CounterState)),
117115
(Exception(), [230]*3, (False, METER_PROBLEM, None))])
118116
def test_check_meter(
119117
MockClientHandlerProtocol: Mock,

0 commit comments

Comments
 (0)