That’s exacly why chose Mikrotik due to its flexibility.
- 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
- 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 prohibitedafter 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_onthis 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