I have been trying to do exactly this same thing with the help of @JDRoberts over at this thread…
I am migrating my efforts here so we can merge ideas and successes. I don’t know if I needed to do this or not, but I made a custom device driver that implemented the sensor and momentary capabilities. Your approach looks simpler.