diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/home/inverter/monitor.py | 4 | ||||
-rw-r--r-- | src/home/inverter/types.py | 11 | ||||
-rwxr-xr-x | src/inverter_bot.py | 5 |
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", |