Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions packages/modules/common/hardware_check.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import logging
import pymodbus
from typing import Any, Optional, Protocol, Tuple, Union

Expand All @@ -6,6 +7,9 @@
from modules.common.fault_state import FaultState
from modules.common.modbus import ModbusSerialClient_, ModbusTcpClient_

log = logging.getLogger(__name__)


EVSE_MIN_FIRMWARE = 7

OPEN_TICKET = (" Bitte nehme bei anhaltenden Problemen über die Support-Funktion in den Einstellungen Kontakt mit " +
Expand Down Expand Up @@ -97,9 +101,7 @@ def request_and_check_hardware(self: ClientHandlerProtocol,
else:
raise Exception(meter_error_msg + OPEN_TICKET)
elif evse_check_passed and meter_check_passed and meter_error_msg is not None:
if meter_error_msg != METER_NO_SERIAL_NUMBER:
meter_error_msg += OPEN_TICKET
fault_state.warning(meter_error_msg)
fault_state.warning(meter_error_msg + OPEN_TICKET)
if evse_check_passed is False:
if meter_error_msg is not None:
raise Exception(EVSE_BROKEN + " " + meter_error_msg + OPEN_TICKET)
Expand All @@ -112,7 +114,7 @@ def check_meter(self: ClientHandlerProtocol) -> Tuple[bool, Optional[str], Count
with self.client:
counter_state = self.meter_client.get_counter_state()
if counter_state.serial_number == "0" or counter_state.serial_number is None:
return True, METER_NO_SERIAL_NUMBER, counter_state
log.warning(METER_NO_SERIAL_NUMBER)
return True, _check_meter_values(counter_state), counter_state
except Exception:
return False, METER_PROBLEM, None
6 changes: 2 additions & 4 deletions packages/modules/common/hardware_check_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
from modules.common.component_state import CounterState, EvseState
from modules.common.evse import Evse
from modules.common.hardware_check import (
EVSE_BROKEN, LAN_ADAPTER_BROKEN, METER_BROKEN_VOLTAGES, METER_NO_SERIAL_NUMBER,
METER_PROBLEM, OPEN_TICKET, USB_ADAPTER_BROKEN,
EVSE_BROKEN, LAN_ADAPTER_BROKEN, METER_BROKEN_VOLTAGES, METER_PROBLEM, OPEN_TICKET, USB_ADAPTER_BROKEN,
SeriesHardwareCheckMixin, _check_meter_values)
from modules.common.modbus import NO_CONNECTION, ModbusSerialClient_, ModbusTcpClient_
from modules.conftest import SAMPLE_IP, SAMPLE_PORT
Expand Down Expand Up @@ -112,8 +111,7 @@ def test_check_meter_values_voltages(voltages, power, expected_msg, monkeypatch)

@patch('modules.common.hardware_check.ClientHandlerProtocol')
@pytest.mark.parametrize("serial_number, voltages, expected",
[("0", [230]*3, (True, METER_NO_SERIAL_NUMBER, CounterState)),
(12345, [230]*3, (True, None, CounterState)),
[(12345, [230]*3, (True, None, CounterState)),
(Exception(), [230]*3, (False, METER_PROBLEM, None))])
def test_check_meter(
MockClientHandlerProtocol: Mock,
Expand Down