From 6af96ae8d65d16e17079b60d010ab439f773134a Mon Sep 17 00:00:00 2001 From: Evgeny Zinoviev Date: Sun, 16 May 2021 03:08:04 +0300 Subject: readme fix --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index abc44a0..7a3e6e9 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ Create environment configuration file `/etc/default/inverter-bot`: ``` TOKEN="YOUR_TOKEN" USERS="ID ID ID ..." -OPTS="" # here you can pass other options such as --inverterd-host +PARAMS="" # here you can pass other options such as --inverterd-host ``` Create systemd service file `/etc/systemd/system/inverter-bot.service` with the following content (changing stuff like paths): -- cgit v1.2.3 From ef00f7d6695f924fa6f50ab954da12a263d840fb Mon Sep 17 00:00:00 2001 From: Evgeny Zinoviev Date: Sun, 16 May 2021 03:11:36 +0300 Subject: delete obsolete file --- test.py | 35 ----------------------------------- 1 file changed, 35 deletions(-) delete mode 100644 test.py diff --git a/test.py b/test.py deleted file mode 100644 index 79ac277..0000000 --- a/test.py +++ /dev/null @@ -1,35 +0,0 @@ -import json, re -from pprint import pprint - - -s = '{"result":"ok","data":{"grid_voltage":{"unit":"V","value":0.0},"grid_freq":{"unit":"Hz","value":0.0},"ac_output_voltage":{"unit":"V","value":230.0},"ac_output_freq":{"unit":"Hz","value":50.0},"ac_output_apparent_power":{"unit":"VA","value":115},"ac_output_active_power":{"unit":"Wh","value":18},"output_load_percent":{"unit":"%","value":2},"battery_voltage":{"unit":"V","value":50.0},"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_capacity":{"unit":"%","value":78},"inverter_heat_sink_temp":{"unit":"°C","value":19},"mppt1_charger_temp":{"unit":"°C","value":0},"mppt2_charger_temp":{"unit":"°C","value":0},"pv1_input_power":{"unit":"Wh","value":1000},"pv2_input_power":{"unit":"Wh","value":0},"pv1_input_voltage":{"unit":"V","value":0.0},"pv2_input_voltage":{"unit":"V","value":0.0},"settings_values_changed":"Custom","mppt1_charger_status":"Abnormal","mppt2_charger_status":"Abnormal","load_connected":"Connected","battery_power_direction":"Discharge","dc_ac_power_direction":"DC/AC","line_power_direction":"Do nothing","local_parallel_id":0}}' - -if __name__ == '__main__': - gs = json.loads(s)['data'] - # pprint(gs) - - # render response - power_direction = gs['battery_power_direction'].lower() - power_direction = re.sub(r'ge$', 'ging', power_direction) - - charging_rate = '' - if power_direction == 'charging': - charging_rate = ' @ %s %s' % (gs['battery_charging_current']['value'], gs['battery_charging_current']['unit']) - elif power_direction == 'discharging': - charging_rate = ' @ %s %s' % (gs['battery_discharging_current']['value'], gs['battery_discharging_current']['unit']) - - html = 'Battery: %s %s' % (gs['battery_voltage']['value'], gs['battery_voltage']['unit']) - html += ' (%s%s, ' % (gs['battery_capacity']['value'], gs['battery_capacity']['unit']) - html += '%s%s)' % (power_direction, charging_rate) - - html += '\nLoad: %s %s' % (gs['ac_output_active_power']['value'], gs['ac_output_active_power']['unit']) - html += ' (%s%%)' % (gs['output_load_percent']['value']) - - if gs['pv1_input_power']['value'] > 0: - html += '\nInput power: %s%s' % (gs['pv1_input_power']['value'], gs['pv1_input_power']['unit']) - - if gs['grid_voltage']['value'] > 0 or gs['grid_freq']['value'] > 0: - html += '\nGenerator: %s %s' % (gs['grid_voltage']['unit'], gs['grid_voltage']['value']) - html += ', %s %s' % (gs['grid_freq']['value'], gs['grid_freq']['unit']) - - print(html) \ No newline at end of file -- cgit v1.2.3 From 302b3a78bd7a61be877daa66f81d406189b7ef62 Mon Sep 17 00:00:00 2001 From: Evgeny Zinoviev Date: Sun, 16 May 2021 15:18:48 +0300 Subject: don't send telegram.error.TimedOut to user --- inverter-bot | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/inverter-bot b/inverter-bot index 921b185..b9937e4 100755 --- a/inverter-bot +++ b/inverter-bot @@ -21,6 +21,7 @@ from telegram.ext import ( MessageHandler, CallbackContext ) +from telegram.error import TimedOut class InverterClientWrapper: @@ -121,7 +122,8 @@ def msg_status(update: Update, context: CallbackContext) -> None: reply(update, html) except Exception as e: logging.exception(str(e)) - reply(update, 'exception: ' + str(e)) + if not isinstance(e, TimedOut): + reply(update, 'exception: ' + str(e)) def msg_generation(update: Update, context: CallbackContext) -> None: @@ -161,7 +163,8 @@ def msg_generation(update: Update, context: CallbackContext) -> None: reply(update, html) except Exception as e: logging.exception(str(e)) - reply(update, 'exception: ' + str(e)) + if not isinstance(e, TimedOut): + reply(update, 'exception: ' + str(e)) def msg_gs(update: Update, context: CallbackContext) -> None: @@ -170,7 +173,8 @@ def msg_gs(update: Update, context: CallbackContext) -> None: reply(update, status) except Exception as e: logging.exception(str(e)) - reply(update, 'exception: ' + str(e)) + if not isinstance(e, TimedOut): + reply(update, 'exception: ' + str(e)) def msg_ri(update: Update, context: CallbackContext) -> None: @@ -179,7 +183,8 @@ def msg_ri(update: Update, context: CallbackContext) -> None: reply(update, rated) except Exception as e: logging.exception(str(e)) - reply(update, 'exception: ' + str(e)) + if not isinstance(e, TimedOut): + reply(update, 'exception: ' + str(e)) def msg_errors(update: Update, context: CallbackContext) -> None: @@ -188,7 +193,8 @@ def msg_errors(update: Update, context: CallbackContext) -> None: reply(update, errors) except Exception as e: logging.exception(str(e)) - reply(update, 'exception: ' + str(e)) + if not isinstance(e, TimedOut): + reply(update, 'exception: ' + str(e)) def msg_all(update: Update, context: CallbackContext) -> None: -- cgit v1.2.3