Playnite is an amazing game library manager that combines all my pc games (and emulators) in a highly customisable front-end. The best part is the 'Fullscreen'-mode: An interface made for televisions with controller support.
I want Home Assistant to know when we are playing a game on our TV so that I can automate the living room accordingly.
Let's take this step-by-step
To start off, I created a input boolean in Home Assistant called 'Game Mode'. Playnite will use this to tell Home Assistant a game is being played.
At the Home Assistant side, this is pretty much it. Next up is using a Powershell Module, written by GitHub user 'flemmingss'. This will allow us to write a script that we can execute every time a game is run trough Playnite. Download the repository and extract the 'Home Assistant' folder to a place where it can sit untouched. This folder contains the 'Powershell Module' we will refer to later.
I wrote the following little scripts to toggle 'Game Mode' on and off. Remember to add your own Home Assistant IP and Long Lived Access Tokens to the scripts. You can obtain the token via your profile page. Save these scripts in a folder where it won't accidentally be deleted.
The last step is to open Playnite's settings. On the 'Scripts'-tab, add the following lines to turn 'Game Mode' on when starting a game and to turn 'Game Mode' off when you quit playing.
This is a very basic way of connecting Playnite with Home Assistant. I would love to send Home Assistant metadata such as the name of the game we are playing, including the coverart. To be continued...