add get-alarm-list command

This commit is contained in:
suaveolent 2024-06-03 14:05:46 +02:00
parent 0eb5f17a5e
commit 93537a5f51
3 changed files with 24 additions and 0 deletions

View File

@ -283,6 +283,12 @@ async def async_identify_inverters(dtu: DTU) -> list[str]:
return inverter_models
async def async_get_alarm_list(dtu: DTU) -> None:
"""Get alarm list from the dtu asynchronously."""
return await dtu.async_get_alarm_list()
def print_invalid_command(command: str) -> None:
"""Print an invalid command message."""
@ -325,6 +331,7 @@ async def main() -> None:
"heartbeat",
"identify-dtu",
"identify-inverters",
"get-alarm-list",
],
help="Command to execute",
)
@ -351,6 +358,7 @@ async def main() -> None:
"heartbeat": async_heatbeat,
"identify-dtu": async_identify_dtu,
"identify-inverters": async_identify_inverters,
"get-alarm-list": async_get_alarm_list,
}
command_func = switch.get(args.command, print_invalid_command)

View File

@ -60,6 +60,7 @@ CMD_ACTION_REPEATER_NETWORKING = 0
CMD_ACTION_DTU_DEFAULT = 0
CMD_ACTION_GATEWAY_DEFAULT = 0
CMD_ACTION_METER_REVERSE = 49
CMD_ACTION_ALARM_LIST = 50
CMD_ACTION_GW_REBOOT = 4096
CMD_ACTION_GW_RESET = 4097
CMD_ACTION_GW_STOP_RUN = 4098

View File

@ -13,6 +13,7 @@ from crcmod import mkCrcFun
from hoymiles_wifi import logger
from hoymiles_wifi.const import (
CMD_ACTION_ALARM_LIST,
CMD_ACTION_DTU_REBOOT,
CMD_ACTION_DTU_UPGRADE,
CMD_ACTION_LIMIT_POWER,
@ -310,6 +311,20 @@ class DTU:
command, request, APPHeartbeatPB_pb2.HBReqDTO
)
async def async_get_alarm_list(self) -> CommandPB_pb2.CommandResDTO | None:
"""Turn off DTU."""
request = CommandPB_pb2.CommandResDTO()
request.action = CMD_ACTION_ALARM_LIST
request.package_nub = 1
request.dev_kind = 0
request.tid = int(time.time())
command = CMD_COMMAND_RES_DTO
return await self.async_send_request(
command, request, CommandPB_pb2.CommandReqDTO
)
async def async_send_request(
self,
command: bytes,