This would work (even?) better if it wasn’t a switch, but a push button with the unblocking automatically timing out after some interval. Otherwise you’re prone to just letting it stay on unblock.
The Amazon Dash buttons could be hacked to do something like that.
You could use a home assistant-like api to turn off the switch as well as manage the /etc/hosts changes. I don’t have any experience with home assistant, per-se, but I have programmatically controlled similar the switches with an older api, so I assume HA would work too.
Similarly: https://flic.io/
Little programmable buttons, they're great. I've used them for similar habit formation stuff, in my case not ignoring my alarm, by making the button the only way to shut it off, and putting the button very far away from bed.
Nice, but pretty expensive at $35 for the simplest button. For comparison, an IKEA smart button/dimmer is only $10.
Sonoff buttons are even cheaper, I think. IKEA buttons work well too, though.
In Europe they are more expensive than the IKEA ones for some reason, but thanks for the tip, they look nice.
It depends where you get them from, I get mine from Ali for around $7? Locally they cost around 7 € as well, IIRC.
I only see prices above 9 € on AliExpress, but it's still a good price.
Hm yeah, it looks like they stopped making the SNZB-01, now they only have the SNZB-01P, it seems. I don't know what the differences are, I'm afraid.