Ever get deep into a game on your PC, only to be pulled out by a phone notification, bright lights, or an unexpected system sound? It breaks the immersion and can be frustrating. But what if your smart home could automatically know you’re gaming and adjust everything for you? That’s where an automatic “Game Mode” built with Home Assistant comes in.
Contents
- Why You Need Auto Game Mode
- How Home Assistant Detects Your Game
- Method 1: Tapping into Steam
- Method 2: Tracking Windows with HASS.Agent
- Creating the Brains: Your Game Mode Sensor
- What Happens When Game Mode Kicks In? (Building the Automation)
- Silence the World: Phone Do Not Disturb (DnD)
- Set the Mood: Smart Lights
- Optimize Audio
- Turning Game Mode Off (The Reverse)
- Conclusion
By linking your PC’s activity with Home Assistant, you can create automations that trigger the moment you launch a game. This means your lights can dim, your phone can silence itself, and other distractions disappear, all without you lifting a finger. This guide breaks down how to set up this super practical automation using a combination of your Steam status and a handy tool called HASS.Agent.
Why You Need Auto Game Mode
Automating your gaming environment isn’t just cool; it’s practical.
- Eliminate Distractions: Silence phone notifications and prevent unexpected alerts.
- Set the Mood: Adjust lighting for better focus or ambiance.
- Optimize Audio: Ensure game sounds are prioritized over music or other background noise.
- Seamless Experience: No need to manually change settings every time you start playing.
Home Assistant’s flexibility allows you to tailor this mode exactly how you like, making your gaming sessions smoother and more immersive.
How Home Assistant Detects Your Game
To trigger your game mode, Home Assistant needs to know when you’re playing a game. We’ll use two main methods for robust detection:
Method 1: Tapping into Steam
If you play games on Steam, this is the easiest route. The Home Assistant Steam integration can track your online status. When you launch a game through Steam, the sensor linked to your account gets updated with details about the game you’re currently playing.
You’ll need a Steam Web API key for this, which is free and easy to get. Think of it like giving Home Assistant permission to politely ask Steam what you’re up to. This method is great because it knows you’re still “in-game” even if you briefly alt-tab out to check something.
Home Assistant UI showing Steam integration sensor attributes, including the detected 'game' attribute used for game mode.
The key piece of information here is the game attribute attached to your Steam sensor in Home Assistant. If this attribute exists and has a value, it means you’re playing a game detected by Steam.
Method 2: Tracking Windows with HASS.Agent
For games not on Steam, or apps you want to treat as ‘game mode’ triggers, HASS.Agent is incredibly useful. This free Windows application acts as a bridge between your PC and Home Assistant. One of its many abilities is reporting the name of the window currently active on your computer.
By checking if the active window name matches a specific game (like “VALORANT”), Home Assistant can detect non-Steam games too. The main difference here is that HASS.Agent only reports the currently focused window. If you alt-tab, it will report the new window name, potentially turning off game mode briefly. Combining it with the Steam method covers more bases. You’ll need HASS.Agent set up and configured to send active window data to Home Assistant. (Looking for more on HASS.Agent? Learn why HASS.Agent is a must-have for Windows Home Assistant users).
Creating the Brains: Your Game Mode Sensor
Now that we have two ways to detect gaming, we need a single “switch” in Home Assistant that turns ON if either Steam detects a game or HASS.Agent sees a specific game window. We do this with a Home Assistant helper sensor, specifically a “template binary sensor.”
A binary sensor is just an entity that can be ON or OFF. A template sensor uses a simple formula (the template) to determine its state.
Here’s the template that checks both conditions:
{{ (state_attr('sensor.adam_steam', 'game') is not none) or (states('sensor.desktop_73d9nef_activewindow') == 'VALORANT') }}
Let’s break this down simply:
state_attr('sensor.adam_steam', 'game') is not none: This checks if your Steam sensor (sensor.adam_steam– replace with your sensor name) has agameattribute. If it does (meaning it’s “not none”), this part is true.or: This is the key – either the Steam condition is true or the next condition is true.states('sensor.desktop_73d9nef_activewindow') == 'VALORANT': This checks if the current state (the window name) of your HASS.Agent active window sensor (sensor.desktop_73d9nef_activewindow– replace with yours) is exactly ‘VALORANT’. If it is, this part is true.
If either of these checks is true, your new binary sensor will turn ON, indicating Game Mode should be active. Otherwise, it stays OFF.
You can create this template sensor directly in your Home Assistant configuration.yaml file or through the UI if you have the Helper feature that supports template sensors enabled.
Home Assistant Template Editor displaying the YAML code for the Game Mode binary sensor, combining Steam and HASS.Agent logic.
What Happens When Game Mode Kicks In? (Building the Automation)
With your Game Mode sensor ready, you can build an automation that triggers when this sensor turns ON.
Your automation’s trigger will be simple:
- Trigger: State change of your Game Mode binary sensor.
- From:
off - To:
on
Now for the fun part: defining the actions! What do you want Home Assistant to do when you start gaming? Here are some ideas based on the original setup:
Silence the World: Phone Do Not Disturb (DnD)
This is a fantastic way to avoid pop-ups and notification sounds. Home Assistant’s mobile app integration allows you to send commands to your phone.
actions:
- service: notify.mobile_app_cph2671 # Replace with your phone's notification service name
data:
message: "command_dnd"
data:
command: "total_silence" # Or other DnD modes depending on your phone/app version
This action sends a specific command through the Home Assistant app on your phone, instantly putting it into a silent Do Not Disturb mode. No more game interruptions!
Set the Mood: Smart Lights
Change the lighting in your room to reduce eye strain, set a specific atmosphere, or indicate that you’re busy gaming.
actions:
- if:
- condition: state
entity_id: light.office_light # Replace with your light entity ID
state: "on"
then:
- service: light.turn_on
data:
brightness_pct: 5 # Dim lights significantly
rgb_color: [237, 44, 44] # Set to red (or your preferred color)
target:
device_id: 7443cc0d215861e4624f05e2ea6c3fb5 # Replace with your light's device ID
This action includes a check (if condition) to only change the light if it’s already on. It then dims it to a low brightness and sets a red color – perfect for late-night gaming vibes.
Optimize Audio
If you use specific audio hardware like a GoXLR or software mixers, you might be able to control them via Home Assistant integrations.
An example action might be:
- Increase the ‘Game’ channel volume.
- Decrease or pause the ‘Music’ channel volume (if you were listening to music).
The specifics here depend heavily on the devices and integrations you have set up for audio control in Home Assistant. Alternatively, you could use HASS.Agent to run a command on your PC that adjusts software mixer volumes.
Combine these actions (and any others you can think of!) within the single automation triggered by your Game Mode sensor turning ON.
Turning Game Mode Off (The Reverse)
Just as important as turning Game Mode ON is turning it OFF and returning things to normal. You’ll create a second automation for this.
- Trigger: State change of your Game Mode binary sensor.
- From:
on - To:
off
The actions for this automation will be the reverse of the first:
- Turn off phone Do Not Disturb.
- Return lights to their previous state (this can be tricky and might require saving the state when game mode turns ON). A simpler approach is just setting them to a default ‘normal’ state.
- Reset audio levels.
Setting devices back to their exact previous state requires more advanced Home Assistant techniques like using helper variables to store the state before Game Mode activates. For a simpler setup, just returning them to a sensible default is a great start.
Conclusion
Building an automatic Game Mode in Home Assistant is a prime example of how smart home technology can genuinely improve your daily life – or in this case, your gaming sessions! By combining simple integrations like Steam and HASS.Agent with Home Assistant’s automation power, you can create a seamless, distraction-free environment tailored for focus and immersion.
This setup is just the beginning. You can expand it to control fans, monitor temperatures, display status on a screen (like with an ePaper display), or anything else integrated with Home Assistant. Dive in, experiment with the actions, and build the ultimate automated gaming sanctuary!