Hoist TM sensor code to a separate file on the server side (uglily).