Skip to content

Commit

Permalink
0.29.0 (#796)
Browse files Browse the repository at this point in the history
* Move `force clients update` to a separate button instead of regular call (#777)

* Add `restart_wired` button (#778)

* Add release notes to the `update` entity (#779)

* Check that capabilities of the device tracker exist before accessing (#786)

* Bump release-drafter/release-drafter from 5.25.0 to 6.0.0 (#782)

* Remove SSDP discovery (#791)

* Add `Rebuild AiMesh` button (#794)

* Bump asusrouter to `1.7.0`

* Bump version to `0.29.0`
  • Loading branch information
Vaskivskyi authored Feb 15, 2024
1 parent a16e260 commit 1e4cb74
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 105 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release-drafter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Run release-drafter
uses: release-drafter/release-drafter@v5.25.0
uses: release-drafter/release-drafter@v6.0.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

3 changes: 3 additions & 0 deletions custom_components/asusrouter/button.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ def __init__(
self._state_args = description.state_args
self._state_expect_modify = description.state_expect_modify

if description.icon:
self._attr_icon = description.icon

async def async_press(
self,
**kwargs: Any,
Expand Down
66 changes: 0 additions & 66 deletions custom_components/asusrouter/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
from asusrouter.error import AsusRouterAccessError
from asusrouter.modules.endpoint.error import AccessError
from asusrouter.modules.homeassistant import convert_to_ha_sensors_group
from homeassistant.components import ssdp
from homeassistant.config_entries import ConfigEntry, ConfigFlow, OptionsFlow
from homeassistant.const import (
CONF_HOST,
Expand Down Expand Up @@ -47,8 +46,6 @@
CONF_DEFAULT_CONSIDER_HOME,
CONF_DEFAULT_CREATE_DEVICES,
CONF_DEFAULT_EVENT,
CONF_DEFAULT_FORCE_CLIENTS,
CONF_DEFAULT_FORCE_CLIENTS_WAITTIME,
CONF_DEFAULT_HIDE_PASSWORDS,
CONF_DEFAULT_INTERFACES,
CONF_DEFAULT_INTERVALS,
Expand All @@ -60,8 +57,6 @@
CONF_DEFAULT_SSL,
CONF_DEFAULT_TRACK_DEVICES,
CONF_DEFAULT_USERNAME,
CONF_FORCE_CLIENTS,
CONF_FORCE_CLIENTS_WAITTIME,
CONF_HIDE_PASSWORDS,
CONF_INTERFACES,
CONF_INTERVAL,
Expand Down Expand Up @@ -90,7 +85,6 @@
RESULT_UNKNOWN,
RESULT_WRONG_CREDENTIALS,
ROUTER,
SSDP_SERVER,
STEP_CONNECTED_DEVICES,
STEP_CREDENTIALS,
STEP_EVENTS,
Expand All @@ -101,7 +95,6 @@
STEP_OPERATION,
STEP_OPTIONS,
STEP_SECURITY,
STEP_SSDP,
UNIQUE_ID,
)

Expand Down Expand Up @@ -432,16 +425,6 @@ def _create_form_connected_devices(
): cv.multi_select(
dict(sorted(user_input[ALL_CLIENTS].items(), key=lambda item: item[1]))
),
vol.Required(
CONF_FORCE_CLIENTS,
default=user_input.get(CONF_FORCE_CLIENTS, CONF_DEFAULT_FORCE_CLIENTS),
): cv.boolean,
vol.Required(
CONF_FORCE_CLIENTS_WAITTIME,
default=user_input.get(
CONF_FORCE_CLIENTS_WAITTIME, CONF_DEFAULT_FORCE_CLIENTS_WAITTIME
),
): cv.positive_float,
vol.Required(
CONF_LATEST_CONNECTED,
default=user_input.get(
Expand Down Expand Up @@ -616,7 +599,6 @@ def __init__(self) -> None:
# Steps description
self._steps: dict[str, dict[str, Any]] = {
STEP_FIND: {METHOD: self.async_step_find, NEXT: STEP_CREDENTIALS},
STEP_SSDP: {NEXT: STEP_CREDENTIALS},
STEP_CREDENTIALS: {
METHOD: self.async_step_credentials,
NEXT: STEP_OPERATION,
Expand All @@ -628,54 +610,6 @@ def __init__(self) -> None:
STEP_OPTIONS: {METHOD: self.async_step_options},
}

# SSDP
async def async_step_ssdp(
self,
discovery_info: ssdp.SsdpServiceInfo,
) -> FlowResult:
"""Flow initiated by SSDP discovery."""

step_id = STEP_SSDP

# Get the serial number
serial_number = discovery_info.upnp.get(ssdp.ATTR_UPNP_SERIAL)

# Abort if no serial number provided
if not serial_number or serial_number == "":
return self.async_abort(reason="no_serial")

# Check if configured already
await self.async_set_unique_id(serial_number)
self._abort_if_unique_id_configured()

_LOGGER.debug("Discovered SSDP device with serial number: %s", serial_number)
_LOGGER.debug("Discovered SSDP device: %s", discovery_info)

# Make sure, this is actually an AsusWRT-powered device
if (
not discovery_info.ssdp_server
or SSDP_SERVER not in discovery_info.ssdp_server
):
return self.async_abort(reason="not_router")

# Save host
assert discovery_info.ssdp_location is not None
host = urlparse(discovery_info.ssdp_location).hostname
self._configs[CONF_HOST] = host

# Friendly name
name = discovery_info.upnp[ssdp.ATTR_UPNP_FRIENDLY_NAME]

# Set the title placeholder
self.description_placeholders = {
CONF_NAME: name,
CONF_HOST: host,
}
self.context["title_placeholders"] = self.description_placeholders

# Process to setup
return await _async_process_step(self._steps, step_id)

# User setup
async def async_step_user(
self,
Expand Down
33 changes: 24 additions & 9 deletions custom_components/asusrouter/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from homeassistant.components.binary_sensor import BinarySensorDeviceClass
from homeassistant.components.button import ButtonDeviceClass
from homeassistant.components.sensor import SensorDeviceClass, SensorStateClass
from homeassistant.components.update import UpdateDeviceClass
from homeassistant.const import (
ATTR_CONNECTIONS,
ATTR_IDENTIFIERS,
Expand Down Expand Up @@ -459,8 +460,6 @@
CONF_EVENT_NODE_CONNECTED = "node_connected"
CONF_EVENT_NODE_DISCONNECTED = "node_disconnected"
CONF_EVENT_NODE_RECONNECTED = "node_reconnected"
CONF_FORCE_CLIENTS = "force_clients"
CONF_FORCE_CLIENTS_WAITTIME = "force_clients_waittime"
CONF_HIDE_PASSWORDS = "hide_passwords"
CONF_INTERFACES = "interfaces"
CONF_INTERVAL = "interval_"
Expand Down Expand Up @@ -505,8 +504,6 @@
CONF_EVENT_NODE_DISCONNECTED: True,
CONF_EVENT_NODE_RECONNECTED: True,
}
CONF_DEFAULT_FORCE_CLIENTS = True
CONF_DEFAULT_FORCE_CLIENTS_WAITTIME = 5.0
CONF_DEFAULT_HIDE_PASSWORDS = False
CONF_DEFAULT_INTERFACES = [WAN.upper()]
CONF_DEFAULT_INTERVALS = {CONF_INTERVAL + FIRMWARE: 21600}
Expand Down Expand Up @@ -565,8 +562,6 @@
CONF_EVENT_NODE_CONNECTED,
CONF_EVENT_NODE_DISCONNECTED,
CONF_EVENT_NODE_RECONNECTED,
CONF_FORCE_CLIENTS,
CONF_FORCE_CLIENTS_WAITTIME,
CONF_HIDE_PASSWORDS,
CONF_INTERFACES,
CONF_INTERVAL_DEVICES,
Expand Down Expand Up @@ -970,6 +965,12 @@
state=AsusSystem.RESTART_HTTPD,
entity_registry_enabled_default=False,
),
ARButtonDescription(
key="restart_wired",
name="Restart wired",
icon=ICON_ETHERNET_ON,
state=AsusSystem.RESTART_NET,
),
ARButtonDescription(
key="restart_wireless",
name="Restart wireless",
Expand All @@ -979,13 +980,28 @@
),
]
STATIC_BUTTONS_OPTIONAL: list[ARButtonDescription] = [
ARButtonDescription(
key="rebuild_aimesh",
name="Rebuild AiMesh",
icon=ICON_DEVICES,
state=AsusSystem.REBUILD_AIMESH,
device_class=ButtonDeviceClass.RESTART,
entity_registry_enabled_default=True,
),
ARButtonDescription(
key="restart_firewall",
name="Restart firewall",
icon=ICON_RESTART,
state=AsusSystem.RESTART_FIREWALL,
entity_registry_enabled_default=False,
),
ARButtonDescription(
key="refresh_clients",
name="Refresh clients",
icon=ICON_DEVICES,
state=AsusSystem.UPDATE_CLIENTS,
entity_registry_enabled_default=True,
),
]
STATIC_LIGHTS: list[AREntityDescription] = [
ARLightDescription(
Expand Down Expand Up @@ -1360,9 +1376,11 @@
key_group="firmware",
name="Firmware update",
icon=ICON_UPDATE,
device_class=UpdateDeviceClass.FIRMWARE,
extra_state_attributes={
"current": "current",
"available": "available",
"release_note": "release_note",
},
)
]
Expand Down Expand Up @@ -1399,6 +1417,3 @@
STEP_OPERATION = "operation"
STEP_OPTIONS = "options"
STEP_SECURITY = "security"
STEP_SSDP = "ssdp"

SSDP_SERVER = "AsusWRT"
9 changes: 2 additions & 7 deletions custom_components/asusrouter/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,6 @@
"iot_class": "local_polling",
"issue_tracker": "https://github.com/Vaskivskyi/ha-asusrouter/issues",
"loggers": ["asusrouter"],
"requirements": ["asusrouter==1.6.1"],
"ssdp": [
{
"manufacturer": "ASUSTeK Computer Inc."
}
],
"version": "0.28.0"
"requirements": ["asusrouter==1.7.0"],
"version": "0.29.0"
}
25 changes: 5 additions & 20 deletions custom_components/asusrouter/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@
CONF_DEFAULT_CONSIDER_HOME,
CONF_DEFAULT_CREATE_DEVICES,
CONF_DEFAULT_EVENT,
CONF_DEFAULT_FORCE_CLIENTS,
CONF_DEFAULT_FORCE_CLIENTS_WAITTIME,
CONF_DEFAULT_INTERVALS,
CONF_DEFAULT_LATEST_CONNECTED,
CONF_DEFAULT_MODE,
Expand All @@ -58,8 +56,6 @@
CONF_DEFAULT_SPLIT_INTERVALS,
CONF_DEFAULT_TRACK_DEVICES,
CONF_EVENT_NODE_CONNECTED,
CONF_FORCE_CLIENTS,
CONF_FORCE_CLIENTS_WAITTIME,
CONF_INTERVAL,
CONF_INTERVAL_DEVICES,
CONF_LATEST_CONNECTED,
Expand Down Expand Up @@ -392,7 +388,11 @@ async def setup(self) -> None:
if entry.domain != "device_tracker":
continue
capabilities = entry.capabilities
if "mac" in capabilities:
# Check that capabilities is a dictionary and that it has the MAC address
# I actually don't know how this can be possible, but the issue #785
# https://github.com/Vaskivskyi/ha-asusrouter/issues/785
# shows that device_tracker entry can exist without a MAC address
if isinstance(capabilities, dict) and "mac" in capabilities:
mac = capabilities["mac"]
self._clients[mac] = ARClient(mac)

Expand All @@ -411,21 +411,6 @@ async def setup(self) -> None:

# Update parental control
await self.update_pc_rules()

# Force clients settings
# This should be done after clients update so that first update is fast
force_clients = self._options.get(
CONF_FORCE_CLIENTS, CONF_DEFAULT_FORCE_CLIENTS
)
if force_clients is True:
force_clients_waittime = self._options.get(
CONF_FORCE_CLIENTS_WAITTIME, CONF_DEFAULT_FORCE_CLIENTS_WAITTIME
)
_LOGGER.debug(
"Forcing clients updates with %s s wait time",
force_clients_waittime,
)
self.bridge.api.set_force_clients(force_clients, force_clients_waittime)
else:
_LOGGER.debug(
"Device is in AiMesh node mode. Device tracking and AiMesh monitoring is disabled"
Expand Down
5 changes: 3 additions & 2 deletions custom_components/asusrouter/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,6 @@ def __init__(
super().__init__(coordinator, router, description)
self.entity_description: ARUpdateDescription = description

self._attr_installed_version = self.extra_state_attributes["current"]
self._attr_latest_version = self.extra_state_attributes["available"]
self._attr_installed_version = self.extra_state_attributes.get("current")
self._attr_latest_version = self.extra_state_attributes.get("available")
self._attr_release_summary = self.extra_state_attributes.get("release_note")

0 comments on commit 1e4cb74

Please sign in to comment.