Skip to content

Gtt1229/RocketLeagueAssistant

Repository files navigation

Rocket League Assistant

BakkesMod Plugin to integrate Rocket League events with Home Assistant

If you really want to buy me a coffee: ko-fi

RLHAbanner

⭐Special thanks to those in the Discord and notably Branky and JerryTheBee

And some other person named Josh

Home Assistant Configuration

The plugin utilizes Home Assistant's built in Webhook automation trigger with JSON-based conditions.

Home Assistant Automations Configuration:

  • 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

Option 1 - Generate the base automation using the in-game plugin settings window

  1. 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

    HATokenStep1

    HATokenStep2

    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

  2. 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.

    RLAGenerateAutomation

You should now have an automation called RocketLeague - BakkesGenerated in Home Assistant

  1. Populate each condition with the action corresponding with its condition:

    HAEditConditions

  2. 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

More on automations here

Option 2 - Create a new automation using the RocketLeague-BakkesBase.yaml file.

  1. Create a new automation
  2. Select Edit in YAML
  3. Paste the contents of RocketLeague-BakkesBase.yaml
  4. Manually create a Webhook-ID (A Webhook-ID should be treated as a password and should be randomized like one)
  5. Edit the actions respectively as shown in Option 1 step 4

JSON Values

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

Home Assistant Scenes Configuration to be Used in Automation(Not Required):

  1. Create a new scene corresponding to the scenario (Home Team, Away Team, Demos, etc)
  2. Give it a name (and icon/area if you'd like)
  3. Add entities/devices to the scene and adjust the colors accordingly
  4. Save the scene
  5. Create a new, or duplicate the scene.
  6. Add entities/devices to the scene and adjust the colors accordingly.
  7. Save the scene
  8. Repeat

More on scene creation here

Open your Home Assistant instance and show the blueprint import dialog with a specific blueprint pre-filled.

Notes

If you manually reload the plugin (through the F6 BakkesMod Console) while in the game, the URL will have to be reentered.

To Do

  • More JSON information
  • Probably code clean up and Nullchecks

About

Rocket League events to Home Assistant using BakkesMod

Resources

License

Stars

Watchers

Forks

Packages

No packages published