I’ve been trying to set up my home theater automation in Home Assistant, and I thought I’d share my journey in case others are tackling something similar. The goal was to have my living room lights dim when watching a movie on Kodi and turn back on once the movie ends. Sounds simple, right? Well, it turned out to be a bit of a puzzle, but I figured it out!
First, I looked into using the media_content_type attribute in Kodi. This attribute tells you if what’s playing is a movie, TV show, or something else. I set up an automation to trigger when the media_content_type is ‘movie’ and Kodi is playing. It worked perfectly for turning the lights off when the movie started. But here’s the catch: when the movie ended, the automation didn’t fire as expected. The media_content_type disappears when the movie stops, so the condition fails.
After some research, I stumbled upon a clever workaround using an input_text entity. The idea is to store the media_content_type in input_text when the movie starts. Then, when the movie ends, the automation checks this input_text instead of the Kodi state, which might have already changed or cleared. This ensures the lights turn back on reliably.
Here’s how I set it up:
- Create an input_text entity in your Home Assistant configuration to store the media type.
- Modify the automation to update this input_text when the movie starts.
- Adjust the stopping condition to check the input_text instead of the Kodi state.
This solution not only fixed the issue but also gave me more flexibility. I can now easily expand it to handle different content types or even other media players if needed.
If you’re working on similar automations, I’d love to hear your tips or any alternative approaches you’ve tried. Let’s keep the brainstorming going! ![]()
![]()