FacebooktwitterredditpinterestlinkedinmailFacebooktwitterredditpinterestlinkedinmail

A few years back, I wrote about integrating my dumb gas fireplace into Home Assistant using a Wemos D1 Mini. A few weeks ago Github user locii created an integration for Home Assistant that lets you integrate the popular PC game, Counter Strike: Global Offensive. So I figured I need to combine these things, and summon fire when the bomb goes off in the game. This article walks you through setting up something like this.

Here it is in action:

Here’s what you’ll need

[amazon_link asins=’B07TD42S27,B07TYK4RL8,B01HXM8X88′ template=’ProductCarousel’ store=’azsertmarw-20′ marketplace=’US’ link_id=’c7faa01f-39c2-49bf-9a9e-928b9751899f’]

Setup Home Assistant

I recommend setting up Hassio, which I believe was recently renamed to Home Assistant. That link has instructions on how to set it up on a variety of systems, including the Pi’s.

After you setup Home Assistant, install HACS using these instructions. HACS allows you to easily install more integrations into Home Assistant.

Once you have HACS installed, go into the Home Assistant web interface and click on HACS on the left side, and then click Integrations. Search for csgo and click on CS:GO game state and then click Install. If it asks you to restart Home Assistant, go ahead and do that.

Next, on the left side, click Configuration -> Integrations and click the ‘+’ icon on the bottom right. Search for csgo and click on CS:GO game state listener.

Note the URL it gives you after “uri”. You will need that for the next step.

CS:GO Setup

  1. In Steam, go to Library and right-click on CS:GO -> Manage -> Browse Local Files
  2. Go into the csgo folder, and then into cfg
  3. Create a new file named gamestate_integration_homeassistant.cfg
  4. Open that file in Notepad and copy and paste the following text in there and replace ‘HomeAssistantURL’ with the URL you got from Home Assistant.
    "HomeAssistant Integration v.1"
    {
     "uri" "HomeAssistantURL"
     "timeout" "5.0"
     "buffer" "0.1"
     "throttle" "0.5"
     "heartbeat" "15.0"
     "data"
     {
       "round" "1" // round phase, bomb state and round winner
     }
    }
  5. Save the file

Home Assistant Setup For a Simple Automation

Here, I’ll show you how to take an RGB bulb, and make it turn green when the bomb is planted, yellow when there’s 10 seconds left, and red when there is 5 seconds left.

There are TONS of different bulbs that work with Home Assistant. Whichever one you go with, you will need to get it added into Home Assistant. The TP-Links are fairly easy to add. You can add the integration for it in the Configuration -> Integrations

In Home Assistant, click Configuration -> Automations and click the ‘+’ symbol at the bottom right, and click “Skip” if it asks you a question there.

Just make the page look like the screenshots below:

Enter a name for the automations, and have it trigger on the ‘csgo_bomb_planted’ event. These next 2 screenshots are all the actions that happen after the bomb planted. That 35 in the first screenshot needs to be 30. It turns on the light green, waits 30 seconds, turns the light yellow, waits 5 seconds, turns the light red, waits 5 seconds, and then turns the light off. The bomb should go off when the light turns off. 

A slightly more advanced automation using the fireplace

This automation will start a timer when the bomb is planted. The fireplace will turn on ONLY if the bomb goes off before the round ends. In the previous example, the lights would still do their thing even if the round ended before the bomb went off.

First, copy the following code into your configuration.yaml in  your Home Assistant config. Using the Visual Studio Code addon in Home Assistant makes editing these files much easier. You can find it in Addons in Home Assistant.

timer:
  planted:
    name: Plant Timer
    duration: 37

This creates a timer that starts when you plant the bomb. I need to trigger the fireplace a few seconds early because the gas takes a few seconds to start flowing. That’s why I need a special automation for this.

First, create an automation that starts that timer when the bomb is planted:

 

 

 

 

 

 

Then add an automation that will cancel the timer and turn off the fireplace if the next round starts before the bomb goes off:

 

 

 

 

 

 

Finally, an automation to kick off the fireplace for 5 seconds if the timer goes down to 0.

 

 

 

 

 

 

And that’s it. When the bomb goes off, a much smaller explosion happens. Please let me know if you have any questions or comments. Or if you have any other ideas to take this a step further. As I said before, I think the timer on an OLED might be useful for the actual game. If others have interest in it, I can set that up.

Leave a Reply

Your email address will not be published. Required fields are marked *