BakkesMod Plugin to integrate Rocket League events with Home Assistant
If you really want to buy me a coffee:
Discord: Rocket League Assistant
⭐Special thanks to those in the Discord and notably Branky and JerryTheBee⭐
And some other person named Josh
The plugin utilizes Home Assistant's built in Webhook automation trigger with JSON-based conditions.
- Option 1 - Use a Long-Lived Access Token to automatically create a base automation using Home Assistant's API
- Option 2 - Manually copy and paste the automation YAML to create the base automation
- JSON Values - Keys and values for the JSON requests
-
Generate a Long-Lived Access Token in Home Assistant:
a. Click your username in the bottom left of the Home Assistant web interface
b. Scroll to the bottom under "Long-Lived Access Tokens" and click "Create Token"
c. Give the token a name and press "Ok"
d. Copy the token string. It is best to click into the text box and press CTRL-A to select all, and then CTRL-C to copy the selected text
You will now have a token similar to this:
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiI5NTgxMmNlMWIyYmI0OTRhYTIzN2U0NjNiOTIwMmU5MSIsImlhdCI6MTY4MjM2NzE2OSwiZXhwIjoxOTk3NzI3MTY5fQ.9gdUfsDoYXyTPtqi4vIZ0vuRPFZ-fUrSum_4BxEGzcw
You may want to temporarily paste the code into Notepad or the URL bar -
Use the Template Generator in the plugin's setting window:
a. Press F2 in-game
Plugins
tab ->RocketLeagueAssistant
b. Expand
Automation Template Generator
c. Populate the Home Assistant's Address field with your Home Assistant instance's URL or IP and populate the Token field with the token generated in step 1
d. Click
Generate Automation Base Template
. Your Home Assistant Web Hook Global URL field will be automatically populated with the appropiate URL for Home Assistant.The token will be automatically erased from the plugin and config file on game close for security reasons. It is suggested to also delete the token from Home Assistant after automation generation is complete and confirmed.
The plugin configuration is done.
You should now have an automation called RocketLeague - BakkesGenerated in Home Assistant
-
Populate each condition with the action corresponding with its condition:
-
The color values from the JSON request can be used as the colors for your automations:
a. Select Call a service as your action then edit in YAML.
This will set the color of your lights to the values of your team's primary color. Populate "LIGHTNAMEHERE" with the corresponding entity ID
service: light.turn_on
data:
rgb_color:
- "{{ trigger.json.TeamData.PlayersTeam.color.r |int }}"
- "{{ trigger.json.TeamData.PlayersTeam.color.g |int }}"
- "{{ trigger.json.TeamData.PlayersTeam.color.b |int }}"
target:
entity_id: light.LIGHTNAMEHERE
enabled: true
This will set the color of your lights to brighter values of your team's primary color (Useful for Goals/Demos). Populate "LIGHTNAMEHERE" with the corresponding entity ID:
service: light.turn_on
data:
rgb_color: >
{% set r = trigger.json.TeamData.PlayersTeam.color.r | int %}
{% set g = trigger.json.TeamData.PlayersTeam.color.g | int %}
{% set b = trigger.json.TeamData.PlayersTeam.color.b | int %}
{% macro adjust(color) %} {{ color + (255 - color) / 2 }} {% endmacro %}
{{ [ adjust(r), adjust(g), adjust(b) ] | join(',') }}
brightness_pct: 100
target:
entity_id: light.LIGHTNAMEHERE
enabled: true
Option 2 - Create a new automation using the RocketLeague-BakkesBase.yaml file.
- Create a new automation
- Select Edit in YAML
- Paste the contents of RocketLeague-BakkesBase.yaml
- Manually create a Webhook-ID (A Webhook-ID should be treated as a password and should be randomized like one)
- Edit the actions respectively as shown in Option 1 step 4
x.data /Event data (demo, goal, etc)
x.TeamData.PlayersTeam.color.r /Player's primary color red
x.TeamData.PlayersTeam.color.g /Player's primary color green
x.TeamData.PlayersTeam.color.b /Player's primary color blue
x.TeamData.PlayersTeam.score /Player's team score
x.TeamData.OtherTeam.color.r /OtherTeam's primary color red
x.TeamData.OtherTeam.color.g /OtherTeam's primary color green
x.TeamData.OtherTeam.color.b /OtherTeam's primary color blue
x.TeamData.OtherTeam.score /OtherTeam's score
- Create a new scene corresponding to the scenario (Home Team, Away Team, Demos, etc)
- Give it a name (and icon/area if you'd like)
- Add entities/devices to the scene and adjust the colors accordingly
- Save the scene
- Create a new, or duplicate the scene.
- Add entities/devices to the scene and adjust the colors accordingly.
- Save the scene
- Repeat
If you manually reload the plugin (through the F6 BakkesMod Console) while in the game, the URL will have to be reentered.
- More JSON information
- Probably code clean up and Nullchecks