Integrating Multiple Services into a Single Scene in Home Assistant

Hey everyone, I wanted to share my recent project where I integrated multiple services into a single scene using Home Assistant. It’s been a fantastic way to streamline my smart home setup and make everything work together seamlessly!

I started by reorganizing my configuration.yaml file to allow multiple scenes or scripts to be used within a single component. This involved creating separate folders for groups, automations, and scripts, which made the configuration much cleaner and easier to manage. Here’s a quick look at how I structured it:

group: !include_dir_merge_named groups/
automation: !include_dir_merge_list automations/
script: !include_dir_merge_named scripts/

Each folder was organized to keep related services together. For example, the groups/ folder contained YAML files for different scenes, while the scripts/ folder held the logic for each service. I also created a data_template_script/ folder to store reusable script bodies, which helped reduce redundancy in my code.

One of the key features I implemented was the ability to control both lighting scenes and Spotify playlists through a single input select. This meant I could choose a scene like ‘Festa’ or ‘Romantico’ and have the corresponding lights and music start automatically. Here’s a snippet from one of my scripts:

complete_scenes:
alias: “Qual é o sentimento do seu ambiente?”
sequence:
- service: scene.turn_on
data_template: !include …/data_template_script/scenes_for_complete_case.yaml
- service: media_player.play_media
data_template: !include …/data_template_script/spotify_playlist_for_complete_case.yaml

This setup has been incredibly versatile. Whether I’m hosting a party or just relaxing at home, everything works together perfectly. I also appreciate how easy it is to add new services or scenes by simply updating the relevant YAML files.

If anyone has tips on further optimizing this setup or suggestions for additional features, I’d love to hear them! It’s been a rewarding project, and I’m excited to see how I can expand it even further.

Happy automating! :rocket: