At the present time no custom code can run locally. The reason is because Smart things is still a cloud-based architecture. The only thing that runs locally is the official smart lights smart app and some parts of the official smart home monitor, Plus some of the stock device type handlers for some zigbee and zwave devices. ( even official LAN integrations like the one for Philips Hue don’t run fully locally-- they require cloud access to authenticate the request . )
The reason is because under the current design, anything which is going to be run locally is pushed out to all hubs as part of the firmware update. There’s no way to limit A code update to an individual account. Which means any custom smart app or DTH would get pushed out to every customer, and they just don’t want to do that.
They said they would like to change this method in the future and allow for more local processing, but there’s no timeline for it now.
Detailed discussion in the following thread: