Skip to content

Commit

Permalink
0.30.0 (#812)
Browse files Browse the repository at this point in the history
* Add `color_mode` property for LED entity (#808)

* Add `check_for_updates` button (#809)

* Add support for a full release note in the update entity (#810)

* Add update installation (#811)

* Bump asusrouter to `1.8.0`

* Bump version to `0.30.0`
  • Loading branch information
Vaskivskyi authored Mar 20, 2024
1 parent 1e4cb74 commit fb41fd6
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 3 deletions.
7 changes: 7 additions & 0 deletions custom_components/asusrouter/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -950,6 +950,13 @@
]
)
STATIC_BUTTONS: list[ARButtonDescription] = [
ARButtonDescription(
key="check_update",
name="Check for updates",
icon=ICON_UPDATE,
state=AsusSystem.FIRMWARE_CHECK,
entity_registry_enabled_default=True,
),
ARButtonDescription(
key="reboot",
name="Reboot",
Expand Down
1 change: 1 addition & 0 deletions custom_components/asusrouter/light.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ async def async_setup_entry(
class ARLightLED(ARBinaryEntity, LightEntity):
"""AsusRouter LED light."""

_attr_color_mode = ColorMode.ONOFF
_attr_supported_color_modes = {ColorMode.ONOFF}

def __init__(
Expand Down
4 changes: 2 additions & 2 deletions custom_components/asusrouter/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
"iot_class": "local_polling",
"issue_tracker": "https://github.com/Vaskivskyi/ha-asusrouter/issues",
"loggers": ["asusrouter"],
"requirements": ["asusrouter==1.7.0"],
"version": "0.29.0"
"requirements": ["asusrouter==1.8.0"],
"version": "0.30.0"
}
46 changes: 45 additions & 1 deletion custom_components/asusrouter/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@

from __future__ import annotations

from homeassistant.components.update import UpdateEntity
import asyncio
import logging
from typing import Any

from asusrouter.modules.system import AsusSystem
from homeassistant.components.update import UpdateEntity, UpdateEntityFeature
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback
Expand All @@ -13,6 +18,8 @@
from .entity import ARBinaryEntity, async_setup_ar_entry
from .router import ARDevice

_LOGGER = logging.getLogger(__name__)


async def async_setup_entry(
hass: HomeAssistant,
Expand Down Expand Up @@ -45,3 +52,40 @@ def __init__(
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")
self._attr_in_progress = False

self._attr_supported_features = (
UpdateEntityFeature.RELEASE_NOTES
| UpdateEntityFeature.INSTALL
| UpdateEntityFeature.PROGRESS
)

def release_notes(self) -> str | None:
"""Return the release notes."""

return self.extra_state_attributes.get("release_note")

async def async_install(
self, version: str | None, backup: bool, **kwargs: Any
) -> None:
"""Install the update."""
try:
_LOGGER.debug(
"Trying to install Firmware update. This might take several minutes."
)
result = await self.api.async_set_state(
state=AsusSystem.FIRMWARE_UPGRADE,
)
if not result:
_LOGGER.debug(
"Something went wrong while trying to install the update."
)
else:
self._attr_in_progress = True
await asyncio.sleep(120)
self._attr_in_progress = False

except Exception as ex: # pylint: disable=broad-except
_LOGGER.error(
"An exception occurred while trying to install the update: %s", ex
)

0 comments on commit fb41fd6

Please sign in to comment.