From 50a1de9f73fd724e19a81e5b62fbb3c8febc79f2 Mon Sep 17 00:00:00 2001 From: Tomasz Wieczorek Date: Mon, 29 Aug 2022 00:02:27 +0200 Subject: [PATCH] Add set default for domain for scaffold script (#76628) * Add set default for domain for scaffold script * Add default domain for config_flow_discovery integration * Extend comment explaining usage --- .../scaffold/templates/config_flow/integration/__init__.py | 6 +++++- .../templates/config_flow_discovery/integration/__init__.py | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/script/scaffold/templates/config_flow/integration/__init__.py b/script/scaffold/templates/config_flow/integration/__init__.py index dc92ecc1d15..704292a2e9b 100644 --- a/script/scaffold/templates/config_flow/integration/__init__.py +++ b/script/scaffold/templates/config_flow/integration/__init__.py @@ -14,7 +14,11 @@ PLATFORMS: list[Platform] = [Platform.LIGHT] async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: """Set up NEW_NAME from a config entry.""" - # TODO Store an API object for your platforms to access + + hass.data.setdefault(DOMAIN, {}) + # TODO 1. Create API instance + # TODO 2. Validate the API connection (and authentication) + # TODO 3. Store an API object for your platforms to access # hass.data[DOMAIN][entry.entry_id] = MyApi(...) hass.config_entries.async_setup_platforms(entry, PLATFORMS) diff --git a/script/scaffold/templates/config_flow_discovery/integration/__init__.py b/script/scaffold/templates/config_flow_discovery/integration/__init__.py index d7fb1e56eef..73b4bebf9f5 100644 --- a/script/scaffold/templates/config_flow_discovery/integration/__init__.py +++ b/script/scaffold/templates/config_flow_discovery/integration/__init__.py @@ -14,7 +14,11 @@ PLATFORMS: list[Platform] = [Platform.BINARY_SENSOR] async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: """Set up NEW_NAME from a config entry.""" - # TODO Store an API object for your platforms to access + + hass.data.setdefault(DOMAIN, {}) + # TODO 1. Create API instance + # TODO 2. Validate the API connection (and authentication) + # TODO 3. Store an API object for your platforms to access # hass.data[DOMAIN][entry.entry_id] = MyApi(...) hass.config_entries.async_setup_platforms(entry, PLATFORMS)