Home

Awesome

FRITZ!Box Tools - part of HomeAssistant >= 2021.7.0

As of HA core 2021.7.0 all functionlities of this integration are part of HA core. This custom integration is not maintained anymore, as a result. Thanks for suporting us with this custom integration.

<a href="https://www.buymeacoffee.com/mammuth" target="_blank"><img src="https://bmc-cdn.nyc3.digitaloceanspaces.com/BMC-button-images/custom_images/orange_img.png" alt="Buy Me A Coffee" style="height: auto !important;width: auto !important;" ></a>

This custom integration is now deprecated because is fully merged into HomeAssistant core.

Features:

homeassistant_fritzbox_tools

Installation

Install via HACS

The custom component is available via HACS

Manual Install

If you want to install the custom commponent manually, add the folder fritzbox_tools/ to YOUR_CONFIG_DIR/custom_components/.

If you're running on a manual HA install on eg. Debian or your own Docker setup, make sure to install the system requirements for fritzconnection (the library which is used by this component):

Configuration

As Integration (recommended):

Go to the Integrations pane on your Home Assistant instance.

Using configuration.yml (legacy):

fritzbox_tools:
  devices:
    - host: "192.168.178.1"  # required
      username: "home-assistant"  # required (create one at `System > FRITZ!Box Benutzer` on your router)
      password: "yourfritzboxpassword"  # required
      profiles: # Optional. Needed if you want to control the profiles of your network devices.
        - "Gesperrt"
        - "Gast"
        - "Kinder Smartphones"
      use_wifi: True # Optional, default True: if False no wifi switches will be exposed
      use_port: True  # Optional, default True: if False no port switches will be exposed
      use_profiles: True  # Optional, default True: if False no device switches will be exposed, redundant if devices is not specified
      use_deflections: True # Optional, default True: if False no call deflection switches will be exposed

Prepare your FRITZ!Box

If you want to be able to control settings of the FRITZ!Box (eg. toggle access profiles, (guest) wifi, port forwards, ...), you need to enable two settings in the FRITZ!Box UI Home > Network > Network Settings (Tab) as seen in the following screenshot:

network-settings Note that the option is only visible if you turn on the "advanced view" on your FRITZ!Box.

Port forwardings

It's possible to enable/disable port forwardings for the device which is running Home Assistant.

Requirements:

The port forwards will be exposed as switches in your HA installation (search for port_forward in your entity page to find the IDs).

Note: Currently only port forwards for the device which is running HA are supported!

port_forwardings

Access profiles**

You can switch the online time of access profiles ("Zugangsprofile") within Home Assistant.

Requirements:

The access profiles will be exposed as switches in your HA installation (search for fritzbox_profile in your entity page to find the IDs).

If the switch is toggled on, the devices assigned to the specific profile have internet access. If the switch is toggled off, the devices can not access the internet.

Exposed entities

Example Automations and Scripts

Script: Reconnect / get new IP

The following script can be used to easily add a reconnect button to your UI. If you want to reboot your fritzbox, you can use fritzbox_tools.reboot instead.

fritz_box_reconnect:
  alias: "Reconnect FRITZ!Box"
  sequence:
  - service: fritzbox_tools.reconnect
    data:
        host: 192.168.178.1

Automation: Reconnect / get new IP every night

automation:
- alias: "System: Reconnect FRITZ!Box"
  trigger:
    platform: time
    at: '05:00:00'
  action:
    - service: fritzbox_tools.reconnect
      data:
        host: 192.168.178.1

Automation: Phone notification with wifi credentials when guest wifi is created

The custom component registers a switch for controlling the guest wifi and a service for triggering a reconnect. I use the following automation to send the guest wifi password to my wife's and my phones whenever we turn on the guest wifi:

automation:
  - alias: "Guests Wifi Turned On -> Send Password To Phone
    trigger:
      platform: state
      entity_id: switch.fritzbox_[model]_guest_wifi
      to: 'on'
    action:
      - service: notify.pushbullet_max
        data:
          title: "Guest wifi is enabled"
          message: "Password: ..."

Automation: Open port 80 for the Let's Encrypt http challenge

If you're using the Let's Encrypt Addon you could create an automation for renewing your certificates automatically. However, the http challenge requires port 80 to be open on your router.

The following automation does three things:

automation:
  - alias: 'System: LetsEncrypt certificate renewal'
    trigger:
    - platform: time
      at: 05:00:00
    action:
    - service: switch.turn_on
      entity_id: switch.fritzbox_[model]_portforward_http_server
    - service: hassio.addon_stop
      data:
        addon: core_nginx_proxy
    - delay: 00:00:15
    - service: hassio.addon_restart
      data:
        addon: core_letsencrypt  
    - delay: 00:03:00
    - service: hassio.addon_start
      data:
        addon: core_nginx_proxy
    - service: switch.turn_off
      entity_id: switch.fritzbox_[model]_portforward_http_server

Sensor: External IP address of your router The IP addresses (v4 and v6) are available as attributes of the connectivity sensor that this component exposes. However, if you want to have a dedicated sensor for your external IP, you can create a template sensor like this:

sensors:
  - platform: template
    sensors:
      external_ip:
        friendly_name: "External IP Address"
        entity_id: binary_sensor.fritzbox_[model]_connectivity  # only react on changes of the router connectivity sensor
        value_template: "{{ state_attr('binary_sensor.fritzbox_[model]_connectivity', 'external_ip') }}"
        icon_template: mdi:router-wireless

This will create you a sensor with the entity id sensor.external_ip.

Contributors

Attributions