Simple ideas to assist with your smarthome renovation
It’s Game time! How to receive notifications when the crew are online via Home-Assistant and Node-red.
Ok, so I am a Gamer. Big time. I love to game and always have done. From the early days of cabbage patch kids, rock ‘n’ roll racer, to James Pond on the Mega drive, and Goldeneye on the N64. You name the console, i’ve probably had it. I wanted to find a way to bring home automation into my gaming. Glancing through the integrations on Home-Assistant I noticed that they had an integration for Steam. I play a fair bit on steam, being a lover of Half Life: Team Fortress 2 so I checked into the integration further. I decided I wanted to set up an integration that let me know when my close friends were playing online. This was relatively simple in Node-red.
First I needed to set up the Steam integration in Home-Assistant. This was simple enough, my code is as follows (assuming you’ve split out your configuration.yaml it goes in sensors.yaml if you haven’t then this goes under the sensors section.):
To get the steam IDs of your friends, you need to follow the instructions mentioned here:
“To find an account’s 64-bit SteamID on profiles without a custom URL you can check the URL of the profile page, the long string of numbers at the end is the 64-bit SteamID. If the profile has a custom URL you will have to copy the URL into STEAMID I/O to find the 64-bit SteamID.”
Now that’s set up, i restarted Home-Assistant and now had 5 sensors for my friends showing whether they’re online or not on Steam. I now needed to automate it so that I was going to know if anyone was playing or not, so I looked into Node-red and came up with the following flow:
The flow works as follows:
If there’s a state change on the Steam sensors and if any of my friends go “online”, it sends the payload into the second node which checks if I am at home or not. If I’m away from home it stops there as I don’t want to be bothering my girlfriend unecessarily, nor do I want my phone to be pinged whilst I am out.
Assuming I am home, the payload proceeds to the time filter (this is Peter Scargill’s bigtimer) and as long as the time is between 18.45 and 23.45 it will then proceed to notifications:
Firstly, I get a message come up on my android phone that “One of the boys is playing online”.
Secondly, Google Home announces (via TTS) that “One of the boys is playing online right now”.
You can see the node configurations below:
Big Timer is an incredibly powerful node which can do a variety of functions. I’ve only just scratched the surface. If you wanted to use a more simplified node as a time-gate you could follow the example I have here where I describe how to create a motion sensitive night light that only works during certain times.
The flow above works perfectly. I am also in the midst of building on top of it. These are the things I want to add additionally:
I want to be able to notify our LG WebOS TVs as well, which I shall cover in a different tutorial.
I want the phone notification to be actionable. I want the choice to be “ignore” or “join” ? If I select to join them, I want the pc to automatically switch to game mode. This will involve waking the pc from it’s currently state and running a script that will start Steam and Discord (i think i already have the means to do this, so will write it up when I get round ot setting it in play).
For bonus points, I also have a couple of video lights (i’m a streamer and you can find me at twitch.tv/thebaldfox) and I know they’re bluetooth controllable. I am looking for a way to trigger them via bluetooth in home-assistant or via my pc, so that not only is my pc ready for gaming, but should I wish to stream, I can also automatically switch these on and set them to the appropriate white balance and power setting. This is a longer term project though because I need to understand how to sniff the bluetooth traffic and reverse engineer the .apk file (android) to try and find the commands. Anyone have any ideas there?
Hopefully some of you found this useful. I’ve also set this up for a friend who has kids, and they love it. They only allow the notifications to pass through after a certain time once homework has been completed!
Let me know if you have any questions or comments!