From time to time I like to play a round of CS:GO. I’m also watching some tournaments on Twitch and always liked how they sync the stage to the game state. That is something I wanted to have in my own home.
Thankfully CS:GO provides a simple game state subscription that is easy to integrate into HomeAssistant.
A few hours later, the CS:GO game state integration was born. It adds a webhook to HomeAssistant that can be triggered by the CS:GO client. Some small logic parsed the webhook messages and keeps track of the game state to fire events in HomeAssistant. Those events can then be used to trigger automations.
Now everyone can immerse with the game.
Watch me play against harmless bots for demonstration
My automation consists of scripts that perfom all the actions and automations that are triggering the scripts:
scripts.yaml
csgo_freezetime:
alias: CSGO - Freezetime
sequence:
- data:
entity_id:
- script.csgo_flashloop1
- script.csgo_flashloop2
service: script.turn_off
- data:
rgb_color:
- 83
- 52
- 235
transition: 0.5
entity_id: light.example
service: light.turn_on
csgo_begin_end:
alias: CSGO - Round start/end
sequence:
- data:
entity_id:
- script.csgo_flashloop1
- script.csgo_flashloop2
service: script.turn_off
- data:
transition: 1
xy_color:
- 0.45989990234
- 0.41059875488
entity_id: light.example
service: light.turn_on
csgo_bomb_planted:
alias: CSGO - Bomb planted
sequence:
- data:
rgb_color:
- 255
- 190
- 0
transition: 0.5
entity_id: light.example
service: light.turn_on
- delay: '1'
- service: script.csgo_flashloop1
csgo_bomb_defused:
alias: CSGO - Bomb defused
sequence:
- data:
entity_id:
- script.csgo_flashloop1
- script.csgo_flashloop2
service: script.turn_off
- data:
rgb_color:
- 0
- 255
- 0
transition: 0.5
entity_id: light.example
service: light.turn_on
csgo_bomb_exploded:
alias: CSGO - Bomb exploded
sequence:
- data:
entity_id:
- script.csgo_flashloop1
- script.csgo_flashloop2
service: script.turn_off
- data:
rgb_color:
- 255
- 0
- 0
transition: 0.5
entity_id: light.example
service: light.turn_on
csgo_flashloop1:
alias: CSGO - Flashloop 1
sequence:
- data: {}
entity_id: script.csgo_flashloop2
service: script.turn_off
- service: script.csgo_flashloop2
- data:
flash: long
entity_id: light.example
service: light.turn_on
- delay: '10'
csgo_flashloop2:
alias: CSGO - Flashloop 2
sequence:
- delay: '1'
- timeout: 00:00:15
wait_template: '{{ states.script.csgo_flashloop1.state == "off" }}'
- service: script.csgo_flashloop1
automations.yaml
- id: '00000001'
alias: CSGO - Freezetime starts
description: ''
trigger:
- event_data: {}
event_type: csgo_round_freeze
platform: event
condition:
- condition: device
device_id: 12345
domain: light
entity_id: light.example
type: is_on
action:
- data: {}
entity_id: script.csgo_freezetime
service: script.turn_on
- id: '00000002'
alias: CSGO - Round starts or game ends
description: ''
trigger:
- event_data: {}
event_type: csgo_round_started
platform: event
- event_data: {}
event_type: csgo_game_stopped
platform: event
condition:
- condition: device
device_id: 12345
domain: light
entity_id: light.example
type: is_on
action:
- data: {}
entity_id: script.csgo_begin_end
service: script.turn_on
- id: '00000003'
alias: CSGO - Bomb planted
description: ''
trigger:
- event_data: {}
event_type: csgo_bomb_planted
platform: event
condition:
- condition: device
device_id: 12345
domain: light
entity_id: light.example
type: is_on
action:
- data: {}
entity_id: script.csgo_bomb_planted
service: script.turn_on
- id: '00000004'
alias: CSGO - Bomb exploded
description: ''
trigger:
- event_data: {}
event_type: csgo_bomb_exploded
platform: event
condition:
- condition: device
device_id: 12345
domain: light
entity_id: light.example
type: is_on
action:
- data: {}
entity_id: script.csgo_bomb_exploded
service: script.turn_on
- id: '00000005'
alias: CSGO - Bomb defused
description: ''
trigger:
- event_data: {}
event_type: csgo_bomb_defused
platform: event
condition:
- condition: device
device_id: 12345
domain: light
entity_id: light.example
type: is_on
action:
- data: {}
entity_id: script.csgo_bomb_defused
service: script.turn_on
Scripts and automations can be pasted to the according files and are fully compatible with the UI editors.
Installation instructions using HACS
Have fun.