{"id":4495,"date":"2025-07-16T11:06:19","date_gmt":"2025-07-16T11:06:19","guid":{"rendered":"https:\/\/www.creatingsmarthome.com\/?p=4495"},"modified":"2025-07-19T15:33:26","modified_gmt":"2025-07-19T15:33:26","slug":"home-assistant-never-miss-an-f1-race-start-again","status":"publish","type":"post","link":"https:\/\/www.creatingsmarthome.com\/index.php\/2025\/07\/16\/home-assistant-never-miss-an-f1-race-start-again\/","title":{"rendered":"Home Assistant: Never Miss an F1 Race Start Again"},"content":{"rendered":"\n<p>As an avid Formula 1 fan, I watch nearly every race. However, I&#8217;ve lost count of the times I&#8217;ve been engrossed in coding or tinkering with my home automation setup, only to miss the race start. I wondered: could I use Home Assistant to solve this?<\/p>\n\n\n\n<p>The answer is a resounding yes. While sending a simple race-time notification is easy enough with an F1 integration, I wanted to take it a step further. My goal was to create an actionable notification that, with a single tap, would turn on my TV and start the F1 live stream directly.<\/p>\n\n\n\n<div class=\"wp-block-media-text has-media-on-the-right is-stacked-on-mobile\"><div class=\"wp-block-media-text__content\">\n<p>This guide will walk you through the integrations and automations required to make this happen.<\/p>\n<\/div><figure class=\"wp-block-media-text__media\"><img loading=\"lazy\" decoding=\"async\" width=\"1008\" height=\"388\" src=\"https:\/\/www.creatingsmarthome.com\/wp-content\/uploads\/2025\/07\/Screenshot_20250716-123008.png\" alt=\"\" class=\"wp-image-4516 size-full\" srcset=\"https:\/\/www.creatingsmarthome.com\/wp-content\/uploads\/2025\/07\/Screenshot_20250716-123008.png 1008w, https:\/\/www.creatingsmarthome.com\/wp-content\/uploads\/2025\/07\/Screenshot_20250716-123008-300x115.png 300w, https:\/\/www.creatingsmarthome.com\/wp-content\/uploads\/2025\/07\/Screenshot_20250716-123008-768x296.png 768w\" sizes=\"auto, (max-width: 1008px) 100vw, 1008px\" \/><\/figure><\/div>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">The Setup<\/h2>\n\n\n\n<p>Here&#8217;s the environment I&#8217;m using for this project:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Home Assistant<\/li>\n\n\n\n<li>Home Assistant Companion app for Android<\/li>\n\n\n\n<li>An Android TV device (NVIDIA Shield in my case)<\/li>\n\n\n\n<li>A subscription to F1 TV Pro<\/li>\n\n\n\n<li>The F1 TV app installed on the Android TV<\/li>\n<\/ul>\n\n\n\n<p>You can likely adapt these steps to your own setup with a few tweaks.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Step 1: F1 Integration<\/h2>\n\n\n\n<p>The&nbsp;<strong><a href=\"https:\/\/github.com\/Nicxe\/f1_sensor\">F1 Sensor<\/a><\/strong>&nbsp;is an unofficial integration, available for installation through <a href=\"https:\/\/hacs.xyz\">HACS<\/a>. It offers a wealth of F1-related data, from the race calendar to championship standings. For this particular automation, we only need the race calendar data, but feel free to explore its other features once you&#8217;re set up.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Step 2: Android TV Debug Bridge Integration<\/h2>\n\n\n\n<p>To launch the F1 TV app on our Android TV from Home Assistant, we need the&nbsp;<strong><a href=\"https:\/\/www.home-assistant.io\/integrations\/androidtv\/\">Android TV Debug Bridge (ADB)<\/a><\/strong> integration. This powerful tool allows us to send remote commands, like launching apps, directly to the Android system. Since it&#8217;s an official Home Assistant integration, you won&#8217;t need HACS.<\/p>\n\n\n\n<p>Follow the official&nbsp;<a target=\"_blank\" rel=\"noreferrer noopener\" href=\"https:\/\/www.home-assistant.io\/integrations\/androidtv\/\">ADB integration setup guide<\/a>&nbsp;to ensure a smooth installation.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Step 3: Create an ADB Script to Start the F1 TV Live Stream<\/h3>\n\n\n\n<p>To simplify our final automation, we&#8217;ll first create a helper script that starts the F1 TV app and navigates to the live stream. There&#8217;s a small catch: the F1 TV app for Android TV doesn&#8217;t support launching directly into the live stream via an intent. To work around this, we have to simulate a sequence of remote control button presses.<\/p>\n\n\n\n<p>While this method works, it&#8217;s not ideal and can sometimes fail if the app is in an unexpected state. Hopefully, a future update to the F1 TV app will allow for direct deep-linking.<\/p>\n\n\n\n<p>The script below performs the following actions:<\/p>\n\n\n\n<ol start=\"1\" class=\"wp-block-list\">\n<li><strong>Starts<\/strong>&nbsp;the F1 TV app.<\/li>\n\n\n\n<li><strong>Waits<\/strong>&nbsp;for 1 second.<\/li>\n\n\n\n<li><strong>Sends<\/strong>&nbsp;a &#8216;wakeup&#8217; command to ensure the screen is on.<\/li>\n\n\n\n<li><strong>Waits<\/strong>&nbsp;for 5 seconds to give the app time to load.<\/li>\n\n\n\n<li><strong>Simulates<\/strong>&nbsp;a &#8216;D-Pad Center&#8217; press to select the featured live event (which should be the upcoming race\/qualifying\/sprint).<\/li>\n\n\n\n<li><strong>Waits<\/strong>&nbsp;for 1 second.<\/li>\n\n\n\n<li><strong>Simulates<\/strong>&nbsp;a second &#8216;D-Pad Center&#8217; press to select the &#8216;Watch Live&#8217; option.<\/li>\n<\/ol>\n\n\n\n<p>Add the following script to your&nbsp;<code>scripts.yaml<\/code>&nbsp;or create it via the UI.&nbsp;<strong>Remember to change the&nbsp;<code>entity_id<\/code>&nbsp;to match your own Android TV media player entity!<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>play_f1_tv_on_shield:\n  alias: 'Starts and plays F1 TV on Shield TV'\n  sequence:\n    - service: androidtv.adb_command\n      data:\n        command: am start -a android.intent.action.VIEW -d -n com.formulaone.production\/com.avs.f1.ui.splash.SplashActivity\n        entity_id: media_player.android_tv_192_168_1_175\n    - delay: 1\n    - service: androidtv.adb_command\n      data:\n        command: adb shell input keyevent KEYCODE_WAKEUP\n        entity_id: media_player.android_tv_192_168_1_175\n    - delay: 5\n    - service: androidtv.adb_command\n      data:\n        command: adb shell input keyevent DPAD_CENTER\n        entity_id: media_player.android_tv_192_168_1_175\n    - delay: 1\n    - service: androidtv.adb_command\n      data:\n        command: adb shell input keyevent DPAD_CENTER\n        entity_id: media_player.android_tv_192_168_1_175\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Step 4: The Notification Automation<\/h2>\n\n\n\n<p>Our notification system has two main components: Template Sensors to calculate when to send the alert, and the Automation itself, which builds and sends the actionable notification.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Template sensors<\/h3>\n\n\n\n<p>These sensors are straightforward. For each event (race, qualifying, and sprint), we take the official start time from the&nbsp;<code>sensor.f1_next_race<\/code>, convert it to our local timezone, and then subtract 10 minutes. This gives us the exact time to trigger our notification. If you also want alerts for practice sessions, simply create additional sensors following the same pattern.<\/p>\n\n\n\n<p>Add the following to your&nbsp;<code>configuration.yaml<\/code>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sensor:\n  - platform: template\n    sensors:\n      formula_one_race_start_notification:\n        friendly_name: 'Formula One race start notification'\n        device_class: timestamp\n        value_template: &gt;-\n          {{ (states('sensor.f1_next_race') | as_datetime |&nbsp;as_local) - timedelta(minutes = 10 | int ) }}\n      formula_one_qualifying_start_notification:\n        friendly_name: 'Formula One qualifying start notification'\n        device_class: timestamp\n        value_template: &gt;-\n          {{ (state_attr('sensor.f1_next_race', 'qualifying_start') | as_datetime |&nbsp;as_local) - timedelta(minutes = 10 | int ) }}\n      formula_one_sprint_start_notification:\n        friendly_name: 'Formula One sprint start notification'\n        device_class: timestamp\n        value_template: &gt;-\n          {%- if state_attr('sensor.f1_next_race', 'sprint_start') != None %}\n            {{ (state_attr('sensor.f1_next_race', 'sprint_start') | as_datetime |&nbsp;as_local) - timedelta(minutes = 10 | int ) }}\n          {%- else %}\n            None\n          {%- endif %}<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Automation<\/h3>\n\n\n\n<p>This is the core of the project. The automation is triggered by one of our template sensors. It sends an actionable notification to my phone with a dynamic message indicating which session is about to start (e.g., &#8220;F1 race is about to start&#8221;). The notification has two buttons: &#8216;Play on TV&#8217;, which runs our ADB script, and &#8216;Ignore&#8217;, which dismisses the alert. We use&nbsp;<code>trigger_id<\/code>&nbsp;to make the notification message context-aware.<\/p>\n\n\n\n<p><strong>Note:<\/strong>&nbsp;You must change the&nbsp;<code>service: notify.mobile_app_pixel_9_pro_xl<\/code>&nbsp;line to your own mobile device&#8217;s notification service.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>automation:\n  id: 'notify_f1_start'\n  alias: 'Media: Notify F1 race start'\n  trigger:\n  - platform: time\n    at: sensor.formula_one_qualifying_start_notification\n    id: qualifying\n  - platform: time\n    at: sensor.formula_one_sprint_start_notification\n    id: sprint\n  - platform: time\n    at: sensor.formula_one_race_start_notification\n    id: race\n  action:\n    - alias: Set up variables for the actions\n      variables:\n        action_play_f1: \"{{ 'PLAY_F1_' ~ context.id }}\"\n        action_no: \"{{ 'NO_' ~ context.id }}\"\n    - alias: Notify Mobile\n      service: notify.mobile_app_pixel_9_pro_xl\n      data:\n        message: F1 {{ trigger.id }} is about to start. Do you want to play it on TV?\n        data:\n          importance: high\n          actions:\n            - action: \"{{ action_play_f1 }}\"\n              title: Play on TV\n            - action: \"{{ action_no }}\"\n              title: Ignore\n    - alias: Wait for a response\n      timeout:\n        minutes: 10\n      continue_on_timeout: false\n      wait_for_trigger:\n        - platform: event\n          event_type: mobile_app_notification_action\n          event_data:\n            action: \"{{ action_play_f1 }}\"\n    - alias: Perform the action\n      choose:\n        - conditions: \"{{ wait.trigger.event.data.action == action_no }}\"\n          sequence: &#91;]\n        - conditions: \"{{ wait.trigger.event.data.action == action_play_f1 }}\"\n          sequence:\n            - service: script.play_f1_tv_on_shield\n              data: {}\n  mode: single\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">BONUS: F1 Card<\/h2>\n\n\n\n<p>If you&#8217;re looking for a quick view of the upcoming F1 race inside Home Assistant, check out the&nbsp;<strong><a href=\"https:\/\/github.com\/marcokreeft87\/formulaone-card\">F1 Card<\/a><\/strong>. This is a great-looking custom Lovelace card that provides information on the next race, driver and team standings, and the full season schedule.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"550\" src=\"https:\/\/www.creatingsmarthome.com\/wp-content\/uploads\/2025\/07\/Screenshot-2025-07-16-at-13.56.37-1024x550.png\" alt=\"\" class=\"wp-image-4518\" srcset=\"https:\/\/www.creatingsmarthome.com\/wp-content\/uploads\/2025\/07\/Screenshot-2025-07-16-at-13.56.37-1024x550.png 1024w, https:\/\/www.creatingsmarthome.com\/wp-content\/uploads\/2025\/07\/Screenshot-2025-07-16-at-13.56.37-300x161.png 300w, https:\/\/www.creatingsmarthome.com\/wp-content\/uploads\/2025\/07\/Screenshot-2025-07-16-at-13.56.37-768x412.png 768w, https:\/\/www.creatingsmarthome.com\/wp-content\/uploads\/2025\/07\/Screenshot-2025-07-16-at-13.56.37-1536x824.png 1536w, https:\/\/www.creatingsmarthome.com\/wp-content\/uploads\/2025\/07\/Screenshot-2025-07-16-at-13.56.37-2048x1099.png 2048w, https:\/\/www.creatingsmarthome.com\/wp-content\/uploads\/2025\/07\/Screenshot-2025-07-16-at-13.56.37-1920x1031.png 1920w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Further Enhancements<\/h2>\n\n\n\n<p>I&#8217;m already thinking and creating future improvements to take this project even further:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Voice Notifications:<\/strong>&nbsp;Announce the alert through my smart speakers if I&#8217;m at home.<\/li>\n\n\n\n<li><strong>Voice Activation:<\/strong>&nbsp;Start the F1 stream with a voice command or by responding to the voice notification.<\/li>\n\n\n\n<li><strong>AI-Enriched Notifications:<\/strong>\u00a0Use AI to add more context or fun facts to the notification text.  (example below)<\/li>\n<\/ul>\n\n\n\n<p>Here&#8217;s an my prompt of AI generated content for the automation, just use the generated_content[&#8216;text&#8217;] as the push notification message. At least I&#8217;m the outcome \ud83d\ude42<\/p>\n\n\n\n<div class=\"wp-block-media-text has-media-on-the-right is-stacked-on-mobile\" style=\"grid-template-columns:auto 37%\"><div class=\"wp-block-media-text__content\">\n<pre class=\"wp-block-code\"><code>  - action: google_generative_ai_conversation.generate_content\n    data:\n      prompt: >\n        You are F1 advertiser. {{ trigger.id }} is starting in 10 minutes. Make\n        a message to fit in a push notification. Here is the data for the next\n        race: {{ states.sensor.f1_next_race.attributes }}\n    response_variable: generated_content<\/code><\/pre>\n<\/div><figure class=\"wp-block-media-text__media\"><img loading=\"lazy\" decoding=\"async\" width=\"1008\" height=\"412\" src=\"https:\/\/www.creatingsmarthome.com\/wp-content\/uploads\/2025\/07\/Screenshot_20250719-105321.png\" alt=\"\" class=\"wp-image-4533 size-full\" srcset=\"https:\/\/www.creatingsmarthome.com\/wp-content\/uploads\/2025\/07\/Screenshot_20250719-105321.png 1008w, https:\/\/www.creatingsmarthome.com\/wp-content\/uploads\/2025\/07\/Screenshot_20250719-105321-300x123.png 300w, https:\/\/www.creatingsmarthome.com\/wp-content\/uploads\/2025\/07\/Screenshot_20250719-105321-768x314.png 768w\" sizes=\"auto, (max-width: 1008px) 100vw, 1008px\" \/><\/figure><\/div>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>As an avid Formula 1 fan, I watch nearly every race. However, I&#8217;ve lost count of the times I&#8217;ve been engrossed in coding or tinkering&hellip;<\/p>\n","protected":false},"author":1,"featured_media":4517,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[100,2],"tags":[441,442,105,438,443,440,444,439,7,225],"class_list":["post-4495","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-home-assistant","category-inspiration","tag-adb","tag-android-tv","tag-automation","tag-f1","tag-f1-app","tag-f1-card","tag-f1-tv","tag-formula-1","tag-home-assistant","tag-notification","has-post-thumbnail-archive"],"acf":[],"featured_image_src":"https:\/\/www.creatingsmarthome.com\/wp-content\/uploads\/2025\/07\/f1-homeassistant.jpg","author_info":{"display_name":"Toni","author_link":"https:\/\/www.creatingsmarthome.com\/index.php\/author\/topsy\/"},"_links":{"self":[{"href":"https:\/\/www.creatingsmarthome.com\/index.php\/wp-json\/wp\/v2\/posts\/4495","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.creatingsmarthome.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.creatingsmarthome.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.creatingsmarthome.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.creatingsmarthome.com\/index.php\/wp-json\/wp\/v2\/comments?post=4495"}],"version-history":[{"count":26,"href":"https:\/\/www.creatingsmarthome.com\/index.php\/wp-json\/wp\/v2\/posts\/4495\/revisions"}],"predecessor-version":[{"id":4534,"href":"https:\/\/www.creatingsmarthome.com\/index.php\/wp-json\/wp\/v2\/posts\/4495\/revisions\/4534"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.creatingsmarthome.com\/index.php\/wp-json\/wp\/v2\/media\/4517"}],"wp:attachment":[{"href":"https:\/\/www.creatingsmarthome.com\/index.php\/wp-json\/wp\/v2\/media?parent=4495"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.creatingsmarthome.com\/index.php\/wp-json\/wp\/v2\/categories?post=4495"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.creatingsmarthome.com\/index.php\/wp-json\/wp\/v2\/tags?post=4495"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}