Skip to content

Commit

Permalink
Add model property
Browse files Browse the repository at this point in the history
  • Loading branch information
cyr-ius committed May 8, 2024
1 parent 6e1a232 commit a111f45
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion custom_components/livebox/coordinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,23 @@ def __init__(
use_tls=config_entry.data.get(CONF_USE_TLS, False),
)
self.unique_id: str | None = None
self.model: int | None = None

async def _async_update_data(self) -> dict[str, Any]:
"""Fetch data."""
try:
# Mandatory information
infos = await self.async_get_infos()
self.unique_id = infos["SerialNumber"]
match infos["ProductClass"]:
case "Livebox 4":
self.model = 4
case "Livebox Fibre":
self.model = 5
case "Livebox 6":
self.model = 6
case "Livebox 7":
self.model = 7

# Optionals
lan_tracking = self.config_entry.options.get(CONF_LAN_TRACKING, False)
Expand Down Expand Up @@ -152,7 +162,8 @@ async def async_get_wifi_stats(self) -> bool:

async def async_get_fiber_stats(self) -> bool:
"""Get fiber stats."""
stats = await self._make_request(self.api.nemo.async_get_net_dev_stats, "veip0")
intf = "eth0" if self.model == 4 else "veip0"
stats = await self._make_request(self.api.nemo.async_get_net_dev_stats, intf)
return stats.get("status", {})

async def async_get_wan_status(self) -> dict[str, Any]:
Expand Down

0 comments on commit a111f45

Please sign in to comment.