Skip to content

Commit

Permalink
1.8.0 (#473)
Browse files Browse the repository at this point in the history
* Add support for firmware release note in no-AiMesh mode (#468)

* Add `FIRMWARE_CHECK` and `FIRMWARE_UPGRADE` states to `AsusSystem` (#469)

* Update GitHub funding file (#470)

* Add check on the VPNC client data availability (#471)

* Add explicit string conversion on pc rule save (#472)

* Bump version to `1.8.0`
  • Loading branch information
Vaskivskyi authored Mar 20, 2024
1 parent 8da4c9c commit 3d9b324
Show file tree
Hide file tree
Showing 10 changed files with 41 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
buy_me_a_coffee: Vaskivskyi
github: [Vaskivskyi]
patreon: Vaskivskyi
custom: ["https://www.buymeacoffee.com/Vaskivskyi"]
3 changes: 2 additions & 1 deletion asusrouter/asusrouter.py
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,8 @@ def _where_to_get_data(self, datatype: AsusData) -> Optional[AsusDataFinder]:
while isinstance(data_map, AsusData):
data_map = ASUSDATA_MAP.get(data_map)
# Check if we have a map
if not data_map:
if not isinstance(data_map, AsusDataFinder):
_LOGGER.debug("No map found for %s", datatype)
return None

# Check if endpoints are available
Expand Down
4 changes: 3 additions & 1 deletion asusrouter/modules/data_finder.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,9 @@ def __init__(
AsusData.CPU: AsusDataFinder(Endpoint.HOOK, request=ASUSDATA_REQUEST["main"]),
AsusData.DEVICEMAP: AsusDataFinder(Endpoint.DEVICEMAP),
AsusData.FIRMWARE: AsusDataFinder(Endpoint.FIRMWARE),
AsusData.FIRMWARE_NOTE: AsusDataFinder(Endpoint.FIRMWARE_NOTE),
AsusData.FIRMWARE_NOTE: AsusDataFinder(
[Endpoint.FIRMWARE_NOTE, Endpoint.FIRMWARE_NOTE_AIMESH]
),
AsusData.GWLAN: AsusDataFinder(
Endpoint.HOOK,
method=gwlan_nvram_request,
Expand Down
3 changes: 2 additions & 1 deletion asusrouter/modules/endpoint/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ class Endpoint(str, Enum):
DEVICEMAP = "ajax_status.xml"
ETHERNET_PORTS = "ajax_ethernet_ports.asp"
FIRMWARE = "detect_firmware.asp"
FIRMWARE_NOTE = "release_note_amas.asp"
FIRMWARE_NOTE = "release_note0.asp"
FIRMWARE_NOTE_AIMESH = "release_note_amas.asp"
HOOK = "appGet.cgi"
NETWORKMAPD = "update_networkmapd.asp"
ONBOARDING = "ajax_onboarding.asp"
Expand Down
4 changes: 4 additions & 0 deletions asusrouter/modules/endpoint/firmware_note.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ def read(content: str) -> dict[str, Any]:
raw_note = content.replace("\ufeff", "")
raw_note = raw_note.replace("\uff1a", ":") # Replace the full-width colon

# Empty release note -> fast return
if raw_note == "\n\n":
return {}

# Get only the changes
# 1. Split the data into lines
lines = raw_note.splitlines()
Expand Down
5 changes: 5 additions & 0 deletions asusrouter/modules/endpoint/firmware_note_aimesh.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
"""Firmware release notes for AiMesh endpoint module.
This module is an alias for the firmware release notes endpoint module."""

from asusrouter.modules.endpoint.firmware_note import process, read
2 changes: 2 additions & 0 deletions asusrouter/modules/endpoint/hook.py
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,8 @@ def process_vpnc(data: dict[str, Any]) -> Tuple[dict[AsusVPNType, dict[int, Any]
continue
part = client.split(">")
# Format: name, type, id, login, password, active, vpnc_id, ?, ?, ?, ?, `Web`
if len(part) < 7:
continue
vpnc_id = safe_int(part[6])
vpnc[vpnc_id] = {
"type": AsusVPNType(part[1])
Expand Down
11 changes: 3 additions & 8 deletions asusrouter/modules/parental_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,14 +277,9 @@ def write_pc_rules(rules: dict[str, ParentalControlRule]) -> dict[str, str]:
# Join the values together
data = {}
for key, attribute in PC_RULE_MAP.items():
if attribute == "type":
data[key] = ">".join(
str(getattr(rule, attribute, "")) for rule in rules.values()
)
else:
data[key] = ">".join(
getattr(rule, attribute, "") for rule in rules.values()
)
data[key] = ">".join(
str(getattr(rule, attribute, "")) for rule in rules.values()
)

data[KEY_PC_TIMEMAP] = data[KEY_PC_TIMEMAP].replace("&#60", "<")

Expand Down
18 changes: 18 additions & 0 deletions asusrouter/modules/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ class AsusSystem(str, Enum):
Some services might not be tested and might not work as expected. Use with caution
and at your own risk."""

# Firmware
FIRMWARE_CHECK = "firmware_check" # Check for firmware update
# Firmware upgrade will upgrade the firmware to the latest version
# if available. The firmware file is downloaded from the Asus server.
# After the download, the router will reboot and install the firmware.
FIRMWARE_UPGRADE = "firmware_upgrade" # Firmware upgrade
PREPARE_CERT = "prepare_cert" # Prepare certificate
REBOOT = "reboot" # Reboot the router
REBUILD_AIMESH = "re_reconnect" # Rebuild AiMesh
Expand Down Expand Up @@ -86,6 +92,18 @@ class AsusSystem(str, Enum):

# Map AsusSystem special cases to service calls
STATE_MAP: dict[AsusSystem, dict[str, Any]] = {
AsusSystem.FIRMWARE_CHECK: {
"service": None,
"arguments": {"action_mode": "firmware_check"},
"apply": False,
"expect_modify": False,
},
AsusSystem.FIRMWARE_UPGRADE: {
"service": None,
"arguments": {"action_mode": "firmware_upgrade"},
"apply": False,
"expect_modify": False,
},
AsusSystem.UPDATE_CLIENTS: {
"service": None,
"arguments": {"action_mode": "update_client_list"},
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "asusrouter"
version = "1.7.0"
version = "1.8.0"
license = {text = "Apache-2.0"}
requires-python = ">=3.11.0"
readme = "README.md"
Expand Down

0 comments on commit 3d9b324

Please sign in to comment.