For example lets consider your case with motion sensors and how to solve it with DeviceHive and esp8266. Each bulb, motion sensor and switch have embedded esp8266 module with DeviceHive firmware. Each module is connected to cloud service which is DeviceHive server + application with business logic implementation. This application waits for event from switches and sends command for turning on/off corresponding bulb. It also analyzes data from motion sensors. We can track humans presence in each room. For example, if someone enters into a room there is no need to turn off light before someone leaves a room. Except bedrooms where special logic can be implemented. Sure, this logic can have schedule with some rules, for example special schedule for holidays. It's not a big deal for app which works in cloud
Also, this model is very useful if you want to change something in logic. For example you want to add feature that lights shouldn't be turn on in daytime. You can take sunrise and sunset time from some weather forecast service or calculate it by yourself and use this data to turning off lights. All that you need to do is deploy new app with new business logic to cloud. And all devices would follow new logic.