How do you use modes (revisited)?

@ogiewon's Bed Presence solution:

It does require some skill and comfort with microcontrollers to setup but it has been my wife and I's favorite automation.