I've got a cube that's hooked into my Home Assistant setup that works similarly. Flipping the cube upside down turns my bedside light on or off, rotating it clockwise increases the brightness, and counterclockwise decreases it.
I did something similar using these: https://eu.aqara.com/products/aqara-cube-t1-pro (or rather, an earlier iteration). Just Zigbee, nothing too complex, and then you hook it into something which knows how to interpret the events it sends (or events + current state if you want it to be a little more contextually smart). I generally tried to centralise the smarts, dumb devices and a smart interpreter always worked out more robust than clever devices. It's amazing how many combinations of actions you can indicate just by shaking/tapping/turning/flipping - more than enough to do the things you commonly do with one actuator (a light or set of lights for example).