diff options
author | Evgeny Zinoviev <me@ch1p.io> | 2022-09-02 13:37:49 +0300 |
---|---|---|
committer | Evgeny Zinoviev <me@ch1p.io> | 2022-09-02 13:38:02 +0300 |
commit | c7e10c52a9cd5be57e86e4e911bd21d6380771a6 (patch) | |
tree | e1115e551d9fdb64048fa7ba1a2561d96c7eadb8 | |
parent | 06ca251b94e06b8fe58437704a7ada716d3056b0 (diff) |
inverter: support inverter-tools 1.5.0
-rw-r--r-- | localwebsite/handlers/InverterHandler.php | 8 | ||||
-rw-r--r-- | src/home/database/inverter.py | 8 | ||||
-rw-r--r-- | src/home/inverter/monitor.py | 6 | ||||
-rw-r--r-- | src/home/mqtt/message/inverter.py | 8 | ||||
-rwxr-xr-x | src/inverter_bot.py | 16 | ||||
-rwxr-xr-x | src/inverter_mqtt_receiver.py | 4 | ||||
-rwxr-xr-x | test/test_inverter_monitor.py | 16 |
7 files changed, 33 insertions, 33 deletions
diff --git a/localwebsite/handlers/InverterHandler.php b/localwebsite/handlers/InverterHandler.php index 8fb5d74..78fc1ab 100644 --- a/localwebsite/handlers/InverterHandler.php +++ b/localwebsite/handlers/InverterHandler.php @@ -40,12 +40,12 @@ class InverterHandler extends RequestHandler $charging_rate = ''; if ($power_direction == 'charging') $charging_rate = sprintf(' @ %s %s', - $status['battery_charging_current']['value'], - $status['battery_charging_current']['unit']); + $status['battery_charge_current']['value'], + $status['battery_charge_current']['unit']); else if ($power_direction == 'discharging') $charging_rate = sprintf(' @ %s %s', - $status['battery_discharging_current']['value'], - $status['battery_discharging_current']['unit']); + $status['battery_discharge_current']['value'], + $status['battery_discharge_current']['unit']); $html = sprintf('<b>Battery:</b> %s %s', $status['battery_voltage']['value'], diff --git a/src/home/database/inverter.py b/src/home/database/inverter.py index 8902f04..6fdf9d7 100644 --- a/src/home/database/inverter.py +++ b/src/home/database/inverter.py @@ -24,8 +24,8 @@ class InverterDatabase: battery_voltage: int, battery_voltage_scc: int, battery_voltage_scc2: int, - battery_discharging_current: int, - battery_charging_current: int, + battery_discharge_current: int, + battery_charge_current: int, battery_capacity: int, inverter_heat_sink_temp: int, mppt1_charger_temp: int, @@ -83,8 +83,8 @@ class InverterDatabase: battery_voltage, battery_voltage_scc, battery_voltage_scc2, - battery_discharging_current, - battery_charging_current, + battery_discharge_current, + battery_charge_current, battery_capacity, inverter_heat_sink_temp, mppt1_charger_temp, diff --git a/src/home/inverter/monitor.py b/src/home/inverter/monitor.py index 444d3bc..87e07be 100644 --- a/src/home/inverter/monitor.py +++ b/src/home/inverter/monitor.py @@ -131,7 +131,7 @@ class InverterMonitor(Thread): def run(self): # Check allowed currents and validate the config. - allowed_currents = list(inverter.exec('get-allowed-ac-charging-currents')['data']) + allowed_currents = list(inverter.exec('get-allowed-ac-charge-currents')['data']) allowed_currents.sort() for a in self.currents: @@ -397,10 +397,10 @@ class InverterMonitor(Thread): def set_hw_charging_current(self, current: int): try: - response = inverter.exec('set-max-ac-charging-current', (0, current)) + response = inverter.exec('set-max-ac-charge-current', (0, current)) if response['result'] != 'ok': logger.error(f'failed to change AC charging current to {current} A') - raise InverterError('set-max-ac-charging-current: inverterd reported error') + raise InverterError('set-max-ac-charge-current: inverterd reported error') else: self.charging_event_handler(ChargingEvent.AC_CURRENT_CHANGED, current=current) logger.info(f'changed AC charging current to {current} A') diff --git a/src/home/mqtt/message/inverter.py b/src/home/mqtt/message/inverter.py index 2df17e5..d36aad5 100644 --- a/src/home/mqtt/message/inverter.py +++ b/src/home/mqtt/message/inverter.py @@ -29,8 +29,8 @@ class Status: int(data['battery_voltage'] * 10), int(data['battery_voltage_scc'] * 10), int(data['battery_voltage_scc2'] * 10), - data['battery_discharging_current'], - data['battery_charging_current'], + data['battery_discharge_current'], + data['battery_charge_current'], data['battery_capacity'], data['inverter_heat_sink_temp'], data['mppt1_charger_temp'], @@ -55,8 +55,8 @@ class Status: 'battery_voltage': data[8] / 10, 'battery_voltage_scc': data[9] / 10, 'battery_voltage_scc2': data[10] / 10, - 'battery_discharging_current': data[11], - 'battery_charging_current': data[12], + 'battery_discharge_current': data[11], + 'battery_charge_current': data[12], 'battery_capacity': data[13], 'inverter_heat_sink_temp': data[14], 'mppt1_charger_temp': data[15], diff --git a/src/inverter_bot.py b/src/inverter_bot.py index b8a01c4..54b17c8 100755 --- a/src/inverter_bot.py +++ b/src/inverter_bot.py @@ -145,11 +145,11 @@ def status(ctx: Context) -> None: if power_direction == 'charging': charging_rate = f'{chrg_at}%s %s' % ( - gs['battery_charging_current']['value'], gs['battery_charging_current']['unit']) + gs['battery_charge_current']['value'], gs['battery_charge_current']['unit']) pd_label = ctx.lang('pd_charging') elif power_direction == 'discharging': charging_rate = f'{chrg_at}%s %s' % ( - gs['battery_discharging_current']['value'], gs['battery_discharging_current']['unit']) + gs['battery_discharge_current']['value'], gs['battery_discharge_current']['unit']) pd_label = ctx.lang('pd_discharging') else: pd_label = ctx.lang('pd_nothing') @@ -206,14 +206,14 @@ def generation(ctx: Context) -> None: def setgencc(ctx: Context) -> None: - allowed_values = inverter.exec('get-allowed-ac-charging-currents')['data'] + allowed_values = inverter.exec('get-allowed-ac-charge-currents')['data'] try: current = int(ctx.args[0]) if current not in allowed_values: raise ValueError(f'invalid value {current}') - response = inverter.exec('set-max-ac-charging-current', (0, current)) + response = inverter.exec('set-max-ac-charge-current', (0, current)) ctx.reply('OK' if response['result'] == 'ok' else 'ERROR') # TODO notify monitor @@ -230,7 +230,7 @@ def setgenct(ctx: Context) -> None: dv = float(ctx.args[1]) if 44 <= cv <= 51 and 48 <= dv <= 58: - response = inverter.exec('set-charging-thresholds', (cv, dv)) + response = inverter.exec('set-charge-thresholds', (cv, dv)) ctx.reply('OK' if response['result'] == 'ok' else 'ERROR') else: raise ValueError('invalid values') @@ -254,8 +254,8 @@ def setacmode(mode: ACMode): logger.debug(f'setacmode: mode={mode}, cv={cv}, dv={dv}, a={a}') - inverter.exec('set-charging-thresholds', (cv, dv)) - inverter.exec('set-max-ac-charging-current', (0, a)) + inverter.exec('set-charge-thresholds', (cv, dv)) + inverter.exec('set-max-ac-charge-current', (0, a)) def setacmode_start(ctx: Context) -> None: @@ -318,7 +318,7 @@ def setbatuv(ctx: Context) -> None: v = float(ctx.args[0]) if 40.0 <= v <= 48.0: - response = inverter.exec('set-battery-cut-off-voltage', (v,)) + response = inverter.exec('set-battery-cutoff-voltage', (v,)) ctx.reply('OK' if response['result'] == 'ok' else 'ERROR') else: raise ValueError('invalid voltage') diff --git a/src/inverter_mqtt_receiver.py b/src/inverter_mqtt_receiver.py index dd61d9a..d3a487b 100755 --- a/src/inverter_mqtt_receiver.py +++ b/src/inverter_mqtt_receiver.py @@ -48,8 +48,8 @@ class MQTTReceiver(MQTTBase): battery_voltage=int(data['battery_voltage'] * 10), battery_voltage_scc=int(data['battery_voltage_scc'] * 10), battery_voltage_scc2=int(data['battery_voltage_scc2'] * 10), - battery_discharging_current=data['battery_discharging_current'], - battery_charging_current=data['battery_charging_current'], + battery_discharge_current=data['battery_discharge_current'], + battery_charge_current=data['battery_charge_current'], battery_capacity=data['battery_capacity'], inverter_heat_sink_temp=data['inverter_heat_sink_temp'], mppt1_charger_temp=data['mppt1_charger_temp'], diff --git a/test/test_inverter_monitor.py b/test/test_inverter_monitor.py index cbf1b82..3b1c6b0 100755 --- a/test/test_inverter_monitor.py +++ b/test/test_inverter_monitor.py @@ -143,8 +143,8 @@ class InverterEmulator(threading.Thread): "battery_voltage": {"unit": "V", "value": 48.4}, "battery_voltage_scc": {"unit": "V", "value": 0.0}, "battery_voltage_scc2": {"unit": "V", "value": 0.0}, - "battery_discharging_current": {"unit": "A", "value": 0}, - "battery_charging_current": {"unit": "A", "value": 0}, + "battery_discharge_current": {"unit": "A", "value": 0}, + "battery_charge_current": {"unit": "A", "value": 0}, "battery_capacity": {"unit": "%", "value": 62}, "inverter_heat_sink_temp": {"unit": "°C", "value": 8}, "mppt1_charger_temp": {"unit": "°C", "value": 0}, @@ -175,15 +175,15 @@ class InverterEmulator(threading.Thread): "battery_bulk_voltage": {"unit": "V", "value": 57.6}, "battery_float_voltage": {"unit": "V", "value": 54.0}, "battery_type": "User", - "max_charging_current": {"unit": "A", "value": 60}, - "max_ac_charging_current": {"unit": "A", "value": 10}, + "max_charge_current": {"unit": "A", "value": 60}, + "max_ac_charge_current": {"unit": "A", "value": 10}, "input_voltage_range": "Appliance", "output_source_priority": "Parallel output", "charge_source_priority": "Solar-and-Utility", "parallel_max_num": 6, "machine_type": "Off-Grid-Tie", "topology": "Transformer-less", - "output_model_setting": "Single module", + "output_mode": "Single output", "solar_power_priority": "Load-Battery-Utility", "mppt": "2"} @@ -234,13 +234,13 @@ class InverterEmulator(threading.Thread): args = command[1:] command = command[0] - if command == 'get-allowed-ac-charging-currents': + if command == 'get-allowed-ac-charge-currents': self.reply_ok(conn, [2, 10, 20, 30, 40, 50, 60]) elif command == 'get-status': self.reply_ok(conn, self._get_status()) elif command == 'get-rated': self.reply_ok(conn, self._get_rated()) - elif command == 'set-max-ac-charging-current': + elif command == 'set-max-ac-charge-current': self.set_ac_current(args[1]) self.reply_ok(conn, 1) else: @@ -307,7 +307,7 @@ class InverterEmulator(threading.Thread): def set_ac_current(self, amps): with self.lock: - self.rated['max_ac_charging_current']['value'] = amps + self.rated['max_ac_charge_current']['value'] = amps charger.current_changed(amps) def set_pd(self, pd: BatteryPowerDirection): |