Rename [blueprint|Blueprint] -> [integration_blueprint|Integration blueprint] (#47)

This commit is contained in:
Joakim Sørensen 2020-11-15 00:30:14 +01:00 committed by GitHub
parent 668bd9d0bc
commit 8b3b9d380a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
19 changed files with 309 additions and 307 deletions

View File

@ -3,4 +3,4 @@ default_config:
logger: logger:
default: info default: info
logs: logs:
custom_components.blueprint: debug custom_components.integration_blueprint: debug

View File

@ -48,7 +48,7 @@ Use [black](https://github.com/ambv/black) to make sure the code follows the sty
## Test your code modification ## Test your code modification
This custom component is based on [blueprint template](https://github.com/custom-components/blueprint). This custom component is based on [integration_blueprint template](https://github.com/custom-components/integration_blueprint).
It comes with development environment in a container, easy to launch It comes with development environment in a container, easy to launch
if you use Visual Studio Code. With this container you will have a stand alone if you use Visual Studio Code. With this container you will have a stand alone

View File

@ -25,15 +25,15 @@ File | Purpose
`.github/ISSUE_TEMPLATE/issue.md` | Template for issues `.github/ISSUE_TEMPLATE/issue.md` | Template for issues
`.github/settings.yml` | Probot settings to control the repository settings. `.github/settings.yml` | Probot settings to control the repository settings.
`.vscode/tasks.json` | Tasks for the devcontainer. `.vscode/tasks.json` | Tasks for the devcontainer.
`custom_components/blueprint/translations/*` | [Translation files.](https://developers.home-assistant.io/docs/internationalization/custom_integration) `custom_components/integration_blueprint/translations/*` | [Translation files.](https://developers.home-assistant.io/docs/internationalization/custom_integration)
`custom_components/blueprint/__init__.py` | The component file for the integration. `custom_components/integration_blueprint/__init__.py` | The component file for the integration.
`custom_components/blueprint/api.py` | This is a sample API client. `custom_components/integration_blueprint/api.py` | This is a sample API client.
`custom_components/blueprint/binary_sensor.py` | Binary sensor platform for the integration. `custom_components/integration_blueprint/binary_sensor.py` | Binary sensor platform for the integration.
`custom_components/blueprint/config_flow.py` | Config flow file, this adds the UI configuration possibilities. `custom_components/integration_blueprint/config_flow.py` | Config flow file, this adds the UI configuration possibilities.
`custom_components/blueprint/const.py` | A file to hold shared variables/constants for the entire integration. `custom_components/integration_blueprint/const.py` | A file to hold shared variables/constants for the entire integration.
`custom_components/blueprint/manifest.json` | A [manifest file](https://developers.home-assistant.io/docs/en/creating_integration_manifest.html) for Home Assistant. `custom_components/integration_blueprint/manifest.json` | A [manifest file](https://developers.home-assistant.io/docs/en/creating_integration_manifest.html) for Home Assistant.
`custom_components/blueprint/sensor.py` | Sensor platform for the integration. `custom_components/integration_blueprint/sensor.py` | Sensor platform for the integration.
`custom_components/blueprint/switch.py` | Switch sensor platform for the integration. `custom_components/integration_blueprint/switch.py` | Switch sensor platform for the integration.
`CONTRIBUTING.md` | Guidelines on how to contribute. `CONTRIBUTING.md` | Guidelines on how to contribute.
`example.png` | Screenshot that demonstrate how it might look in the UI. `example.png` | Screenshot that demonstrate how it might look in the UI.
`info.md` | An example on a info file (used by [hacs][hacs]). `info.md` | An example on a info file (used by [hacs][hacs]).
@ -65,7 +65,7 @@ to ensure Home Assistant update the code of the python library. (example `"requi
README content if this was a published component: README content if this was a published component:
*** ***
# blueprint # integration_blueprint
[![GitHub Release][releases-shield]][releases] [![GitHub Release][releases-shield]][releases]
[![GitHub Activity][commits-shield]][commits] [![GitHub Activity][commits-shield]][commits]
@ -78,7 +78,7 @@ README content if this was a published component:
[![Discord][discord-shield]][discord] [![Discord][discord-shield]][discord]
[![Community Forum][forum-shield]][forum] [![Community Forum][forum-shield]][forum]
_Component to integrate with [blueprint][blueprint]._ _Component to integrate with [integration_blueprint][integration_blueprint]._
**This component will set up the following platforms.** **This component will set up the following platforms.**
@ -94,8 +94,8 @@ Platform | Description
1. Using the tool of choice open the directory (folder) for your HA configuration (where you find `configuration.yaml`). 1. Using the tool of choice open the directory (folder) for your HA configuration (where you find `configuration.yaml`).
2. If you do not have a `custom_components` directory (folder) there, you need to create it. 2. If you do not have a `custom_components` directory (folder) there, you need to create it.
3. In the `custom_components` directory (folder) create a new folder called `blueprint`. 3. In the `custom_components` directory (folder) create a new folder called `integration_blueprint`.
4. Download _all_ the files from the `custom_components/blueprint/` directory (folder) in this repository. 4. Download _all_ the files from the `custom_components/integration_blueprint/` directory (folder) in this repository.
5. Place the files you downloaded in the new directory (folder) you created. 5. Place the files you downloaded in the new directory (folder) you created.
6. Restart Home Assistant 6. Restart Home Assistant
7. In the HA UI go to "Configuration" -> "Integrations" click "+" and search for "Blueprint" 7. In the HA UI go to "Configuration" -> "Integrations" click "+" and search for "Blueprint"
@ -103,17 +103,17 @@ Platform | Description
Using your HA configuration directory (folder) as a starting point you should now also have this: Using your HA configuration directory (folder) as a starting point you should now also have this:
```text ```text
custom_components/blueprint/translations/en.json custom_components/integration_blueprint/translations/en.json
custom_components/blueprint/translations/nb.json custom_components/integration_blueprint/translations/nb.json
custom_components/blueprint/translations/sensor.nb.json custom_components/integration_blueprint/translations/sensor.nb.json
custom_components/blueprint/__init__.py custom_components/integration_blueprint/__init__.py
custom_components/blueprint/api.py custom_components/integration_blueprint/api.py
custom_components/blueprint/binary_sensor.py custom_components/integration_blueprint/binary_sensor.py
custom_components/blueprint/config_flow.py custom_components/integration_blueprint/config_flow.py
custom_components/blueprint/const.py custom_components/integration_blueprint/const.py
custom_components/blueprint/manifest.json custom_components/integration_blueprint/manifest.json
custom_components/blueprint/sensor.py custom_components/integration_blueprint/sensor.py
custom_components/blueprint/switch.py custom_components/integration_blueprint/switch.py
``` ```
## Configuration is done in the UI ## Configuration is done in the UI
@ -126,11 +126,11 @@ If you want to contribute to this please read the [Contribution guidelines](CONT
*** ***
[blueprint]: https://github.com/custom-components/blueprint [integration_blueprint]: https://github.com/custom-components/integration_blueprint
[buymecoffee]: https://www.buymeacoffee.com/ludeeus [buymecoffee]: https://www.buymeacoffee.com/ludeeus
[buymecoffeebadge]: https://img.shields.io/badge/buy%20me%20a%20coffee-donate-yellow.svg?style=for-the-badge [buymecoffeebadge]: https://img.shields.io/badge/buy%20me%20a%20coffee-donate-yellow.svg?style=for-the-badge
[commits-shield]: https://img.shields.io/github/commit-activity/y/custom-components/blueprint.svg?style=for-the-badge [commits-shield]: https://img.shields.io/github/commit-activity/y/custom-components/blueprint.svg?style=for-the-badge
[commits]: https://github.com/custom-components/blueprint/commits/master [commits]: https://github.com/custom-components/integration_blueprint/commits/master
[hacs]: https://github.com/custom-components/hacs [hacs]: https://github.com/custom-components/hacs
[hacsbadge]: https://img.shields.io/badge/HACS-Custom-orange.svg?style=for-the-badge [hacsbadge]: https://img.shields.io/badge/HACS-Custom-orange.svg?style=for-the-badge
[discord]: https://discord.gg/Qa5fW2R [discord]: https://discord.gg/Qa5fW2R
@ -141,4 +141,4 @@ If you want to contribute to this please read the [Contribution guidelines](CONT
[license-shield]: https://img.shields.io/github/license/custom-components/blueprint.svg?style=for-the-badge [license-shield]: https://img.shields.io/github/license/custom-components/blueprint.svg?style=for-the-badge
[maintenance-shield]: https://img.shields.io/badge/maintainer-Joakim%20Sørensen%20%40ludeeus-blue.svg?style=for-the-badge [maintenance-shield]: https://img.shields.io/badge/maintainer-Joakim%20Sørensen%20%40ludeeus-blue.svg?style=for-the-badge
[releases-shield]: https://img.shields.io/github/release/custom-components/blueprint.svg?style=for-the-badge [releases-shield]: https://img.shields.io/github/release/custom-components/blueprint.svg?style=for-the-badge
[releases]: https://github.com/custom-components/blueprint/releases [releases]: https://github.com/custom-components/integration_blueprint/releases

View File

@ -1,12 +0,0 @@
{
"domain": "blueprint",
"name": "Blueprint",
"documentation": "https://github.com/custom-components/blueprint",
"issue_tracker": "https://github.com/custom-components/blueprint/issues",
"dependencies": [],
"config_flow": true,
"codeowners": [
"@ludeeus"
],
"requirements": []
}

View File

@ -1,107 +1,109 @@
""" """
Custom integration to integrate blueprint with Home Assistant. Custom integration to integrate integration_blueprint with Home Assistant.
For more details about this integration, please refer to For more details about this integration, please refer to
https://github.com/custom-components/blueprint https://github.com/custom-components/integration_blueprint
""" """
import asyncio import asyncio
from datetime import timedelta from datetime import timedelta
import logging import logging
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.core import Config, HomeAssistant from homeassistant.core import Config, HomeAssistant
from homeassistant.exceptions import ConfigEntryNotReady from homeassistant.exceptions import ConfigEntryNotReady
from homeassistant.helpers.aiohttp_client import async_get_clientsession from homeassistant.helpers.aiohttp_client import async_get_clientsession
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed
from .api import BlueprintApiClient from .api import IntegrationBlueprintApiClient
from .const import ( from .const import (
CONF_PASSWORD, CONF_PASSWORD,
CONF_USERNAME, CONF_USERNAME,
DOMAIN, DOMAIN,
PLATFORMS, PLATFORMS,
STARTUP_MESSAGE, STARTUP_MESSAGE,
) )
SCAN_INTERVAL = timedelta(seconds=30) SCAN_INTERVAL = timedelta(seconds=30)
_LOGGER: logging.Logger = logging.getLogger(__package__) _LOGGER: logging.Logger = logging.getLogger(__package__)
async def async_setup(hass: HomeAssistant, config: Config): async def async_setup(hass: HomeAssistant, config: Config):
"""Set up this integration using YAML is not supported.""" """Set up this integration using YAML is not supported."""
return True return True
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry): async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
"""Set up this integration using UI.""" """Set up this integration using UI."""
if hass.data.get(DOMAIN) is None: if hass.data.get(DOMAIN) is None:
hass.data.setdefault(DOMAIN, {}) hass.data.setdefault(DOMAIN, {})
_LOGGER.info(STARTUP_MESSAGE) _LOGGER.info(STARTUP_MESSAGE)
username = entry.data.get(CONF_USERNAME) username = entry.data.get(CONF_USERNAME)
password = entry.data.get(CONF_PASSWORD) password = entry.data.get(CONF_PASSWORD)
session = async_get_clientsession(hass) session = async_get_clientsession(hass)
client = BlueprintApiClient(username, password, session) client = IntegrationBlueprintApiClient(username, password, session)
coordinator = BlueprintDataUpdateCoordinator(hass, client=client) coordinator = BlueprintDataUpdateCoordinator(hass, client=client)
await coordinator.async_refresh() await coordinator.async_refresh()
if not coordinator.last_update_success: if not coordinator.last_update_success:
raise ConfigEntryNotReady raise ConfigEntryNotReady
hass.data[DOMAIN][entry.entry_id] = coordinator hass.data[DOMAIN][entry.entry_id] = coordinator
for platform in PLATFORMS: for platform in PLATFORMS:
if entry.options.get(platform, True): if entry.options.get(platform, True):
coordinator.platforms.append(platform) coordinator.platforms.append(platform)
hass.async_add_job( hass.async_add_job(
hass.config_entries.async_forward_entry_setup(entry, platform) hass.config_entries.async_forward_entry_setup(entry, platform)
) )
entry.add_update_listener(async_reload_entry) entry.add_update_listener(async_reload_entry)
return True return True
class BlueprintDataUpdateCoordinator(DataUpdateCoordinator): class BlueprintDataUpdateCoordinator(DataUpdateCoordinator):
"""Class to manage fetching data from the API.""" """Class to manage fetching data from the API."""
def __init__(self, hass: HomeAssistant, client: BlueprintApiClient) -> None: def __init__(
"""Initialize.""" self, hass: HomeAssistant, client: IntegrationBlueprintApiClient
self.api: BlueprintApiClient = client ) -> None:
self.platforms = [] """Initialize."""
self.api = client
super().__init__(hass, _LOGGER, name=DOMAIN, update_interval=SCAN_INTERVAL) self.platforms = []
async def _async_update_data(self): super().__init__(hass, _LOGGER, name=DOMAIN, update_interval=SCAN_INTERVAL)
"""Update data via library."""
try: async def _async_update_data(self):
return await self.api.async_get_data() """Update data via library."""
except Exception as exception: try:
raise UpdateFailed() from exception return await self.api.async_get_data()
except Exception as exception:
raise UpdateFailed() from exception
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Handle removal of an entry."""
coordinator = hass.data[DOMAIN][entry.entry_id] async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
unloaded = all( """Handle removal of an entry."""
await asyncio.gather( coordinator = hass.data[DOMAIN][entry.entry_id]
*[ unloaded = all(
hass.config_entries.async_forward_entry_unload(entry, platform) await asyncio.gather(
for platform in PLATFORMS *[
if platform in coordinator.platforms hass.config_entries.async_forward_entry_unload(entry, platform)
] for platform in PLATFORMS
) if platform in coordinator.platforms
) ]
if unloaded: )
hass.data[DOMAIN].pop(entry.entry_id) )
if unloaded:
return unloaded hass.data[DOMAIN].pop(entry.entry_id)
return unloaded
async def async_reload_entry(hass: HomeAssistant, entry: ConfigEntry) -> None:
"""Reload config entry."""
await async_unload_entry(hass, entry) async def async_reload_entry(hass: HomeAssistant, entry: ConfigEntry) -> None:
await async_setup_entry(hass, entry) """Reload config entry."""
await async_unload_entry(hass, entry)
await async_setup_entry(hass, entry)

View File

@ -14,7 +14,7 @@ _LOGGER: logging.Logger = logging.getLogger(__package__)
HEADERS = {"Content-type": "application/json; charset=UTF-8"} HEADERS = {"Content-type": "application/json; charset=UTF-8"}
class BlueprintApiClient: class IntegrationBlueprintApiClient:
def __init__( def __init__(
self, username: str, password: str, session: aiohttp.ClientSession self, username: str, password: str, session: aiohttp.ClientSession
) -> None: ) -> None:

View File

@ -1,35 +1,35 @@
"""Binary sensor platform for blueprint.""" """Binary sensor platform for integration_blueprint."""
from homeassistant.components.binary_sensor import BinarySensorDevice from homeassistant.components.binary_sensor import BinarySensorEntity
from .const import ( from .const import (
BINARY_SENSOR, BINARY_SENSOR,
BINARY_SENSOR_DEVICE_CLASS, BINARY_SENSOR_DEVICE_CLASS,
DEFAULT_NAME, DEFAULT_NAME,
DOMAIN, DOMAIN,
) )
from .entity import BlueprintEntity from .entity import IntegrationBlueprintEntity
async def async_setup_entry(hass, entry, async_add_devices): async def async_setup_entry(hass, entry, async_add_devices):
"""Setup binary_sensor platform.""" """Setup binary_sensor platform."""
coordinator = hass.data[DOMAIN][entry.entry_id] coordinator = hass.data[DOMAIN][entry.entry_id]
async_add_devices([BlueprintBinarySensor(coordinator, entry)]) async_add_devices([IntegrationBlueprintBinarySensor(coordinator, entry)])
class BlueprintBinarySensor(BlueprintEntity, BinarySensorDevice): class IntegrationBlueprintBinarySensor(IntegrationBlueprintEntity, BinarySensorEntity):
"""blueprint binary_sensor class.""" """integration_blueprint binary_sensor class."""
@property @property
def name(self): def name(self):
"""Return the name of the binary_sensor.""" """Return the name of the binary_sensor."""
return f"{DEFAULT_NAME}_{BINARY_SENSOR}" return f"{DEFAULT_NAME}_{BINARY_SENSOR}"
@property @property
def device_class(self): def device_class(self):
"""Return the class of this binary_sensor.""" """Return the class of this binary_sensor."""
return BINARY_SENSOR_DEVICE_CLASS return BINARY_SENSOR_DEVICE_CLASS
@property @property
def is_on(self): def is_on(self):
"""Return true if the binary_sensor is on.""" """Return true if the binary_sensor is on."""
return self.coordinator.data.get("title", "") == "foo" return self.coordinator.data.get("title", "") == "foo"

View File

@ -4,7 +4,7 @@ from homeassistant.core import callback
from homeassistant.helpers.aiohttp_client import async_create_clientsession from homeassistant.helpers.aiohttp_client import async_create_clientsession
import voluptuous as vol import voluptuous as vol
from .api import BlueprintApiClient from .api import IntegrationBlueprintApiClient
from .const import ( from .const import (
CONF_PASSWORD, CONF_PASSWORD,
CONF_USERNAME, CONF_USERNAME,
@ -65,7 +65,7 @@ class BlueprintFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
"""Return true if credentials is valid.""" """Return true if credentials is valid."""
try: try:
session = async_create_clientsession(self.hass) session = async_create_clientsession(self.hass)
client = BlueprintApiClient(username, password, session) client = IntegrationBlueprintApiClient(username, password, session)
await client.async_get_data() await client.async_get_data()
return True return True
except Exception: # pylint: disable=broad-except except Exception: # pylint: disable=broad-except

View File

@ -1,40 +1,40 @@
"""Constants for blueprint.""" """Constants for integration_blueprint."""
# Base component constants # Base component constants
NAME = "Blueprint" NAME = "Integration blueprint"
DOMAIN = "blueprint" DOMAIN = "integration_blueprint"
DOMAIN_DATA = f"{DOMAIN}_data" DOMAIN_DATA = f"{DOMAIN}_data"
VERSION = "0.0.1" VERSION = "0.0.1"
ATTRIBUTION = "Data provided by http://jsonplaceholder.typicode.com/" ATTRIBUTION = "Data provided by http://jsonplaceholder.typicode.com/"
ISSUE_URL = "https://github.com/custom-components/blueprint/issues" ISSUE_URL = "https://github.com/custom-components/integration_blueprint/issues"
# Icons # Icons
ICON = "mdi:format-quote-close" ICON = "mdi:format-quote-close"
# Device classes # Device classes
BINARY_SENSOR_DEVICE_CLASS = "connectivity" BINARY_SENSOR_DEVICE_CLASS = "connectivity"
# Platforms # Platforms
BINARY_SENSOR = "binary_sensor" BINARY_SENSOR = "binary_sensor"
SENSOR = "sensor" SENSOR = "sensor"
SWITCH = "switch" SWITCH = "switch"
PLATFORMS = [BINARY_SENSOR, SENSOR, SWITCH] PLATFORMS = [BINARY_SENSOR, SENSOR, SWITCH]
# Configuration and options # Configuration and options
CONF_ENABLED = "enabled" CONF_ENABLED = "enabled"
CONF_USERNAME = "username" CONF_USERNAME = "username"
CONF_PASSWORD = "password" CONF_PASSWORD = "password"
# Defaults # Defaults
DEFAULT_NAME = DOMAIN DEFAULT_NAME = DOMAIN
STARTUP_MESSAGE = f""" STARTUP_MESSAGE = f"""
------------------------------------------------------------------- -------------------------------------------------------------------
{NAME} {NAME}
Version: {VERSION} Version: {VERSION}
This is a custom integration! This is a custom integration!
If you have any issues with this you need to open an issue here: If you have any issues with this you need to open an issue here:
{ISSUE_URL} {ISSUE_URL}
------------------------------------------------------------------- -------------------------------------------------------------------
""" """

View File

@ -4,7 +4,7 @@ from homeassistant.helpers.update_coordinator import CoordinatorEntity
from .const import DOMAIN, NAME, VERSION, ATTRIBUTION from .const import DOMAIN, NAME, VERSION, ATTRIBUTION
class BlueprintEntity(CoordinatorEntity): class IntegrationBlueprintEntity(CoordinatorEntity):
def __init__(self, coordinator, config_entry): def __init__(self, coordinator, config_entry):
super().__init__(coordinator) super().__init__(coordinator)
self.config_entry = config_entry self.config_entry = config_entry

View File

@ -0,0 +1,12 @@
{
"domain": "integration_blueprint",
"name": "Integration blueprint",
"documentation": "https://github.com/custom-components/integration_blueprint",
"issue_tracker": "https://github.com/custom-components/integration_blueprint/issues",
"dependencies": [],
"config_flow": true,
"codeowners": [
"@ludeeus"
],
"requirements": []
}

View File

@ -1,28 +1,28 @@
"""Sensor platform for blueprint.""" """Sensor platform for integration_blueprint."""
from .const import DEFAULT_NAME, DOMAIN, ICON, SENSOR from .const import DEFAULT_NAME, DOMAIN, ICON, SENSOR
from .entity import BlueprintEntity from .entity import IntegrationBlueprintEntity
async def async_setup_entry(hass, entry, async_add_devices): async def async_setup_entry(hass, entry, async_add_devices):
"""Setup sensor platform.""" """Setup sensor platform."""
coordinator = hass.data[DOMAIN][entry.entry_id] coordinator = hass.data[DOMAIN][entry.entry_id]
async_add_devices([BlueprintSensor(coordinator, entry)]) async_add_devices([IntegrationBlueprintSensor(coordinator, entry)])
class BlueprintSensor(BlueprintEntity): class IntegrationBlueprintSensor(IntegrationBlueprintEntity):
"""blueprint Sensor class.""" """integration_blueprint Sensor class."""
@property @property
def name(self): def name(self):
"""Return the name of the sensor.""" """Return the name of the sensor."""
return f"{DEFAULT_NAME}_{SENSOR}" return f"{DEFAULT_NAME}_{SENSOR}"
@property @property
def state(self): def state(self):
"""Return the state of the sensor.""" """Return the state of the sensor."""
return self.coordinator.data.get("body") return self.coordinator.data.get("body")
@property @property
def icon(self): def icon(self):
"""Return the icon of the sensor.""" """Return the icon of the sensor."""
return ICON return ICON

View File

@ -1,40 +1,40 @@
"""Switch platform for blueprint.""" """Switch platform for integration_blueprint."""
from homeassistant.components.switch import SwitchEntity from homeassistant.components.switch import SwitchEntity
from .const import DEFAULT_NAME, DOMAIN, ICON, SWITCH from .const import DEFAULT_NAME, DOMAIN, ICON, SWITCH
from .entity import BlueprintEntity from .entity import IntegrationBlueprintEntity
async def async_setup_entry(hass, entry, async_add_devices): async def async_setup_entry(hass, entry, async_add_devices):
"""Setup sensor platform.""" """Setup sensor platform."""
coordinator = hass.data[DOMAIN][entry.entry_id] coordinator = hass.data[DOMAIN][entry.entry_id]
async_add_devices([BlueprintBinarySwitch(coordinator, entry)]) async_add_devices([IntegrationBlueprintBinarySwitch(coordinator, entry)])
class BlueprintBinarySwitch(BlueprintEntity, SwitchEntity): class IntegrationBlueprintBinarySwitch(IntegrationBlueprintEntity, SwitchEntity):
"""blueprint switch class.""" """integration_blueprint switch class."""
async def async_turn_on(self, **kwargs): # pylint: disable=unused-argument async def async_turn_on(self, **kwargs): # pylint: disable=unused-argument
"""Turn on the switch.""" """Turn on the switch."""
await self.coordinator.api.async_set_title("bar") await self.coordinator.api.async_set_title("bar")
await self.coordinator.async_request_refresh() await self.coordinator.async_request_refresh()
async def async_turn_off(self, **kwargs): # pylint: disable=unused-argument async def async_turn_off(self, **kwargs): # pylint: disable=unused-argument
"""Turn off the switch.""" """Turn off the switch."""
await self.coordinator.api.async_set_title("foo") await self.coordinator.api.async_set_title("foo")
await self.coordinator.async_request_refresh() await self.coordinator.async_request_refresh()
@property @property
def name(self): def name(self):
"""Return the name of the switch.""" """Return the name of the switch."""
return f"{DEFAULT_NAME}_{SWITCH}" return f"{DEFAULT_NAME}_{SWITCH}"
@property @property
def icon(self): def icon(self):
"""Return the icon of this switch.""" """Return the icon of this switch."""
return ICON return ICON
@property @property
def is_on(self): def is_on(self):
"""Return true if the switch is on.""" """Return true if the switch is on."""
return self.coordinator.data.get("title", "") == "foo" return self.coordinator.data.get("title", "") == "foo"

View File

@ -4,7 +4,7 @@
"step": { "step": {
"user": { "user": {
"title": "Blueprint", "title": "Blueprint",
"description": "If you need help with the configuration have a look here: https://github.com/custom-components/blueprint", "description": "If you need help with the configuration have a look here: https://github.com/custom-components/integration_blueprint",
"data": { "data": {
"username": "Username", "username": "Username",
"password": "Password" "password": "Password"

View File

@ -4,7 +4,7 @@
"step": { "step": {
"user": { "user": {
"title": "Blueprint", "title": "Blueprint",
"description": "Hvis du trenger hjep til konfigurasjon ta en titt her: https://github.com/custom-components/blueprint", "description": "Hvis du trenger hjep til konfigurasjon ta en titt her: https://github.com/custom-components/integration_blueprint",
"data": { "data": {
"username": "Brukernavn", "username": "Brukernavn",
"password": "Passord" "password": "Passord"

View File

@ -1,5 +1,5 @@
{ {
"name": "Blueprint", "name": "Integration blueprint",
"hacs": "1.6.0", "hacs": "1.6.0",
"domains": [ "domains": [
"binary_sensor", "binary_sensor",

16
info.md
View File

@ -9,7 +9,7 @@
[![Discord][discord-shield]][discord] [![Discord][discord-shield]][discord]
[![Community Forum][forum-shield]][forum] [![Community Forum][forum-shield]][forum]
_Component to integrate with [blueprint][blueprint]._ _Component to integrate with [integration_blueprint][integration_blueprint]._
**This component will set up the following platforms.** **This component will set up the following platforms.**
@ -36,11 +36,11 @@ Platform | Description
*** ***
[blueprint]: https://github.com/custom-components/blueprint [integration_blueprint]: https://github.com/custom-components/integration_blueprint
[buymecoffee]: https://www.buymeacoffee.com/ludeeus [buymecoffee]: https://www.buymeacoffee.com/ludeeus
[buymecoffeebadge]: https://img.shields.io/badge/buy%20me%20a%20coffee-donate-yellow.svg?style=for-the-badge [buymecoffeebadge]: https://img.shields.io/badge/buy%20me%20a%20coffee-donate-yellow.svg?style=for-the-badge
[commits-shield]: https://img.shields.io/github/commit-activity/y/custom-components/blueprint.svg?style=for-the-badge [commits-shield]: https://img.shields.io/github/commit-activity/y/custom-components/integration_blueprint.svg?style=for-the-badge
[commits]: https://github.com/custom-components/blueprint/commits/master [commits]: https://github.com/custom-components/integration_blueprint/commits/master
[hacs]: https://hacs.xyz [hacs]: https://hacs.xyz
[hacsbadge]: https://img.shields.io/badge/HACS-Custom-orange.svg?style=for-the-badge [hacsbadge]: https://img.shields.io/badge/HACS-Custom-orange.svg?style=for-the-badge
[discord]: https://discord.gg/Qa5fW2R [discord]: https://discord.gg/Qa5fW2R
@ -48,9 +48,9 @@ Platform | Description
[exampleimg]: example.png [exampleimg]: example.png
[forum-shield]: https://img.shields.io/badge/community-forum-brightgreen.svg?style=for-the-badge [forum-shield]: https://img.shields.io/badge/community-forum-brightgreen.svg?style=for-the-badge
[forum]: https://community.home-assistant.io/ [forum]: https://community.home-assistant.io/
[license]: https://github.com/custom-components/blueprint/blob/main/LICENSE [license]: https://github.com/custom-components/integration_blueprint/blob/main/LICENSE
[license-shield]: https://img.shields.io/github/license/custom-components/blueprint.svg?style=for-the-badge [license-shield]: https://img.shields.io/github/license/custom-components/integration_blueprint.svg?style=for-the-badge
[maintenance-shield]: https://img.shields.io/badge/maintainer-Joakim%20Sørensen%20%40ludeeus-blue.svg?style=for-the-badge [maintenance-shield]: https://img.shields.io/badge/maintainer-Joakim%20Sørensen%20%40ludeeus-blue.svg?style=for-the-badge
[releases-shield]: https://img.shields.io/github/release/custom-components/blueprint.svg?style=for-the-badge [releases-shield]: https://img.shields.io/github/release/custom-components/integration_blueprint.svg?style=for-the-badge
[releases]: https://github.com/custom-components/blueprint/releases [releases]: https://github.com/custom-components/integration_blueprint/releases
[user_profile]: https://github.com/ludeeus [user_profile]: https://github.com/ludeeus

View File

@ -31,5 +31,5 @@ not_skip = __init__.py
force_sort_within_sections = true force_sort_within_sections = true
sections = FUTURE,STDLIB,INBETWEENS,THIRDPARTY,FIRSTPARTY,LOCALFOLDER sections = FUTURE,STDLIB,INBETWEENS,THIRDPARTY,FIRSTPARTY,LOCALFOLDER
default_section = THIRDPARTY default_section = THIRDPARTY
known_first_party = custom_components.blueprint known_first_party = custom_components.integration_blueprint
combine_as_imports = true combine_as_imports = true