You need to be able to enumerate all the possible scenario in your head in order to make a script that looks intelligent. eg: ok I want the light to start when I'm entering and switch them off when I leave. Well unless there is somebody inside (another sensor), unless I just pick the mail (a timer). How do I communicate my intention to come back, so the house does not switch off my netflix download ? If the lock is unlocked, but then shouldn't that generate an alert instead ? That's hopeless for regular user and even for developer that is too much effort for too little benefit.
The other approach is Nest, that is trying to guess. So your home would monitor what you do and try to replicate it. I'm not confident - take an application like Word, they are still irritating after decades of intellisense and a somewhat controlled and restricted environment.
The only one that could work I think would be an Apple bludgeon approach. Your front door and lights and heater work all together nicely following 1 strict scenario. You either adapt to it or don't buy their product at all ( so if Apple decide that morning means raising the blinder and you would rather let them down in order to get clothed, you better learn to have to change your clothes in the bathroom )