# Path: mppsolar/protocols/pi30.py
# class pi30(AbstractProtocol):
#     def __init__(self, *args, **kwargs) -> None:
#         super().__init__()
#         self._protocol_id = b"PI30"
#         self.COMMANDS = COMMANDS
#         self.STATUS_COMMANDS = ["QPIGS", "Q1"]
#         self.SETTINGS_COMMANDS = ["QPIRI", "QFLAG"]
#         self.DEFAULT_COMMAND = "QPI"
#         # log.info(f'Using protocol {self._protocol_id} with {len(self.COMMANDS)} commands')
# 
#     def check_response_valid(self, response):
#         if response is None:
#             return False, {"ERROR": ["No response", ""]}
#         if len(response) <= 3:
#             return False, {"ERROR": ["Response to short", ""]}
# 
#         if type(response) is str:
#             if "(NAK" in response:
#                 return False, {"ERROR": ["NAK", ""]}
#             crc_high, crc_low = crc(response[:-3])
#             if [ord(response[-3]), ord(response[-2])] != [crc_high, crc_low]:
#                 return False, {"ERROR": ["Invalid response CRCs", ""]}
#         elif type(response) is bytes:
#             if b"(NAK" in response:
#                 return False, {"ERROR": ["NAK", ""]}
# 
#             crc_high, crc_low = crc(response[:-3])
#             if response[-3:-1] != bytes([crc_high, crc_low]):
#                 return False, {"ERROR": ["Invalid response CRC", ""]}
#         log.debug("CRCs match")
#         return True, {}


import logging
from .pi30 import pi30
                ],
            ],
            ["float", "Battery Redischarge Voltage", "V"],
            [
                "option",
                "PV OK Condition",
                [
                    "As long as one unit of inverters has connect PV, parallel system will consider PV OK",
                    "Only All of inverters have connect PV, parallel system will consider PV OK",
                ],
            ],
            [
                "option",
                "PV Power Balance",
                [
                    "PV input max current will be the max charged current",
                    "PV input max power will be the sum of the max charged power and loads power",
                ],
            ],
            ["int", "Max Charging Time at CV Stage", "min"],
        ],
        "test_responses": [
            b"(230.0 21.7 230.0 50.0 21.7 5000 4000 48.0 46.0 42.0 56.4 54.0 0 10 010 1 0 0 6 01 0 0 54.0 0 1 60\x83\xAA\r",
            b"(120.0 20.8 120.0 60.0 20.8 2500 2500 48.0 47.0 43.0 56.1 56.1 2 40 060 0 0 0 9 01 0 6 55.0 0 1 000\xBE\xAC\r",
            b"(NAK\x73\x73\r",
        ],
    },
}



# Path: mppsolar/protocols/pi30.py
# class pi30(AbstractProtocol):
#     def __init__(self, *args, **kwargs) -> None:
#         super().__init__()
#         self._protocol_id = b"PI30"
#         self.COMMANDS = COMMANDS
#         self.STATUS_COMMANDS = ["QPIGS", "Q1"]
#         self.SETTINGS_COMMANDS = ["QPIRI", "QFLAG"]
#         self.DEFAULT_COMMAND = "QPI"
#         # log.info(f'Using protocol {self._protocol_id} with {len(self.COMMANDS)} commands')
# 
#     def check_response_valid(self, response):
#         if response is None:
#             return False, {"ERROR": ["No response", ""]}
#         if len(response) <= 3:
#             return False, {"ERROR": ["Response to short", ""]}
# 
#         if type(response) is str:
#             if "(NAK" in response:
#                 return False, {"ERROR": ["NAK", ""]}
#             crc_high, crc_low = crc(response[:-3])
#             if [ord(response[-3]), ord(response[-2])] != [crc_high, crc_low]:
#                 return False, {"ERROR": ["Invalid response CRCs", ""]}
#         elif type(response) is bytes:
#             if b"(NAK" in response:
#                 return False, {"ERROR": ["NAK", ""]}
# 
#             crc_high, crc_low = crc(response[:-3])
#             if response[-3:-1] != bytes([crc_high, crc_low]):
#                 return False, {"ERROR": ["Invalid response CRC", ""]}
#         log.debug("CRCs match")
#         return True, {}


# Path: mppsolar/protocols/pi41.py
import logging
from .pi30 import pi30

                ],
            ],
            ["float", "Battery Redischarge Voltage", "V"],
            [
                "option",
                "PV OK Condition",
                [
                    "As long as one unit of inverters has connect PV, parallel system will consider PV OK",
                    "Only All of inverters have connect PV, parallel system will consider PV OK",
                ],
            ],
            [
                "option",
                "PV Power Balance",
                [
                    "PV input max current will be the max charged current",
                    "PV input max power will be the sum of the max charged power and loads power",
                ],
            ],
            ["int", "Max Charging Time at CV Stage", "min"],
        ],
        "test_responses": [
            b"(230.0 21.7 230.0 50.0 21.7 5000 4000 48.0 46.0 42.0 56.4 54.0 0 10 010 1 0 0 6 01 0 0 54.0 0 1 60\x83\xAA\r",
            b"(120.0 20.8 120.0 60.0 20.8 2500 2500 48.0 47.0 43.0 56.1 56.1 2 40 060 0 0 0 9 01 0 6 55.0 0 1 000\xBE\xAC\r",
            b"(NAK\x73\x73\r",
        ],
    },
}



class pi41(pi30):