Skip to content

Commit

Permalink
2024 codestyle and modernization - part 2 (#90)
Browse files Browse the repository at this point in the history
  • Loading branch information
iMicknl authored Jan 7, 2024
1 parent 0acc32e commit 3143ec9
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 7 deletions.
15 changes: 13 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,23 @@
[![GitHub release](https://img.shields.io/github/release/iMicknl/ha-sagemcom-fast.svg)](https://github.com/iMicknl/ha-sagemcom-fast/releases/)
[![HA integration usage](https://img.shields.io/badge/dynamic/json?color=41BDF5&logo=home-assistant&label=integration%20usage&suffix=%20installs&cacheSeconds=15600&url=https://analytics.home-assistant.io/custom_integrations.json&query=$.sagemcom_fast.total)](https://analytics.home-assistant.io/custom_integrations.json)

# Sagemcom F@st - Home Assistant (work in progress)
# Sagemcom F@st integration for Home Assistant

This integration adds support for Sagemcom F@st routers to Home Assistant. Currently this is a work in progress where only a basic device_tracker is supported, however in the future sensors will be added as well.
This integration adds support for Sagemcom F@st routers to Home Assistant. Currently only a basic device_tracker entity is supported, however this could be extended in the future with more sensors.

Sagemcom F@st routers are used by many providers worldwide, but many of them did rebrand the router. Examples are the b-box from Proximus, Home Hub from bell and the Smart Hub from BT.

## Features

- Device Tracker, to track connected devices to your router (WiFi and Ethernet)
- Reboot button, to reboot your gateway from Home Assistant

## Known limitations / issues

Since this integration is only used by a few users, not much time has been spent on the development lately. There are currently some known limitations and bugs. Contributions are welcome!

- After reboot, not connected devices have status 'unavailable' [#14](https://github.com/iMicknl/ha-sagemcom-fast/issues/14)

## Installation

### Manual
Expand Down
2 changes: 1 addition & 1 deletion custom_components/sagemcom_fast/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
return unload_ok


async def update_listener(hass: HomeAssistant, entry: ConfigEntry):
async def update_listener(hass: HomeAssistant, entry: ConfigEntry) -> None:
"""Update when entry options update."""
if entry.options[CONF_SCAN_INTERVAL]:
data: HomeAssistantSagemcomFastData = hass.data[DOMAIN][entry.entry_id]
Expand Down
1 change: 1 addition & 0 deletions custom_components/sagemcom_fast/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ async def async_step_user(self, user_input=None):
errors = {}

if user_input:
# TODO change to gateway mac address or something more unique
await self.async_set_unique_id(user_input.get(CONF_HOST))
self._abort_if_unique_id_configured()

Expand Down
15 changes: 11 additions & 4 deletions custom_components/sagemcom_fast/device_tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@

from homeassistant.components.device_tracker import SourceType
from homeassistant.components.device_tracker.config_entry import ScannerEntity
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant
from homeassistant.helpers.device_registry import CONNECTION_NETWORK_MAC, DeviceInfo
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.restore_state import RestoreEntity
from homeassistant.helpers.typing import StateType
from homeassistant.helpers.update_coordinator import CoordinatorEntity
Expand All @@ -14,12 +17,16 @@
from .coordinator import SagemcomDataUpdateCoordinator


async def async_setup_entry(hass, config_entry, async_add_entities):
"""Set up from config entry."""
data: HomeAssistantSagemcomFastData = hass.data[DOMAIN][config_entry.entry_id]
async def async_setup_entry(
hass: HomeAssistant,
entry: ConfigEntry,
async_add_entities: AddEntitiesCallback,
) -> None:
"""Set up device tracker from config entry."""
data: HomeAssistantSagemcomFastData = hass.data[DOMAIN][entry.entry_id]

async_add_entities(
SagemcomScannerEntity(data.coordinator, idx, config_entry.entry_id)
SagemcomScannerEntity(data.coordinator, idx, entry.entry_id)
for idx, device in data.coordinator.data.items()
)

Expand Down

0 comments on commit 3143ec9

Please sign in to comment.