Skip to content

Commit

Permalink
Remove unused consts
Browse files Browse the repository at this point in the history
  • Loading branch information
ludeeus committed Feb 11, 2023
1 parent ac1caeb commit ca7ad78
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 92 deletions.
4 changes: 2 additions & 2 deletions custom_components/integration_blueprint/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
from __future__ import annotations

from homeassistant.config_entries import ConfigEntry
from homeassistant.const import Platform
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME, Platform
from homeassistant.core import HomeAssistant
from homeassistant.exceptions import ConfigEntryNotReady
from homeassistant.helpers.aiohttp_client import async_get_clientsession

from .api import IntegrationBlueprintApiClient
from .const import CONF_PASSWORD, CONF_USERNAME, DOMAIN, PLATFORMS
from .const import DOMAIN
from .coordinator import BlueprintDataUpdateCoordinator

PLATFORMS: list[Platform] = [
Expand Down
8 changes: 4 additions & 4 deletions custom_components/integration_blueprint/binary_sensor.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
"""Binary sensor platform for integration_blueprint."""
from __future__ import annotations

from homeassistant.components.binary_sensor import (
BinarySensorDeviceClass,
BinarySensorEntity,
BinarySensorEntityDescription,
BinarySensorDeviceClass,
)

from .coordinator import BlueprintDataUpdateCoordinator

from .const import DOMAIN
from .coordinator import BlueprintDataUpdateCoordinator
from .entity import IntegrationBlueprintEntity


ENTITY_DESCRIPTIONS = (
BinarySensorEntityDescription(
key="integration_blueprint",
Expand Down
50 changes: 4 additions & 46 deletions custom_components/integration_blueprint/config_flow.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
"""Adds config flow for Blueprint."""
from __future__ import annotations

import voluptuous as vol
from homeassistant import config_entries
from homeassistant.core import callback
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
from homeassistant.helpers.aiohttp_client import async_create_clientsession

from .api import IntegrationBlueprintApiClient
from .const import CONF_PASSWORD, CONF_USERNAME, DOMAIN, PLATFORMS
from .const import DOMAIN


class BlueprintFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
Expand All @@ -22,10 +24,6 @@ async def async_step_user(self, user_input=None):
"""Handle a flow initialized by the user."""
self._errors = {}

# Uncomment the next 2 lines if only a single instance of the integration is allowed:
# if self._async_current_entries():
# return self.async_abort(reason="single_instance_allowed")

if user_input is not None:
valid = await self._test_credentials(
user_input[CONF_USERNAME], user_input[CONF_PASSWORD]
Expand All @@ -46,11 +44,6 @@ async def async_step_user(self, user_input=None):

return await self._show_config_form(user_input)

@staticmethod
@callback
def async_get_options_flow(config_entry):
return BlueprintOptionsFlowHandler(config_entry)

async def _show_config_form(self, user_input): # pylint: disable=unused-argument
"""Show the configuration form to edit location data."""
return self.async_show_form(
Expand All @@ -74,38 +67,3 @@ async def _test_credentials(self, username, password):
except Exception: # pylint: disable=broad-except
pass
return False


class BlueprintOptionsFlowHandler(config_entries.OptionsFlow):
"""Blueprint config flow options handler."""

def __init__(self, config_entry):
"""Initialize HACS options flow."""
self.config_entry = config_entry
self.options = dict(config_entry.options)

async def async_step_init(self, user_input=None): # pylint: disable=unused-argument
"""Manage the options."""
return await self.async_step_user()

async def async_step_user(self, user_input=None):
"""Handle a flow initialized by the user."""
if user_input is not None:
self.options.update(user_input)
return await self._update_options()

return self.async_show_form(
step_id="user",
data_schema=vol.Schema(
{
vol.Required(x, default=self.options.get(x, True)): bool
for x in sorted(PLATFORMS)
}
),
)

async def _update_options(self):
"""Update config entry options."""
return self.async_create_entry(
title=self.config_entry.data.get(CONF_USERNAME), data=self.options
)
38 changes: 1 addition & 37 deletions custom_components/integration_blueprint/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,43 +3,7 @@

LOGGER: Logger = getLogger(__package__)


# Base component constants
NAME = "Integration blueprint"
DOMAIN = "integration_blueprint"
DOMAIN_DATA = f"{DOMAIN}_data"
VERSION = "0.0.1"
VERSION = "0.0.0"
ATTRIBUTION = "Data provided by http://jsonplaceholder.typicode.com/"
ISSUE_URL = "https://github.com/custom-components/integration_blueprint/issues"

# Icons
ICON = "mdi:format-quote-close"

# Device classes
BINARY_SENSOR_DEVICE_CLASS = "connectivity"

# Platforms
BINARY_SENSOR = "binary_sensor"
SENSOR = "sensor"
SWITCH = "switch"
PLATFORMS = [BINARY_SENSOR, SENSOR, SWITCH]


# Configuration and options
CONF_ENABLED = "enabled"
CONF_USERNAME = "username"
CONF_PASSWORD = "password"

# Defaults
DEFAULT_NAME = DOMAIN


STARTUP_MESSAGE = f"""
-------------------------------------------------------------------
{NAME}
Version: {VERSION}
This is a custom integration!
If you have any issues with this you need to open an issue here:
{ISSUE_URL}
-------------------------------------------------------------------
"""
4 changes: 2 additions & 2 deletions custom_components/integration_blueprint/coordinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@

from datetime import timedelta

from homeassistant.core import HomeAssistant
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed

from .api import IntegrationBlueprintApiClient
from .const import LOGGER, DOMAIN
from .const import DOMAIN, LOGGER


class BlueprintDataUpdateCoordinator(DataUpdateCoordinator):
Expand Down
2 changes: 2 additions & 0 deletions custom_components/integration_blueprint/entity.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
"""BlueprintEntity class"""
from __future__ import annotations

from homeassistant.helpers.update_coordinator import CoordinatorEntity

from .const import ATTRIBUTION, DOMAIN, NAME, VERSION
Expand Down
3 changes: 2 additions & 1 deletion custom_components/integration_blueprint/sensor.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
"""Sensor platform for integration_blueprint."""
from __future__ import annotations

from homeassistant.components.sensor import SensorEntity, SensorEntityDescription

from .const import DOMAIN
from .coordinator import BlueprintDataUpdateCoordinator
from .entity import IntegrationBlueprintEntity


ENTITY_DESCRIPTIONS = (
SensorEntityDescription(
key="integration_blueprint",
Expand Down
3 changes: 3 additions & 0 deletions custom_components/integration_blueprint/switch.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
"""Switch platform for integration_blueprint."""
from __future__ import annotations

from homeassistant.components.switch import SwitchEntity, SwitchEntityDescription

from .const import DOMAIN
Expand All @@ -13,6 +15,7 @@
),
)


async def async_setup_entry(hass, entry, async_add_devices):
"""Setup sensor platform."""
coordinator = hass.data[DOMAIN][entry.entry_id]
Expand Down

0 comments on commit ca7ad78

Please sign in to comment.