diff --git a/README.md b/README.md index a2d131f..94b18df 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/custom_components/sagemcom_fast/__init__.py b/custom_components/sagemcom_fast/__init__.py index f2dec9a..7dbfb84 100644 --- a/custom_components/sagemcom_fast/__init__.py +++ b/custom_components/sagemcom_fast/__init__.py @@ -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] diff --git a/custom_components/sagemcom_fast/config_flow.py b/custom_components/sagemcom_fast/config_flow.py index b73c989..4b64225 100644 --- a/custom_components/sagemcom_fast/config_flow.py +++ b/custom_components/sagemcom_fast/config_flow.py @@ -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() diff --git a/custom_components/sagemcom_fast/device_tracker.py b/custom_components/sagemcom_fast/device_tracker.py index d4b33c8..e22954f 100644 --- a/custom_components/sagemcom_fast/device_tracker.py +++ b/custom_components/sagemcom_fast/device_tracker.py @@ -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 @@ -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() )