Initial Commit

This commit is contained in:
2026-06-11 11:50:50 -04:00
commit d4a69c41be
2748 changed files with 80489 additions and 0 deletions
@@ -0,0 +1 @@
"""Complex modules for AsusRouter integration."""
@@ -0,0 +1,131 @@
"""Aura RGB module for AsusRouter integration.
This module allows converting AsusRouter Aura data to the
Home Assistant format. This is required due to the complex
data structure and effect handling by Home Assistant.
"""
from __future__ import annotations
from typing import Any
from asusrouter.modules.color import ColorRGBB
from asusrouter.tools.converters import scale_value_int
from homeassistant.components.light import ColorMode
from homeassistant.const import EntityCategory
from ..const import ICON_LIGHT_OFF, ICON_LIGHT_ON
from ..dataclass import AREntityDescription, ARLightDescription
AURA_NO_EFFECT = "EFFECT_OFF"
AURA_FALLBACK_BRIGHTNESS = 128
AURA_FALLBACK_COLOR = ColorRGBB(
(128, 128, 128),
AURA_FALLBACK_BRIGHTNESS,
scale=128,
)
AURA_EFFECTS = [
"Gradient",
"Static",
"Breathing",
"Evolution",
"Rainbow",
"Wave",
"Marquee",
]
AURA_EFFECTS_MAP = {
0: AURA_NO_EFFECT,
1: "Gradient",
2: "Static",
3: "Breathing",
4: "Evolution",
5: "Rainbow",
6: "Wave",
7: "Marquee",
}
SUPPORTED_COLOR_MODES = {
0: ColorMode.ONOFF,
1: ColorMode.RGB,
2: ColorMode.RGB,
3: ColorMode.RGB,
4: ColorMode.ONOFF,
5: ColorMode.ONOFF,
6: ColorMode.ONOFF,
7: ColorMode.RGB,
}
ACTIVE_BRIGHTNESS = "active_brightness"
ACTIVE_COLOR = "active_color"
BRIGHTNESS = "brightness"
RGB_COLOR = "rgb_color"
SCHEME = "scheme"
STATE = "state"
ZONES = "zones"
def aura_to_ha(data: dict[str, Any]) -> dict[str, Any]:
"""Convert AsusRouter Aura data to Home Assistant format."""
result = {
STATE: data.get(STATE, False),
ZONES: data.get(ZONES, 0),
}
# Current active effect
_effect = data.get(SCHEME, 0)
result["effect"] = AURA_EFFECTS_MAP.get(_effect, AURA_NO_EFFECT)
# Colors
if ACTIVE_COLOR in data:
result[RGB_COLOR] = ColorRGBB(data[ACTIVE_COLOR], scale=255).as_tuple()
if ACTIVE_BRIGHTNESS in data:
result[BRIGHTNESS] = scale_value_int(
data.get(ACTIVE_BRIGHTNESS, AURA_FALLBACK_BRIGHTNESS),
255,
128,
)
for i in range(result["zones"]):
color_key = f"active_{i}_color"
brightness_key = f"active_{i}_brightness"
if color_key in data:
result[f"{RGB_COLOR}_{i}"] = ColorRGBB(
data.get(color_key, AURA_FALLBACK_COLOR),
scale=255,
).as_tuple()
if brightness_key in data:
result[f"{BRIGHTNESS}_{i}"] = scale_value_int(
data.get(brightness_key, AURA_FALLBACK_BRIGHTNESS),
255,
128,
)
# Color mode support
result["color_mode"] = SUPPORTED_COLOR_MODES.get(_effect, ColorMode.ONOFF)
return result
def per_zone_light(zones: int = 3) -> list[AREntityDescription]:
"""Create a per-zone light entity descriptions."""
return [
ARLightDescription(
key=STATE,
key_group="aura",
name=f"AURA Zone {i + 1}",
icon_on=ICON_LIGHT_ON,
icon_off=ICON_LIGHT_OFF,
capabilities={"zone_id": i},
entity_category=EntityCategory.CONFIG,
entity_registry_enabled_default=False,
extra_state_attributes={
f"{BRIGHTNESS}_{i}": BRIGHTNESS,
f"{RGB_COLOR}_{i}": RGB_COLOR,
},
)
for i in range(zones)
]
@@ -0,0 +1,31 @@
"""Firmware module for AsusRouter integration."""
from __future__ import annotations
from typing import Any
def to_ha(data: dict[str, Any] | None) -> dict[str, Any]:
"""Convert AsusRouter firmware data to Home Assistant format."""
if not data:
return {}
# Current firmware
_current = data.get("current")
_current = str(_current) if _current else None
# Available stable firmware
_latest = data.get("available")
_latest = str(_latest) if _latest else _current
# Available beta firmware
_latest_beta = data.get("available_beta")
_latest_beta = str(_latest_beta) if _latest_beta else _current
return {
"current": _current,
"latest": _latest,
"latest_beta": _latest_beta,
"release_note": data.get("release_note"),
}