Hacker News new | ask | show | jobs
by selvakn 3260 days ago
If it is for executing some script on successful connection of any device to wifi (and thus an IP is assigned), with dhcpd, it can be achieved with the following config:

  subnet 192.168.1.0 netmask 255.255.255.0 {
    on commit {
      set ip = binary-to-ascii (10, 8, ".", leased-address);
     execute ("/usr/local/bin/on-device-connect", "commit", ip);
    }
  }
I have setup exactly this to automate stuff unlocking the door in my office (in the morning, whenever some one arrives and phone connects to wifi).

My original source: http://jpmens.net/2011/07/06/execute-a-script-when-isc-dhcp-...

Edit: Fix code formatting.

2 comments

Ah but that's not cloud native at all!

More seriously, part of the reason I did the project was to see if I could have things react to the dhcp server, and not have the dhcpserver run things for me. No good reason, other than wanting all the components in my home network to run in their own VMs, and so having everything talking via etcd is convenient.

That said, if I didn't have copious amounts of free time, I definitely should have done that.

What does "cloud native" mean? Microservices in containers?
Can you share more information on how your setup physically unlocks the door? Does it involve an electric strike or a motor that turns a lock?
Sure.

This is the lock that Im using: http://www.ebay.com/itm/12V-Electromagnetic-Door-Locks-Magne... . Its electromagnetic and not a turn lock.

And the actuator that I built to control the lock is something like this: https://www.tindie.com/products/Armtronix/wifi-esp8266-solid...

The callback script in the dhcp server pushes an event to a mqtt broker on dhcp commit event.

And all of these orchestrated by home-assistant.io, on top of which, we have also mobile and voice (alexa) integration too.