Ubiquiti Unifi Controller Switch - Unblock/Block Device Access to Unifi network

The only thing I noticed is that I have reversed the controls compared to the custom component ie switch on = blocked

1 Like

Hi Robban,

Is there any documentation to support the adding of devices that I want to be able to unblock/block?

I’ve setup the integration and that’s showing me every device attached to my network! (I see there’s an issue raised for this already)

I’ve added the below to my configuration.yaml but I’m not seeing any switches turn up for me to use to enable/disable the device.

unifi:
  controllers:
    - host: ###.###.###.###
      site: default
      ssid_filter:
        - 'XX999999-9X'
      block_client:
        - 'XX:XX:XX:XX:XX:XX'
        - 'XX:XX:XX:XX:XX:XX'
        - 'XX:XX:XX:XX:XX:XX'  
        - 'XX:XX:XX:XX:XX:XX'  
        - 'XX:XX:XX:XX:XX:XX'  
        - 'XX:XX:XX:XX:XX:XX'

I’ve tested this with both the original custom component code in place and removed, but that’s had no effect. Any help at this point would be gratefully received.

Thanks,

Mike

The site: has you named the site default?

1 Like

Thank you. I don’t know how many times I went over that code but couldn’t see the issue. I’ve fixed the site name and rebooted. I now have switches. Can’t wait to see what you do with this next. Is it on the roadmap to be able to restart AP’s and USGs at some point?

1 Like

Hmm. Haven’t thought about restarting devices. Enable disable wlans is next on my todo. Might need to focus on issues users see with the updated device tracker first though

3 Likes

Can’t thank you enough for this. It’s going to make my life a lot easier!

Thanks for the feedback! I’m happy to hear that :blush:

If I can pick in here regarding the site name…
Is it the actual site name you need to use, or the site name you see in the URL? (In the old configuration it was the site name in the url. For the first site, it was always “default”.
I have to say, in my system it seems to work, except also a lot of errors in the logs with the device tracker, but notice you are busy with it.

Thank you for all your hard work in this! Really appreciated!
I will also be a heavier user of this integration, as I have plenty devices (66 for the moment) on my network. I do a lot of work from home, so have a lot devices that don’t need to be tracked, so would also be interested if at some point it would be possible to bring back the previous behavior of “track_new_devices: false”
Will follow this and other posts, and if necessary can help with tests/logs.

This is one of the first integrations using the new device tracker implementation. Everything is not covered from base. But this feedback will be the base to add relevant functionality.

Regarding site name; yes it is the nice name not the URL name

Please report all errors from the unifi integration. Preferably with accompanied debug logs

Amy chance the block_client switch can be done automatically without having to declare it in the configuration.yaml?
I have all my device trackers grouped by source and state.

I have a monster card/auto-entities card which groups all the tracked devices that are “home” and are from “router” source type (such as ping, Unifi, etc).
I can see myself controlling guest/rogue devices by tapping on them once I see them and having a switch to block them. Maybe within the device_tracker entity popup card? I’m guessing I’m gonna have to resort to custom cards but still doesn’t solve the issue of having to declare all the devices I want to be able to block.

Maybe add an option to include all devices found in the Unifi component as switches to be able to block them?

in 0.97 I just enabled the Unifi integration, and can see the switches for the devices I added to the configuration.yaml, but when I try and switch them I get this error in the frontend:

Failed to call service switch/turn_off. api.err.UnsupportedDevicesOpNotAllowed

If you get errors create github issues with detailed information and logs

Hi Robban,

In the previous connector, we used a group in the unifi controller and any device that was added into that group (ie Block_Unblock) would show up as a switch in Home Assistant. this way we did not have to add any MAC addresses into the configuration.yaml. do you have any plans to also add that config or do we need to always use the MAC addresses?

Thanks
Pedro

Can you share the logic for this block? I can probably add support for that as well

I know this was done a year ago but do you know if it still works with 5.10.26 of the controller. I have the exact same need as you to block my kids devices from the internet until I can verify chores are done or certain times.

I was going to try it since the base functionality doesn’t have this function.

@faspina The base functionality does allow for blocking. The documentation doesn’t read very well (https://www.home-assistant.io/components/unifi/) but in your config file add a “block_client” list of the MAC addresses that you want to be able to block, this will create a “switch” in home assistant that will allow you to block/unblock / automate.

Aah , MAC addresses that makes sense. I think node red unifi component works better for me, I don’t need all those device trackers.

Yeah, I’m not a huge fan of the new basic implementation. I miss the option to only track specific entities, not all entities. I just submitted a PR to update the documentation to include the information about the MAC addresses, hopefully it gets accepted and will be fixed in the future.

1 Like

Hello everyone. I cannot get the Unifi switch entity created. I don’t get any errors in the log but no entity is created. I have tried listing the IP address instead of “unifi” but no luck. Does the site name need to be in quotes? Does it need an underscore (e.g. 116_carter)? Any help would be greatly appreciated. Thanks

unifi:
  controllers:
    - host: unifi
      site: 116 Carter
      block_client:
        - 'd8:31:34:37:0a:87'
      ssid_filter:
        - 'FRANKS'
        - 'BEANS'

Host should be the ip of your controller.
I don’t have quotes around my site but I also don’t have any spaces. I am not sure how things get parsed but quotes would hurt, it should match whatever you have your site name as.
My switches are visible in the Integration existing entities.