Disable internet to any device

Mine is on a Ubuntu server with Virtual Env.

right i think i have that as well on an ubuntu server i set this one up fromthis link il have a go with this as well but am pretty sure the hassbian install will work.

anyone had any luck installing this on HASSIO.

I install ARP component in hassbian 0.92.2 step by step in arpspoof.markdown
after reboot pi
The log show error :

2019-05-13 06:39:06 ERROR (MainThread) [homeassistant.setup] Setup failed for arpspoof: No setup function defined.
2019-05-13 06:39:17 ERROR (Thread-14) [custom_components.arpspoof.switch] ARP component not initialised!

My file in custom_component is /arpspoof/
init .py
arpspoof.py
manifest.json
switch.py

how to fix it. thanks

Hi i had to drop the support for that one as it is not reliable see above, but i’m open for anyone to contribute

Hi @pilotak
You posted one year ago that you have moved to a Mikrotik router solution. I think I will follow your steps. Since I’m not an IT guy, I’ve been reading a lot the docs at Mikrotik website these past nights. The devices are very flexible, which also means a bit complex to start with. But, hey, life is learning. If you don’t mind, right now I have two questions:

  1. Which router do you use? I was considdering this one My flat is around 110 squared meter and just one floor.
  2. I’ve seen your github. I see the custom component but not the scripts to stop connections. Am I missing something?

Thanks a lot for your guidance!

That’s exacly why chose Mikrotik due to its flexibility.

  1. I use this one and at my friend’s home there is this one where he is using it for the same purpose. But any Mikrotik will be fine
  2. It’s generic component for running scripts not just for disabling internet.

Here is the guide in Mikrotik

  • Create separate login credentials for HASS

  • Create firewall rule: Chain=forward, Src. MAC Address=00:00:00:00:00:00 (select device address), Action=reject, Reject With=icmp admin prohibited after save you will see an id of the rule ie.: 10 (you will use this number in scripts)

  • Give your device static IP address in DHCP section ie.: 192.168.0.100

  • Create script with name internet_tom_on this will enable firewall rule you created above (it will block new connections), next line is also important as it closes all connections made before enabling firewall rule

/ip firewall filter enable 10
:foreach i in=[/ip firewall connection find where src-address~"^192.168.0.100:.*\$"] do={ /ip firewall connection remove $i }
  • Create script with name internet_tom_off
/ip firewall filter disable 10

In HASS config:

script:
internet_tom_on:
    sequence:
      - service: mikrotik.run_script
        data:
          name: internet_tom_on
      - service: input_boolean.turn_on
        data:
          entity_id: input_boolean.internet_tom

  internet_tom_off:
    sequence:
      - service: mikrotik.run_script
        data:
          name: internet_tom_off
      - service: input_boolean.turn_off
        data:
          entity_id: input_boolean.internet_tom

input_boolean:
  internet_tom:

switch:
  - platform: template
    switches:
      internet_tom:
        value_template: "{{ is_state('input_boolean.internet_tom', 'on') }}"
        turn_on:
          service: script.turn_on
          data:
            entity_id: script.internet_tom_on
        turn_off:
          service: script.turn_on
          data:
            entity_id: script.internet_tom_off
2 Likes

Thanks a lot! Very useful and detailed explanation! I’m definitely moving to your approach. I’ll come back when I set it up. Thanks again!

Edit: it seems that you and your friend have the same device :joy: (you put the same link; anyway, glad to hear that anyone will be ok, thanks)

sorry, corrected

And two weeks later… just to let you know that this works beautifully. Thanks a lot!

Does this also work with UniFi?

Perfect, I’m happy that it’s useful for somebody else too.

@7even not sure if it has a scripting support but if it has you would need to create a custom component for that as the one I created is only for Mikrotik

any hassio user got this working?

Maybe this?

1 Like

I am looking for something like this for Google WiFi. But I fear the api is not open or understood well enough for that yet…

Hi, does anybody have instructions about how I do this with UniFi network controller. I would like to create a button that blocks a device on UniFi controller but struggling to understand who I need to trigger.

hey @datamonkey, were you able to ifnd a solution for google wifi?

im wonderiing if there is a way to use this https://documenter.getpostman.com/view/7490211/SzzdD1pF?version=latest#193331e1-5074-4d96-b9b6-56994fcd8771

to pause internet on google wifi on all devices?

1 Like

Thanks @alexbell hat looks interesting, last time I checked this list was much shorter…
Will need to play a bit with this when time permits.