diff --git a/app/src/gen3plus/solarman_v5.py b/app/src/gen3plus/solarman_v5.py index 38d9eb9..6f1e96c 100644 --- a/app/src/gen3plus/solarman_v5.py +++ b/app/src/gen3plus/solarman_v5.py @@ -247,6 +247,7 @@ class SolarmanBase(Message): class SolarmanV5(SolarmanBase): AT_CMD = 1 MB_RTU_CMD = 2 + DCU_CMD = 5 AT_CMD_RSP = 8 MB_CLIENT_DATA_UP = 30 '''Data up time in client mode''' @@ -532,6 +533,24 @@ class SolarmanV5(SolarmanBase): except Exception: self.ifc.tx_clear() + def send_dcu_cmd(self, pdu: bytearray): + if self.sensor_list != 0x3026: + logger.debug(f'[{self.node_id}] DCU CMD not allowed,' + f' for sensor: {self.sensor_list:#04x}') + return + + if self.state != State.up: + logger.warning(f'[{self.node_id}] ignore DCU CMD,' + ' cause the state is not UP anymore') + return + self._build_header(0x4510) + self.ifc.tx_add(struct.pack(' 8000: + logger_mqtt.error('dcu_power: value must be in' + 'the range 100..800,' + f' got: {payload}') + else: + pdu = struct.pack('>BBBBBBH', 1, 1, 6, 1, 0, 1, val) + for fnc in self.each_inverter(message, "send_dcu_cmd"): + fnc(pdu) + except Exception: + pass + if message.topic.matches(self.mb_reads_topic): await self.modbus_cmd(message, Modbus.READ_REGS, 2)