{"id":3505,"date":"2023-12-26T09:14:56","date_gmt":"2023-12-26T15:14:56","guid":{"rendered":"https:\/\/promincproductions.com\/blog\/?p=3505"},"modified":"2023-12-26T09:21:47","modified_gmt":"2023-12-26T15:21:47","slug":"home-assistant-integration-failed-setup-will-retry","status":"publish","type":"post","link":"https:\/\/promincproductions.com\/blog\/home-assistant-integration-failed-setup-will-retry\/","title":{"rendered":"Home Assistant Integration &#8220;Failed setup, will retry&#8221;"},"content":{"rendered":"<p>Have you ever seen the <code>Failed setup, will retry<\/code> message in a Home Assistant integration?  This message can show at times on a cloud based integration where Home Assistant is no longer communicating with the remote cloud service.  The technical reason is that the token is no longer valid for one reason or another and thus the connection is failing.  What causes this?  That&#8217;s a mystery for another day &#8211; this post is focused on just getting past it for now.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img decoding=\"async\" width=\"600\" height=\"600\" src=\"https:\/\/promincproductions.com\/blog\/wp-content\/uploads\/2023\/12\/home-assistant-integration-failed-setup.png\" alt=\"How to fix the failed setup message on an integration in Home Assistant\" class=\"wp-image-3515\" title=\"How to fix the failed setup message on an integration in Home Assistant\" srcset=\"https:\/\/promincproductions.com\/blog\/wp-content\/uploads\/2023\/12\/home-assistant-integration-failed-setup.png 600w, https:\/\/promincproductions.com\/blog\/wp-content\/uploads\/2023\/12\/home-assistant-integration-failed-setup-500x500.png 500w, https:\/\/promincproductions.com\/blog\/wp-content\/uploads\/2023\/12\/home-assistant-integration-failed-setup-150x150.png 150w, https:\/\/promincproductions.com\/blog\/wp-content\/uploads\/2023\/12\/home-assistant-integration-failed-setup-450x450.png 450w\" sizes=\"(max-width: 600px) 100vw, 600px\" \/><\/figure>\n<\/div>\n\n\n<p>To solve this issue you&#8217;ll need a method to edit the files of Home Assistant &#8211; well just one file really.  Typically SSH access or FTP access to the server is needed for this.<\/p>\n\n\n\n<div class=\"wp-block-columns is-layout-flex wp-container-core-columns-is-layout-9d6595d7 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<p>In my case, the <a href=\"https:\/\/www.home-assistant.io\/integrations\/geocaching\/\" target=\"_blank\" rel=\"noopener\" data-lasso-id=\"970\">Geocaching integration<\/a> was failing.  Once upon a time this was working, but then failed for <em>a long time<\/em>.  I got sick of seeing the red box today and wanted to solve.<\/p>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\"><div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img decoding=\"async\" width=\"392\" height=\"164\" src=\"https:\/\/promincproductions.com\/blog\/wp-content\/uploads\/2023\/12\/image-1.png\" alt=\"Failed setup message in Home Assistant integration grid page\" class=\"wp-image-3508\" title=\"Failed setup message in Home Assistant integration grid page\" srcset=\"https:\/\/promincproductions.com\/blog\/wp-content\/uploads\/2023\/12\/image-1.png 392w, https:\/\/promincproductions.com\/blog\/wp-content\/uploads\/2023\/12\/image-1-150x63.png 150w\" sizes=\"(max-width: 392px) 100vw, 392px\" \/><\/figure>\n<\/div><\/div>\n<\/div>\n\n\n\n<h2 class=\"wp-block-heading\">How to Repair the Failed Authentication<\/h2>\n\n\n\n<p>To fix a failed integration connection, the bad authentication credentials first needs to be removed.  Then a restart of Home Assistant and it will be ready to re-configure the connection.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Backup Configuration<\/h3>\n\n\n\n<p>It&#8217;s a wise idea to first backup the current configuration file in case something unexpected occurs.  To do so, simply make a copy of the file by downloading it via FTP to your local machine or making a copy via SSH.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>## replace &#091;YYYYMMDD] with the current date\ncp .\/.storage\/core.config_entries .\/.storage\/core.config_entries.bak.&#091;YYYYMMDD]<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Remove the Broken Cloud Service Connection<\/h3>\n\n\n\n<p>Open the <code>.storage\/core.config_entries<\/code> file in an editor like Nano or Vim and look for the entry that has the failed connection.  In the <strong><a href=\"#how-to-find-the-configuration\">How to Find the Configuration<\/a><\/strong> section below the line number is found.  The entry starts with an opening curly brace (<code>{<\/code>) and ends with a closing curly brace (<code>}<\/code>) &#8211; it may or may not have a trailing comma.<\/p>\n\n\n\n<p>Example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>      {\n        \"entry_id\": \"456...\",\n        \"version\": 1,\n        \"domain\": \"geocaching\",\n        \"title\": \"PromInc\",\n        \"data\": {\n          \"auth_implementation\": \"cloud\",\n          \"token\": {\n            \"access_token\": \"eyJhbGciOi...\",\n            \"token_type\": \"bearer\",\n            \"expires_in\": 3599,\n            \"refresh_token\": \"8f7...\",\n            \"service\": \"geocaching\",\n            \"expires_at\": 1690974608.435786\n          }\n        },\n        \"options\": {},\n        \"pref_disable_new_entities\": false,\n        \"pref_disable_polling\": false,\n        \"source\": \"user\",\n        \"unique_id\": \"prominc\",\n        \"disabled_by\": null\n      },<\/code><\/pre>\n\n\n\n<p>Remove\/delete this entire block and save the <code>.storage\/core.config_entries<\/code> file.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Restart Home Assistant<\/h3>\n\n\n\n<p>In Home Assistant, go to the <strong>Settings<\/strong> page.  Then click the three dots menu icon in the top right and choose <strong>Restart Home Assistant<\/strong>.  Then choose the <strong>Restart Home Assistant<\/strong> option and click the <strong>Restart<\/strong> button.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Reconfigure Cloud Integration Credentials<\/h3>\n\n\n\n<p>Now that the bad cloud integration credentials have been cleared, it&#8217;s possible to reconfigure the service.  Go to <strong>Settings -&gt; Devices &amp; services<\/strong> and find the failed integration.  The integration was removed and thus clicking the <strong>+ Add Integration<\/strong> button is needed.  Search for the integration and go through the cloud integration steps.  Once complete, the integration should be working as expected once again!<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><img decoding=\"async\" width=\"1024\" height=\"414\" src=\"https:\/\/promincproductions.com\/blog\/wp-content\/uploads\/2023\/12\/image-2-1024x414.png\" alt=\"Cloud integration is reconfigured and working as expected\" class=\"wp-image-3511\" title=\"Cloud integration is reconfigured and working as expected\" srcset=\"https:\/\/promincproductions.com\/blog\/wp-content\/uploads\/2023\/12\/image-2-1024x414.png 1024w, https:\/\/promincproductions.com\/blog\/wp-content\/uploads\/2023\/12\/image-2-500x202.png 500w, https:\/\/promincproductions.com\/blog\/wp-content\/uploads\/2023\/12\/image-2-768x311.png 768w, https:\/\/promincproductions.com\/blog\/wp-content\/uploads\/2023\/12\/image-2-150x61.png 150w, https:\/\/promincproductions.com\/blog\/wp-content\/uploads\/2023\/12\/image-2-600x243.png 600w, https:\/\/promincproductions.com\/blog\/wp-content\/uploads\/2023\/12\/image-2-450x182.png 450w, https:\/\/promincproductions.com\/blog\/wp-content\/uploads\/2023\/12\/image-2-1360x550.png 1360w, https:\/\/promincproductions.com\/blog\/wp-content\/uploads\/2023\/12\/image-2.png 1423w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n<\/div>\n\n\n<p>When I saw that the integration was removed I got a bit nervous that my dashboards and other usages of this integration would have required attention to reconfigure them.  Thankfully that wasn&#8217;t the case &#8211; likely because it was still configured in <code>.storage\/core.device_registry<\/code> and thus the device and entity IDs did not change.<\/p>\n\n\n\n<p>Here you can see that a dashboard this integration was added to still works after this authentication update.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img decoding=\"async\" width=\"530\" height=\"270\" src=\"https:\/\/promincproductions.com\/blog\/wp-content\/uploads\/2023\/12\/image-3.png\" alt=\"Integration still working as expected in lovelace dashboard after reconfiguring authentication\" class=\"wp-image-3513\" title=\"Integration still working as expected in lovelace dashboard after reconfiguring authentication\" srcset=\"https:\/\/promincproductions.com\/blog\/wp-content\/uploads\/2023\/12\/image-3.png 530w, https:\/\/promincproductions.com\/blog\/wp-content\/uploads\/2023\/12\/image-3-500x255.png 500w, https:\/\/promincproductions.com\/blog\/wp-content\/uploads\/2023\/12\/image-3-150x76.png 150w, https:\/\/promincproductions.com\/blog\/wp-content\/uploads\/2023\/12\/image-3-450x229.png 450w\" sizes=\"(max-width: 530px) 100vw, 530px\" \/><\/figure>\n<\/div>\n\n\n<p> <\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"how-to-find-the-configuration\">How to Find the Configuration<\/h2>\n\n\n\n<p>If using a Linux based system, <code>grep<\/code> is a tool available to search the files of the system.  If you&#8217;ve never used it, it&#8217;s worth learning &#8211; a great search tool!<\/p>\n\n\n\n<p>In Home Assistant I clicked into the integration and saw that the account name is set to <strong>PromInc<\/strong>.  That&#8217;s the clue of what I need to search for using <code>grep<\/code>.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><img decoding=\"async\" width=\"1024\" height=\"451\" src=\"https:\/\/promincproductions.com\/blog\/wp-content\/uploads\/2023\/12\/image-1024x451.png\" alt=\"Finding the failed integration name in Home Assistant\" class=\"wp-image-3509\" title=\"Finding the failed integration name in Home Assistant\" srcset=\"https:\/\/promincproductions.com\/blog\/wp-content\/uploads\/2023\/12\/image-1024x451.png 1024w, https:\/\/promincproductions.com\/blog\/wp-content\/uploads\/2023\/12\/image-500x220.png 500w, https:\/\/promincproductions.com\/blog\/wp-content\/uploads\/2023\/12\/image-768x338.png 768w, https:\/\/promincproductions.com\/blog\/wp-content\/uploads\/2023\/12\/image-150x66.png 150w, https:\/\/promincproductions.com\/blog\/wp-content\/uploads\/2023\/12\/image-600x264.png 600w, https:\/\/promincproductions.com\/blog\/wp-content\/uploads\/2023\/12\/image-450x198.png 450w, https:\/\/promincproductions.com\/blog\/wp-content\/uploads\/2023\/12\/image-1360x600.png 1360w, https:\/\/promincproductions.com\/blog\/wp-content\/uploads\/2023\/12\/image.png 1447w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n<\/div>\n\n\n<pre class=\"wp-block-code\"><code>grep -rn PromInc .\/<\/code><\/pre>\n\n\n\n<p>This returned many results, but a quick scan indicated 2 possible areas in the configuration that would contain the source of the issue.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>.\/.storage\/core.config_entries:796:        \"title\": \"PromInc\",\r\n.\/.storage\/core.device_registry:1527:        \"name\": \"Geocaching PromInc\",\r<\/code><\/pre>\n\n\n\n<p>The second file <code>core.device_registry<\/code> is used to define what devices are added to your Home Assistant instance.  [<a href=\"https:\/\/developers.home-assistant.io\/docs\/device_registry_index\/\" target=\"_blank\" rel=\"noopener\" data-lasso-id=\"971\">reference<\/a>]<\/p>\n\n\n\n<p>But the first file <code>core.config_entries<\/code> indicates in the name that we are on the right path &#8211; a file that handles the configuration!!! [<a href=\"https:\/\/developers.home-assistant.io\/docs\/config_entries_index\/\" target=\"_blank\" rel=\"noopener\" data-lasso-id=\"972\">reference<\/a>]<\/p>\n\n\n\n<p>With the power of <code>grep<\/code> paired with a bit of mental deduction we were able to find the file to edit quickly and easily!<\/p>","protected":false},"excerpt":{"rendered":"<p>Have you ever seen the Failed setup, will retry message in a Home Assistant integration? This message can [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":3515,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"wprm-recipe-roundup-name":"","wprm-recipe-roundup-description":"","_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_post_was_ever_published":false},"categories":[387,332],"tags":[331],"class_list":["post-3505","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-home-assistant","category-smart-home","tag-home-assistant"],"jetpack_featured_media_url":"https:\/\/promincproductions.com\/blog\/wp-content\/uploads\/2023\/12\/home-assistant-integration-failed-setup.png","jetpack_shortlink":"https:\/\/wp.me\/p4BbcR-Ux","jetpack_sharing_enabled":true,"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/promincproductions.com\/blog\/wp-json\/wp\/v2\/posts\/3505","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/promincproductions.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/promincproductions.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/promincproductions.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/promincproductions.com\/blog\/wp-json\/wp\/v2\/comments?post=3505"}],"version-history":[{"count":4,"href":"https:\/\/promincproductions.com\/blog\/wp-json\/wp\/v2\/posts\/3505\/revisions"}],"predecessor-version":[{"id":3516,"href":"https:\/\/promincproductions.com\/blog\/wp-json\/wp\/v2\/posts\/3505\/revisions\/3516"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/promincproductions.com\/blog\/wp-json\/wp\/v2\/media\/3515"}],"wp:attachment":[{"href":"https:\/\/promincproductions.com\/blog\/wp-json\/wp\/v2\/media?parent=3505"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/promincproductions.com\/blog\/wp-json\/wp\/v2\/categories?post=3505"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/promincproductions.com\/blog\/wp-json\/wp\/v2\/tags?post=3505"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}