I’m already using an input boolean which indicates whether we have guests at home or not (see screenshot below) - if that flag gets activated we can now automatically turn on the guest wifi network via this custom component.
The automation also sends a pushbullet notification to our smartphones so we can just read the password to our guests or forward it to them.
The automation which uses the custom component is pretty simple:
- alias: "Guests -> Turn on guest wifi"
trigger:
platform: state
entity_id: input_boolean.guest_mode
to: 'on'
action:
- service: fritzbox_guestwifi.turn_on
- service: notify.pushbullet_max
data:
title: "Guest wifi is enabled"
message: "Password: ..."
Shout out a message if you have questions or input!
In your configuration folder, create a directory named custom_components and copy the fritzbox_guestwifi.py file from my repository into that directory.
Inside your configuration.yml, you then need to set the component up via:
The custom component registers two services, called fritzbox_guestwifi.turn_on and fritzbox_guestwifi.turn_off, which you can use in automations as you see in my example in the first post:
automation:
- alias: "Guests -> Turn on guest wifi"
trigger:
platform: state
entity_id: input_boolean.guest_mode
to: 'on'
action:
- service: fritzbox_guestwifi.turn_on
- service: notify.pushbullet_max
data:
title: "Guest wifi is enabled"
message: "Password: ..."
Thank you, that works perfectly:) Good work!
How do you determine if any guests are at home?
Do I need some special code for that (input_boolean.guest_mode)?
Awesome. Now it shows this error in the logs:
ERROR (SyncWorker_9) [custom_components.fritzbox_guestwifi] Home Assistant cannot call the wished service on the FRITZ!Box. Are credentials, address and port correct?
Password should be correct - do i need to change smth else?
Sadly that does not work either (same error). I have edited the configuration.yaml with username and password (any specials I might miss here?).
My HA is also reachable from outside (dyndns). Maybe that is the problem?
Can HA talk to the FRITZ!Box via the IP 169.254.1.1? Otherwise you should specify the host in the configuration.yaml. (And the port, which is 49000 by default).
I just tested it with my FRITZ!Box 3390 on FRITZ!OS 06.54 - maybe other device/software combinations don’t provide the wished service to control the guest wifi.
Thanks for the great job. Since yesterday working with my Fritz!Box 7490
I just had an issue with the configuration and was wondering why it didn’t work. After setting the host and installing fritzconnection Home Assistant is able to switch on/off the guest wifi.
Well, using third party packages where possible is one of the core concepts of HomeAssistant
You can just install fritzconnection via pip.
I’m glad it worked for you @ikisscarlos!
I’m thinking about extending the functionality to not only control the guest wifi but be able to change a couple of settings. Reconnectingthe fritzbox via HA automations (and thus getting a new IP mostly) might be interesting aswell for example.
Is there a way to detect whether the guest wifi is on or not and show it in HASS?
Not yet. But fritzconnection has a wrapper function for that, so we could add a sensor to HA. I’m not sure whether I will do that since I didn’t need it yet, but if I implement it, I’ll drop a line here!
Is it possible to configure the component twice for two separate fritzboxes
Interesting question. I don’t konw how HA behaves when you register the same component twice, but I doubt it will work as you want it to have
However, my custom_component could be updated to support multiple fritzboxes.
after giving it some more thought, the last point for separate fritzboxes is probably not necessary. Typically, if there are several boxes, the additional ones will act as repeater (or mesh node nowadays) which allows you to have the guest wifi configuration from the main box be applied automatically to all connected ones.
The first point would be more interesting though, since I typically set the geust wifi to automatically deactivate if no one is using it to reduce attack surface. But in a “guests present” scenario I would want to have it enabled until I say otherwise. So, of course I could log in to the box and set it up there but that is not why we are all here
Maybe the “FRITZ!Box Net Monitor” component could be extended with the wifi stuff. Does not seem out of place there…
@mammuth, I have been thinking about the possible extension for your component and I agree with @jo-me regarding the possibility to track the state of the guest wifi from Home Assistant. The Fritz!Fon for example has an option to enable/disable the guest wifi from the device itself, so it could be great to have Home Assistant listening for it, so automations to turn off the guest wifi still work.
@mammuth Great thing you did. Do you consider adding it to the homeassistant main stream repo? So we dont have to go through the unnecessary hassles of a manual installation?
I’m not sure yet how this component suits into the other fritzbox components that are already part of HA.
When I add some more controls and sensors it might be suited as a new component like “FRITZ!Box Control” or something like that.
I’m definitely interested in pushing it upstream once I understand what other features I will add to it
@mammuth
Thank you very much for the custom component.
It is working like a charm so far.
May I add some feature request?
The component itself could already be a switch. This would eliminate the need of automations and input_boolean.
It would also be very cool if the status is polled and the state is updated. I configured my guest network to automatically switch off after 1h after the last guest left. So the input_boolean could show a wrong state.
Furthermore I would alo be awsome, if it would be possible to change the guest wifi password via hass. So it would be possible to change the password with a template (random), slider, input fields or something else.
This looks like a great component!
I tried to configure it per your sample configuration, but it doesn’t seem to work.
Clicking on input boolean activates the automation and sends me an email (my choice of notify component), but I do not see anything happening on the fritzbox side.
I made sure to use a fritzbox user which has enough permissions.
Any idea how to troubleshoot? I do not see anything in hass logs…