About a million years ago, I wrote a ‘side’ project for TrixBox (Hi Wade!) that would manage my extension in my home office by setting the resetting the Extension DND settings through a database “set” command from the Asterisk command line. It was tied to the presence of my cell phone’s Bluetooth connection. If the phone was “close”, calls would go to my office phone; if not, they would DND through to the cell’s “extension”.
Something like that (scanning a datasource and using an ‘rasterisk’ call to set the DND status should be simple enough.