Control FRITZ!Box guest wifi and trigger internet reconnects

If you share the relevant part of the config and the error message of the check process we might be able to assist you.

@mammuth My config yaml is:

fritzbox_tools:
  host: "192.168.178.1"
  username: "xxxxxxxxxxxxxxxxxxxxxxx"  # Skip if you don't have a user
  password: "xxxxxxxxxxxxxxxxxxxxxxxxxx"
  homeassistant_ip: "192.168.178.81"  # Optional. Needed if you want to control port forwardings for the device running Home Assistant
  profile_on: "Standard"  # Optional. Needed if you want to switch between device profiles ("Zugangsprofile")
  profile_off: "Gesperrt"  # Optional. Needed if you want to switch between device profiles ("Zugangsprofile")

The error message is this:

Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/setup.py", line 171, in _async_setup_component
    component.setup, hass, processed_config  # type: ignore
  File "/usr/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/homeassistant/.homeassistant/custom_components/fritzbox_tools/__init__.py", line 38, in setup
    device_list=device_list
  File "/home/homeassistant/.homeassistant/custom_components/fritzbox_tools/__init__.py", line 56, in __init__
    import fritzconnection as fc
  File "/srv/homeassistant/lib/python3.7/site-packages/fritzconnection/__init__.py", line 4, in <module>
    from .fritzconnection import (
  File "/srv/homeassistant/lib/python3.7/site-packages/fritzconnection/fritzconnection.py", line 47, in <module>
    from lxml import etree
ImportError: libxslt.so.1: cannot open shared object file: No such file or directory

It seems that this is a Raspberry Pi related issue, and it needs the following inorder to run properly:

apt-get install libxslt-dev

Yep, exactly. lxml requires dependencies on your system.

I know, but these dependencies weren’t being revealed anywhere. It was only from digging around that I was lucky enough to find a reference.

Great work, that’s what I’ve been looking for for a while. I was surprised that old SmartHome platforms already had this feature and that something like this doesn’t work in Hassio. But I am still missing the button for restarting the box.

–
Klasse, genau danach habe ich schon vor einiger Zeit gesucht und war ĂŒberrascht das diese FunktionalitĂ€t in Hassio nicht VerfĂŒgbar war. Meine alte SmartHome Plattform hatte diese Funktion bereits von Haus aus. Mir fehlt allerdings noch ein Button um einen Neustart der FB durchfĂŒhren zu können. WĂ€re schön wenn der noch kommen wĂŒrde

Werde mich heute mal dran machen die Funktion zu integrieren.

The component exposes a service for reconnecting the Fritzbox (note: this is not the same as restarting it).
You can add it to your UI by creating a script which calls the service and then add this script to your UI.

Yes, will probably solve this with an SSH / Telnet script.

–
Ja, werde es vermutlich mit einem SSH oder Telnet Skript lösen.

I set up a call forward / Rufumleitung in Fritzbox.
I would like to activate this when my wife gets to work and to turn it off when she arrives at home.

Is this possible with this component?

Hi @Pete877, that should be possible, easily!

Do you already have a presence detection device tracker in place? Then you can create an automation with the device tracker as trigger and toggle the call forwarding of this component, correspondingly.

Hi @mammuth
Yes, I use the app and zones for this

Ok great, thank you :beers:

Hi @mammuth

I have a Fritzbox 7490. I created a new User with sufficent permissions and changed the logon method to username and password.

Afterwards I tried to set up the integration.

fritzbox:
  devices:
    - host: 192.168.178.1
      username: Pete
      password: !secret fritzbox

After reboot of homeassistant I do not see anything fritzbox related (no service, no entities
).

What am I missing?

You’re mixing two components. :slight_smile:

One is fritzbox (that’s the one you use). It is to integrate switches and other things from AVM.

What you want to use is the component from this thread, fritzbox_tools. See here:

Check the docs for configuration of fritzbox_tools again
 :wink:

Aaaaaah I see!

Thank you, I’ll have a look over there :beers:

So I set up HACS and Fritzbox-Tools successfuly.

I see the Call forward as a Toggle switch and I renamed the entity to a more readable value.

If I enable the call forward in fritzbox, the button state change.

When I want to do it from homeassistant (either with Toggle switch or service call) I get the following error:

Logger: custom_components.fritzbox_tools.switch
Source: custom_components/fritzbox_tools/switch.py:400
First occurred: 14:37:46 (3 occurrences)
Last logged: 14:39:49

An error occurred while turning on fritzbox_tools Guest wifi switch.
Logger: custom_components.fritzbox_tools.switch
Source: custom_components/fritzbox_tools/switch.py:421
First occurred: 14:37:46 (1 occurrences)
Last logged: 14:37:46

Home Assistant cannot call the wished service on the FRITZ!Box.
Traceback (most recent call last):
  File "/config/custom_components/fritzbox_tools/switch.py", line 421, in _async_handle_deflection_switch_on_off
    "X_AVM-DE_OnTel:1","SetDeflectionEnable", NewEnable=new_state, NewDeflectionId=self.id
  File "/usr/local/lib/python3.7/site-packages/fritzconnection/core/fritzconnection.py", line 207, in call_action
    return self.soaper.execute(service, action_name, arguments)
  File "/usr/local/lib/python3.7/site-packages/fritzconnection/core/soaper.py", line 170, in execute
    return handle_response(response)
  File "/usr/local/lib/python3.7/site-packages/fritzconnection/core/soaper.py", line 153, in handle_response
    raise_fritzconnection_error(response)
  File "/usr/local/lib/python3.7/site-packages/fritzconnection/core/soaper.py", line 82, in raise_fritzconnection_error
    raise exception(message)
fritzconnection.core.exceptions.FritzArgumentError: UPnPError: 
errorCode: 402
errorDescription: Invalid Args

As I have not selected Wifi switches in the setup of the configuration, I assume that the error is a copy and paste-thingy from within the component


Okay I got it working:

  • There in fact is a copy past error in switch.py for the Deflection switch error message

  • The arguments for the deflection toggle must be switched in order, its a bug in the firmware according to https://forum.fhem.de/index.php?topic=92247.0

this is working for me:

           self.fritzbox_tools.connection.call_action(
                "X_AVM-DE_OnTel:1","SetDeflectionEnable", NewDeflectionId=self.id, NewEnable=new_state
            )
2 Likes

Hello,
I am using this extension through HACS since some time, but since one of the latest updates I have seen that the Guest WiFi switch is not working properly. The rest is perfect.
This switch always shows an off status, even when the Guest WiFi is activated from the router. If I try to switch it on, nothing happens.
Any clue about the possible problem? Thanks.

It would be great if the wifi switches would have the SSID as an attribute. The library already has this information when “GetInfo” is called.

I have a TTS notification when the guest wifi is enabled and it would be great if alexa could tell by guests the name of the wifi.

For the password I use an input text since this information seems to be not available in fritzconnection. But since the wifi name is already available it could be added to the sensors as an attribute.

Hello,

is there a way to make a call with dial helper with this tool?

Thanks a lot!

I have the fritz box integration installed and also installed fritzbox tools drom hacs.
See my yaml setop below

I get no sensors or switches. What am I missing?


fritzbox_tools:
  host: 192.168.2.254
  username: home-assistant
  password: !secret fritzbox
  devices: 
    - iPhonevanChanna
#   profile_on: "Standaard" # Optional. Use if the names of your "Zugangsprofile" are different as the defaults.
#   profile_off: "Kids"  # Optional.
  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_devices: 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

In the log I only see
[homeassistant.bootstrap] Waiting on integrations to complete setup: fritzbox_tools