How to use the fritzconnection.FritzConnection function in fritzconnection

To help you get started, we’ve selected a few fritzconnection examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github fetzerch / fritzcollectd / fritzcollectd / __init__.py View on Github external
def init(self):
        """ Initialize the connection to the FRITZ!Box """
        self._fc = fritzconnection.FritzConnection(
            address=self._fritz_address, port=self._fritz_port,
            user=self._fritz_user, password=self._fritz_password)
        if self._fc.modelname is None:
            self._fc = None
            raise IOError("fritzcollectd: Failed to connect to %s" %
                          self._fritz_address)

        if not self._fc.call_action('WANIPConn:1', 'GetStatusInfo'):
            self._fc = None
            raise IOError("fritzcollectd: Statusinformation via UPnP is "
                          "not enabled")

        if self._fritz_password != '':
            # If the 'Allow access for applications' option is disabled,
            # the connection behaves as if it was created without password.
            if 'WANIPConnection:1' not in self._fc.services.keys():
github westfeld / fritz-speed / create-rra.py View on Github external
def get_link_speed():
    fc = fritzconnection.FritzConnection()
    status = fc.call_action('WANCommonInterfaceConfig', 'GetCommonLinkProperties')
    downstream = status['NewLayer1DownstreamMaxBitRate'] / 8.
    upstream = status['NewLayer1UpstreamMaxBitRate'] / 8.
    return (upstream, downstream)
github kbr / fritzconnection / fritzconnection / lib / fritzcall.py View on Github external
def __init__(self,
                 fc=None,
                 address=fritzconnection.FRITZ_IP_ADDRESS,
                 port=fritzconnection.FRITZ_TCP_PORT,
                 user=fritzconnection.FRITZ_USERNAME,
                 password=''):
        super(FritzCall, self).__init__()
        if fc is None:
            fc = fritzconnection.FritzConnection(address, port, user, password)
        self.fc = fc
        self.calls = None
github paviro / MMM-FRITZ-Box-Callmonitor / fritz_access.py View on Github external
def __init__(self, address, port, user, password):
        super(FritzAccess, self).__init__()
        self.fc = fritzconnection.FritzConnection(address, port, user, password)
github westfeld / fritz-speed / monitor-traffic.py View on Github external
def main():
    prefs = read_configuration(os.path.join(os.path.dirname(__file__),'fritz-speed.ini'))
    fc = fritzconnection.FritzConnection()
    status = fc.call_action('WANCommonInterfaceConfig', 'GetTotalBytesSent')
    bytes_up =  status['NewTotalBytesSent']

    status = fc.call_action('WANCommonInterfaceConfig', 'GetTotalBytesReceived')
    bytes_down =  status['NewTotalBytesReceived']
    update_rra(prefs['rra_filename'], str(bytes_up), str(bytes_down))
github mammuth / ha-fritzbox-tools / custom_components / fritzbox_tools / __init__.py View on Github external
port=DEFAULT_PORT,
        profile_on = DEFAULT_PROFILE_ON,
        profile_off = DEFAULT_PROFILE_OFF,
        device_list = DEFAULT_DEVICES,
        use_port = DEFAULT_USE_PORT,
        use_deflections = DEFAULT_USE_DEFLECTIONS,
        use_wifi = DEFAULT_USE_WIFI,
        use_devices = DEFAULT_USE_DEVICES,
    ):
        # pylint: disable=import-error
        from fritzconnection import FritzConnection
        from fritzconnection.lib.fritzstatus import FritzStatus
        from fritz_switch_profiles import FritzProfileSwitch

        # general timeout for all requests to the router. Some calls need quite some time.
        self.connection = FritzConnection(
            address=host, port=port, user=username, password=password, timeout=30.0
        )

        if device_list != DEFAULT_DEVICES:
            self.profile_switch = FritzProfileSwitch(
                "http://" + host, username, password
            )

        self.fritzstatus = FritzStatus(fc=self.connection)
        self.ha_ip = get_local_ip()
        self.profile_on = profile_on
        self.profile_off = profile_off
        self.profile_last_updated = time.time()
        self.device_list = device_list

        self.username = username
github kbr / fritzconnection / fritzconnection / lib / fritzphonebook.py View on Github external
def __init__(self,
                 fc=None,
                 address=fritzconnection.FRITZ_IP_ADDRESS,
                 port=fritzconnection.FRITZ_TCP_PORT,
                 user=fritzconnection.FRITZ_USERNAME,
                 password=''):
        super(FritzPhonebook, self).__init__()
        if fc is None:
            fc = fritzconnection.FritzConnection(address, port, user, password)
        self.fc = fc