summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEvgeny Zinoviev <me@ch1p.io>2022-10-29 15:42:09 +0300
committerEvgeny Zinoviev <me@ch1p.io>2022-10-29 15:42:09 +0300
commit0fce6c52516aba239acc81fd528dcb5051c04f68 (patch)
tree2230dfe1d3102cc28537d6e566952dd6ae1a1e44 /src
parentdbc33cf2293238534fd4d268e6a6d9405daae758 (diff)
inverter_bot: add current OSP to status output
Diffstat (limited to 'src')
-rw-r--r--src/home/inverter/monitor.py4
-rw-r--r--src/home/inverter/types.py11
-rwxr-xr-xsrc/inverter_bot.py5
3 files changed, 16 insertions, 4 deletions
diff --git a/src/home/inverter/monitor.py b/src/home/inverter/monitor.py
index f661d73..86f75ac 100644
--- a/src/home/inverter/monitor.py
+++ b/src/home/inverter/monitor.py
@@ -113,9 +113,7 @@ class InverterMonitor(Thread):
# Reading rated configuration
rated = inverter.exec('get-rated')['data']
- self.osp = OutputSourcePriority.SolarBatteryUtility \
- if rated['output_source_priority'] == 'Solar-Battery-Utility' \
- else OutputSourcePriority.SolarUtilityBattery
+ self.osp = OutputSourcePriority.from_text(rated['output_source_priority'])
# Read data and run implemented programs every 2 seconds.
while not self.interrupted:
diff --git a/src/home/inverter/types.py b/src/home/inverter/types.py
index 0292c15..57021f1 100644
--- a/src/home/inverter/types.py
+++ b/src/home/inverter/types.py
@@ -52,4 +52,13 @@ class ACMode(Enum):
class OutputSourcePriority(Enum):
SolarUtilityBattery = 'SUB'
- SolarBatteryUtility = 'SBU' \ No newline at end of file
+ SolarBatteryUtility = 'SBU'
+
+ @classmethod
+ def from_text(cls, s: str):
+ if s == 'Solar-Battery-Utility':
+ return cls.SolarBatteryUtility
+ elif s == 'Solar-Utility-Battery':
+ return cls.SolarUtilityBattery
+ else:
+ raise ValueError(f'unknown value: {s}') \ No newline at end of file
diff --git a/src/inverter_bot.py b/src/inverter_bot.py
index 223c7b3..3df720c 100755
--- a/src/inverter_bot.py
+++ b/src/inverter_bot.py
@@ -176,6 +176,7 @@ def build_flags_keyboard(flags: dict, ctx: Context) -> Tuple[str, InlineKeyboard
def status(ctx: Context) -> None:
gs = inverter.exec('get-status')['data']
+ rated = inverter.exec('get-rated')['data']
# render response
power_direction = gs['battery_power_direction'].lower()
@@ -209,6 +210,8 @@ def status(ctx: Context) -> None:
html += f'\n<b>{ctx.lang(ac_mode.value)}:</b> %s %s' % (gs['grid_voltage']['unit'], gs['grid_voltage']['value'])
html += ', %s %s' % (gs['grid_freq']['value'], gs['grid_freq']['unit'])
+ html += f'\n<b>{ctx.lang("priority")}</b>: {rated["output_source_priority"]}'
+
# send response
ctx.reply(html)
@@ -495,6 +498,7 @@ class InverterBot(Wrapper):
self.lang.ru(
status='Статус',
generation='Генерация',
+ priority='Приоритет',
osp='Приоритет питания нагрузки',
battery="АКБ",
load="Нагрузка",
@@ -573,6 +577,7 @@ class InverterBot(Wrapper):
self.lang.en(
status='Status',
generation='Generation',
+ priority='Priority',
osp='Output source priority',
battery="Battery",
load="Load",