mirror of
https://github.com/home-assistant/core.git
synced 2025-07-20 03:37:07 +00:00
Move config details to doc
This commit is contained in:
parent
df24a1bfa7
commit
87d40f6673
@ -1,47 +1,12 @@
|
|||||||
"""
|
"""
|
||||||
homeassistant.components.device_tracker.fritz
|
homeassistant.components.device_tracker.fritz
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
Unfortunately, you have to execute the following command by hand:
|
Device tracker platform that supports scanning a FRITZ!Box router for device
|
||||||
sudo apt-get install libxslt-dev libxml2-dev
|
|
||||||
|
|
||||||
Device tracker platform that supports scanning a FitzBox router for device
|
|
||||||
presence.
|
presence.
|
||||||
|
|
||||||
Configuration:
|
For more details about this platform, please refer to the documentation at
|
||||||
|
https://home-assistant.io/components/device_tracker.fritz/
|
||||||
To use the fritz tracker you have to adapt your configuration.yaml by
|
|
||||||
using the following template:
|
|
||||||
|
|
||||||
device_tracker:
|
|
||||||
platform: fritz
|
|
||||||
host: YOUR_ROUTER_IP
|
|
||||||
username: YOUR_ADMIN_USERNAME
|
|
||||||
password: YOUR_ADMIN_PASSWORD
|
|
||||||
|
|
||||||
|
|
||||||
Description:
|
|
||||||
|
|
||||||
host
|
|
||||||
*Optional
|
|
||||||
The IP address of your router, e.g. 192.168.0.1.
|
|
||||||
It is optional since every fritzbox is also reachable by using
|
|
||||||
the 169.254.1.1 IP.
|
|
||||||
|
|
||||||
username
|
|
||||||
*Optional
|
|
||||||
The username of an user with administrative privileges, usually 'admin'.
|
|
||||||
However, it seems that it is not necessary to use it in
|
|
||||||
current generation fritzbox routers because the necessary data
|
|
||||||
can be retrieved anonymously.
|
|
||||||
|
|
||||||
password
|
|
||||||
*Optional
|
|
||||||
The password for your given admin account.
|
|
||||||
However, it seems that it is not necessary to use it in current
|
|
||||||
generation fritzbox routers because the necessary data can
|
|
||||||
be retrieved anonymously.
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
|
|
||||||
@ -58,16 +23,12 @@ _LOGGER = logging.getLogger(__name__)
|
|||||||
|
|
||||||
# noinspection PyUnusedLocal
|
# noinspection PyUnusedLocal
|
||||||
def get_scanner(hass, config):
|
def get_scanner(hass, config):
|
||||||
"""
|
""" Validates config and returns FritzBoxScanner. """
|
||||||
Validates config and returns FritzBoxScanner
|
|
||||||
@param hass:
|
|
||||||
@param config:
|
|
||||||
@return:
|
|
||||||
"""
|
|
||||||
if not validate_config(config,
|
if not validate_config(config,
|
||||||
{DOMAIN: []},
|
{DOMAIN: []},
|
||||||
_LOGGER):
|
_LOGGER):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
scanner = FritzBoxScanner(config[DOMAIN])
|
scanner = FritzBoxScanner(config[DOMAIN])
|
||||||
return scanner if scanner.success_init else None
|
return scanner if scanner.success_init else None
|
||||||
|
|
||||||
@ -75,14 +36,14 @@ def get_scanner(hass, config):
|
|||||||
# pylint: disable=too-many-instance-attributes
|
# pylint: disable=too-many-instance-attributes
|
||||||
class FritzBoxScanner(object):
|
class FritzBoxScanner(object):
|
||||||
"""
|
"""
|
||||||
This class queries a FritzBox router. It is using the
|
This class queries a FRITZ!Box router. It is using the
|
||||||
fritzconnection library for communication with the router.
|
fritzconnection library for communication with the router.
|
||||||
|
|
||||||
The API description can be found under:
|
The API description can be found under:
|
||||||
https://pypi.python.org/pypi/fritzconnection/0.4.6
|
https://pypi.python.org/pypi/fritzconnection/0.4.6
|
||||||
|
|
||||||
This scanner retrieves the list of known hosts and checks
|
This scanner retrieves the list of known hosts and checks their
|
||||||
their corresponding states (on, or off).
|
corresponding states (on, or off).
|
||||||
|
|
||||||
Due to a bug of the fritzbox api (router side) it is not possible
|
Due to a bug of the fritzbox api (router side) it is not possible
|
||||||
to track more than 16 hosts.
|
to track more than 16 hosts.
|
||||||
@ -113,7 +74,7 @@ class FritzBoxScanner(object):
|
|||||||
if CONF_PASSWORD in config.keys():
|
if CONF_PASSWORD in config.keys():
|
||||||
self.password = config[CONF_PASSWORD]
|
self.password = config[CONF_PASSWORD]
|
||||||
|
|
||||||
# Establish a connection to the fritzbox
|
# Establish a connection to the FRITZ!Box
|
||||||
try:
|
try:
|
||||||
self.fritz_box = fc.FritzHosts(address=self.host,
|
self.fritz_box = fc.FritzHosts(address=self.host,
|
||||||
user=self.username,
|
user=self.username,
|
||||||
@ -131,7 +92,7 @@ class FritzBoxScanner(object):
|
|||||||
self.fritz_box.modelname)
|
self.fritz_box.modelname)
|
||||||
self._update_info()
|
self._update_info()
|
||||||
else:
|
else:
|
||||||
_LOGGER.error("Failed to establish connection to FritzBox "
|
_LOGGER.error("Failed to establish connection to FRITZ!Box "
|
||||||
"with IP: %s", self.host)
|
"with IP: %s", self.host)
|
||||||
|
|
||||||
def scan_devices(self):
|
def scan_devices(self):
|
||||||
@ -152,10 +113,7 @@ class FritzBoxScanner(object):
|
|||||||
|
|
||||||
@Throttle(MIN_TIME_BETWEEN_SCANS)
|
@Throttle(MIN_TIME_BETWEEN_SCANS)
|
||||||
def _update_info(self):
|
def _update_info(self):
|
||||||
"""
|
""" Retrieves latest information from the FRITZ!Box. """
|
||||||
Retrieves latest information from the FritzBox.
|
|
||||||
Returns boolean if scanning successful.
|
|
||||||
"""
|
|
||||||
if not self.success_init:
|
if not self.success_init:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user