Home » Blog » Event Triggers Unveiled: Control the Home Assistant Media Player with Your Remote Control

Event Triggers Unveiled: Control the Home Assistant Media Player with Your Remote Control

When creating automations in Home Assistant, you can choose different triggers that the automation should respond to. One of those triggers is the Event Trigger. This is a more advanced trigger in Home Assistant and many people aren’t quite sure what exactly you can do with it. In this tutorial, I’ll teach you how to use event triggers to control Home Assistant. We’ll create an automation that allows you to control the Home Assistant media player using event triggers with a physical remote control. Let’s do this!

⭐⭐⭐ NOTE: ⭐⭐⭐

This article accompanies a YouTube video. I wrote it for people who would rather read than watch a video. To keep doing this, I would like to ask you to check out the video, leave a comment under the video, give the video a thumbs up, and subscribe to my YouTube channel. This means that the video is offered more often to new visitors so that they also stay informed of the latest Home Assistant tutorials.

Thank you for your support!


Click here to watch the video


Before we start building the automation, I want to briefly explain what Events actually are. The heart of Home Assistant revolves around an event bus. All integrations can either fire events through this event bus or listen to it. So, Home Assistant continuously monitors this event bus, and when an event occurs on the event bus, integrations listening to that event can immediately take action. As a simple example, imagine a button and a lamp. As soon as you press the button, the lamp should turn on. For this, you would normally create an automation triggered by pressing the button. This automation essentially waits until the button is pressed. In many cases, you would choose to use a state trigger that checks whether the button goes from off to on. However, in reality, you are triggering on an event without being aware of it.

Identifying Events

How do you now identify an event and its corresponding event data? You can do this, for example, in the Developer Tools. Go to the Events tab and enter “state_changed” as the event_type under Listen To Events. Then click on Start Listening, and you will see all events passing by from entities where the state has changed. You will see an entity_id, an old_state, and a new_state there. On the right-hand side, you will see all types of event listeners that you can try out.

If you want to use an event trigger, you can trigger based on the event, filter conditions based on the specific new_state, and then execute an action. See this example where I activate a scene based on pressing the right button of my Tradfri remote control.

When I listen in the developer tools for state_changed and then click on the right button on my remote control, I can see exactly which event_data I need in my automation. It may take a bit of searching among all the events because events are continuously triggered, but based on the entity_id, you can identify the correct event.

You can see that the entity_id is sensor.tradfri_remote_control_action. Further down, you can see that within new_state, the state arrow_right_click is activated. If we convert this into an automation, it looks like this:

First, I created an event trigger that triggers on the entity_id sensor.tradfri_remote_control_action. Then, in the “And If” section, I filter on the new_state. You can see that I follow the hierarchy of the data I received in the listener in the value_template. So, trigger.event.data.new_state.state == ‘arrow_right_click’. In the “Then Do” section, I activate a scene.

If you can use a state trigger, then the use of an event trigger is often not necessary, but in some cases, an event trigger is needed. And I’ll show you that in the next automation where we’ll use a Logitech Harmony remote control to control the media player of Home Assistant.

To read the buttons of the Logitech Harmony remote control in Home Assistant, we need the Emulated Roku integration.

Install Emulated Roku
  • Go to Settings > Devices & Services.
  • Click on Add Integration.
  • Search for Emulated Roku and click on Emulated Roku.
  • Enter the server name you want to use and specify a port that you haven’t used yet. By default, this is 8060.
  • Click Submit.

Emulated Roku is now installed. You can open your Logitech Harmony app and search for new devices on your network. If everything is set up correctly, you should see the device named Roku 4. You can now select this device if you want to control Home Assistant. Emulated Roku doesn’t support all buttons, but it does support a large number, as you can see on this page.

If you go to the Developer Tools and then to the events tab, you can enter “roku_command” under Listen To Events. For example, if I click on the play button on the remote control, I see data such as source name: Home Assistant, type: keypress, and key: Play. We will use this data in the automation we are going to create to control Home Assistant using the remote control.

I need your help!

You will be doing me a huge favor if you subscribe to my channel if you haven’t already. And, you help me a lot if you also give this video a thumbs up and leave a comment. This way, YouTube will present this video to new people and that will make the channel grow! In the description of the video, you will also find information about how you can sponsor me so that I can continue to make these tutorials for you.

Thank you!

Developing the automation to control Home Assistant with a remote control.
  • Go to Settings > Automations & Scenes.
  • Click Create Automation.
  • Click Create New Automation.
  • Click Add Trigger.
  • Type Event and click Manual Event.
  • In the event_type field, enter roku_command.
  • Enter the following lines in the event_data field:
source_name: Home Assistant
type: keypress
key: Play
  • Now give this trigger a Trigger ID.
  • Go to the three dots in the upper right corner and click Edit ID.
  • Enter an ID name, for instance: Play.
  • You can even limit the event trigger to one user if you want, but I’m not doing that.

Repeat this procedure for all the buttons you want to use. Eventually, you’ll have a complete list of event triggers with their corresponding trigger IDs. By the way, did you know that you can assign the same Trigger ID to multiple events? For example, I gave the Forward and Right events the same trigger ID so that they will both perform the same action later.

Now, let’s move to the Then Do section.

  • Click Add Building Block and then click Choose.
  • Open Option 1 and click Add Condition.
  • Search for Trigger and select Triggered By.
  • Select the Trigger ID Play.
  • Under Actions, click Add Action.
  • Search for media and select Media Player: Play/Pause.
  • Click Choose Entity and select the media player of your choice.
  • Now click Add Option again for the Forward event.
  • Click Add Condition.
  • Search for Trigger and select Triggered By.
  • Select the Trigger ID Fwd.
  • Under Actions, click Add Action.
  • Search for media and select Media Player: Next.
  • Click Choose Entity and select the media player of your choice.
  • Continue to add options for all the Trigger IDs that you defined.
  • Click Save after you’ve finished adding options.
  • Give your Automation a meaningful name.

Your automation is now ready, and if all is well, you should be able to control the Home Assistant Media Player with your Logitech Harmony remote control. Let’s test it out!

If you find it too much work to create the automation yourself, you can also download the Blueprint I created here for the price of a cup of coffee. With that, you’ll have the remote control working in just a few minutes, and you’ll also help ensure that I can continue doing this work and keep this channel alive.

I’ve shown you how to control the media player in Home Assistant, but now you can also use your remote control to skip through scenes or control other devices through Home Assistant. I assume you can figure this out further based on the information I’ve given you in this video.

Thanks for watching. If my work saves you time and you want to see more tutorials from me, consider sponsoring me monthly like these people do. Without your help, I can’t continue making these tutorials. You can find the links to Patreon, Ko-Fi, and how to join my channel in the description of this video. This channel is my work, but unfortunately, YouTube’s ad revenue is not enough to sustain this work, so your help is greatly appreciated!

And don’t forget to give this video a thumbs up and subscribe to my channel if you haven’t already. I’ll see you soon in my next video!

Bye bye!

#HomeAssistant #SmartHome #Automation #EventTriggers #RemoteControl #IoT #HomeAutomation #Tech #DIY #SmartHouse #InternetOfThings #SmarthomeAutomation #HomeTech #SmartLiving #ConnectedHome #HomeSecurity #SmartDevices #SmartTechnology #TechTips #HomeAutomationSystem


Back to all articles