My smart home automations documented.
Here is the overall architecture of my most of my automations.
In order to maintain more advanced logic for your ligthing, music, temperature etc, I reccomend to use multiple layers of state as illustrated in the figure above.
Scenes represent one state of multiple devices. I typically create scenes for each room. Examples of scenes can be "Bathroom night", "Bathroom dimmed", "Bathroom normal", "Living room dimmed", "Living room TV", "Living room dinner".
Aggregated states are varaibles representing a simple value for something. Most of my aggregated states are boolean, such as "is the TV on", "is the sun outside above 30 degrees above horizon", "is someone at home", "is there someone present in the living room". Often multiple sensors are involved in updating an aggregated state, such as a combination of door sensors and motion sensors to represent presence in a room, or multiple presence devices for multiple people to represent whether or not somebody is at home. I also have a few aggregated states that are strings, and not boolean, such as the timeperiod, which can have one of a few predefined text values.
Here is my reccomended steps to getting started
Test each step independently by inspecting the logic view on your phone.