From d156150ef0c100cb4d30e4fbe5b1c45fad7115b0 Mon Sep 17 00:00:00 2001 From: ludeeus Date: Tue, 23 Jul 2019 11:17:19 +0200 Subject: [PATCH] Adds integrationhelper --- custom_components/blueprint/__init__.py | 13 ++++++------- custom_components/blueprint/const.py | 11 +---------- custom_components/blueprint/manifest.json | 2 +- 3 files changed, 8 insertions(+), 18 deletions(-) diff --git a/custom_components/blueprint/__init__.py b/custom_components/blueprint/__init__.py index 7f90a41..151e462 100644 --- a/custom_components/blueprint/__init__.py +++ b/custom_components/blueprint/__init__.py @@ -11,6 +11,10 @@ import voluptuous as vol import homeassistant.helpers.config_validation as cv from homeassistant.helpers import discovery from homeassistant.util import Throttle + +from sampleclient.client import Client +from integrationhelper.const import CC_STARTUP_VERSION + from .const import ( CONF_BINARY_SENSOR, CONF_ENABLED, @@ -25,7 +29,6 @@ from .const import ( ISSUE_URL, PLATFORMS, REQUIRED_FILES, - STARTUP, VERSION, ) @@ -74,12 +77,8 @@ CONFIG_SCHEMA = vol.Schema( async def async_setup(hass, config): """Set up this component.""" - # Import client from a external python package hosted on PyPi - from sampleclient.client import Client - # Print startup message - startup = STARTUP.format(name=DOMAIN, version=VERSION, issueurl=ISSUE_URL) - _LOGGER.info(startup) + _LOGGER.info(CC_STARTUP_VERSION.format(name=DOMAIN, version=VERSION, issue_link=ISSUE_URL)) # Check that all required files are present file_check = await check_files(hass) @@ -143,7 +142,7 @@ class BlueprintData: async def check_files(hass): """Return bool that indicates if all files are present.""" # Verify that the user downloaded all files. - base = "{}/custom_components/{}/".format(hass.config.path(), DOMAIN) + base = f"{hass.config.path()}/custom_components/{DOMAIN}/" missing = [] for file in REQUIRED_FILES: fullpath = "{}{}".format(base, file) diff --git a/custom_components/blueprint/const.py b/custom_components/blueprint/const.py index da457c2..2380311 100644 --- a/custom_components/blueprint/const.py +++ b/custom_components/blueprint/const.py @@ -1,7 +1,7 @@ """Constants for blueprint.""" # Base component constants DOMAIN = "blueprint" -DOMAIN_DATA = "{}_data".format(DOMAIN) +DOMAIN_DATA = f"{DOMAIN}_data" VERSION = "0.0.1" PLATFORMS = ["binary_sensor", "sensor", "switch"] REQUIRED_FILES = [ @@ -13,15 +13,6 @@ REQUIRED_FILES = [ ] ISSUE_URL = "https://github.com/custom-components/blueprint/issues" ATTRIBUTION = "Data from this is provided by blueprint." -STARTUP = """ -------------------------------------------------------------------- -{name} -Version: {version} -This is a custom component -If you have any issues with this you need to open an issue here: -{issueurl} -------------------------------------------------------------------- -""" # Icons ICON = "mdi:format-quote-close" diff --git a/custom_components/blueprint/manifest.json b/custom_components/blueprint/manifest.json index b51d2e9..4e36451 100644 --- a/custom_components/blueprint/manifest.json +++ b/custom_components/blueprint/manifest.json @@ -4,5 +4,5 @@ "documentation": "https://github.com/custom-components/blueprint", "dependencies": [], "codeowners": ["@ludeeus"], - "requirements": ["sampleclient==0.0.1"] + "requirements": ["sampleclient", "integrationhelper"] }