Skip to content

Commit

Permalink
Update component code imports
Browse files Browse the repository at this point in the history
  • Loading branch information
Limych committed Jun 13, 2022
1 parent 738c98f commit 26facb3
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 20 deletions.
3 changes: 2 additions & 1 deletion custom_components/integration_blueprint/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@
from datetime import timedelta

from homeassistant.config_entries import ConfigEntry
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
from homeassistant.core import HomeAssistant
from homeassistant.exceptions import ConfigEntryNotReady
from homeassistant.helpers.aiohttp_client import async_get_clientsession
from homeassistant.helpers.typing import ConfigType
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed

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

SCAN_INTERVAL = timedelta(seconds=30)

Expand Down
5 changes: 3 additions & 2 deletions custom_components/integration_blueprint/binary_sensor.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
"""Binary sensor platform for integration_blueprint."""
from homeassistant.components.binary_sensor import BinarySensorEntity
from homeassistant.const import Platform
from homeassistant.core import HomeAssistant

from .const import BINARY_SENSOR, BINARY_SENSOR_DEVICE_CLASS, DEFAULT_NAME, DOMAIN
from .const import BINARY_SENSOR_DEVICE_CLASS, DEFAULT_NAME, DOMAIN
from .entity import IntegrationBlueprintEntity


Expand All @@ -18,7 +19,7 @@ class IntegrationBlueprintBinarySensor(IntegrationBlueprintEntity, BinarySensorE
@property
def name(self):
"""Return the name of the binary_sensor."""
return f"{DEFAULT_NAME}_{BINARY_SENSOR}"
return f"{DEFAULT_NAME}_{Platform.BINARY_SENSOR}"

@property
def device_class(self):
Expand Down
8 changes: 2 additions & 6 deletions custom_components/integration_blueprint/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,13 @@
import voluptuous as vol
from homeassistant import config_entries
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
from homeassistant.core import callback
from homeassistant.helpers.aiohttp_client import async_create_clientsession
from homeassistant.helpers.typing import ConfigType

from .api import IntegrationBlueprintApiClient
from .const import ( # pylint: disable=unused-import
CONF_PASSWORD,
CONF_USERNAME,
DOMAIN,
PLATFORMS,
)
from .const import DOMAIN, PLATFORMS # pylint: disable=unused-import


class BlueprintFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
Expand Down
15 changes: 8 additions & 7 deletions custom_components/integration_blueprint/const.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
"""Constants for integration_blueprint."""

# Base component constants
from typing import Final

from homeassistant.const import Platform

# Base component constants
NAME: Final = "Integration blueprint"
DOMAIN: Final = "integration_blueprint"
VERSION: Final = "0.1.0"
Expand All @@ -26,15 +28,14 @@
BINARY_SENSOR_DEVICE_CLASS: Final = "connectivity"

# Platforms
BINARY_SENSOR: Final = "binary_sensor"
SENSOR: Final = "sensor"
SWITCH: Final = "switch"
PLATFORMS: Final = [BINARY_SENSOR, SENSOR, SWITCH]
PLATFORMS: Final = [
Platform.BINARY_SENSOR,
Platform.SENSOR,
Platform.SWITCH,
]

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

# Defaults
DEFAULT_NAME: Final = DOMAIN
Expand Down
5 changes: 3 additions & 2 deletions custom_components/integration_blueprint/sensor.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
"""Sensor platform for integration_blueprint."""
from homeassistant.components.sensor import SensorEntity
from homeassistant.const import Platform
from homeassistant.core import HomeAssistant

from .const import DEFAULT_NAME, DOMAIN, ICON, SENSOR
from .const import DEFAULT_NAME, DOMAIN, ICON
from .entity import IntegrationBlueprintEntity


Expand All @@ -18,7 +19,7 @@ class IntegrationBlueprintSensor(IntegrationBlueprintEntity, SensorEntity):
@property
def name(self):
"""Return the name of the sensor."""
return f"{DEFAULT_NAME}_{SENSOR}"
return f"{DEFAULT_NAME}_{Platform.SENSOR}"

@property
def native_value(self):
Expand Down
5 changes: 3 additions & 2 deletions custom_components/integration_blueprint/switch.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
"""Switch platform for integration_blueprint."""
from homeassistant.components.switch import SwitchEntity
from homeassistant.const import Platform
from homeassistant.core import HomeAssistant

from .const import DEFAULT_NAME, DOMAIN, ICON, SWITCH
from .const import DEFAULT_NAME, DOMAIN, ICON
from .entity import IntegrationBlueprintEntity


Expand All @@ -28,7 +29,7 @@ async def async_turn_off(self, **kwargs): # pylint: disable=unused-argument
@property
def name(self):
"""Return the name of the switch."""
return f"{DEFAULT_NAME}_{SWITCH}"
return f"{DEFAULT_NAME}_{Platform.SWITCH}"

@property
def icon(self):
Expand Down

0 comments on commit 26facb3

Please sign in to comment.