Merge pull request 'chore: rename integration and references in unit tests' (#1) from customise-blueprint into main

Reviewed-on: #1
This commit is contained in:
2021-12-11 12:07:43 +00:00
committed by Alex Berry
19 changed files with 37 additions and 37 deletions

View File

@@ -14,7 +14,7 @@ from homeassistant.exceptions import ConfigEntryNotReady
from homeassistant.helpers.aiohttp_client import async_get_clientsession
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed
from .api import IntegrationBlueprintApiClient
from .api import OctopusEnergyApiClient
from .const import (
CONF_PASSWORD,
@@ -44,7 +44,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
password = entry.data.get(CONF_PASSWORD)
session = async_get_clientsession(hass)
client = IntegrationBlueprintApiClient(username, password, session)
client = OctopusEnergyApiClient(username, password, session)
coordinator = BlueprintDataUpdateCoordinator(hass, client=client)
await coordinator.async_refresh()
@@ -69,7 +69,7 @@ class BlueprintDataUpdateCoordinator(DataUpdateCoordinator):
"""Class to manage fetching data from the API."""
def __init__(
self, hass: HomeAssistant, client: IntegrationBlueprintApiClient
self, hass: HomeAssistant, client: OctopusEnergyApiClient
) -> None:
"""Initialize."""
self.api = client

View File

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

View File

@@ -7,16 +7,16 @@ from .const import (
DEFAULT_NAME,
DOMAIN,
)
from .entity import IntegrationBlueprintEntity
from .entity import OctopusEnergyEntity
async def async_setup_entry(hass, entry, async_add_devices):
"""Setup binary_sensor platform."""
coordinator = hass.data[DOMAIN][entry.entry_id]
async_add_devices([IntegrationBlueprintBinarySensor(coordinator, entry)])
async_add_devices([OctopusEnergyBinarySensor(coordinator, entry)])
class IntegrationBlueprintBinarySensor(IntegrationBlueprintEntity, BinarySensorEntity):
class OctopusEnergyBinarySensor(OctopusEnergyEntity, BinarySensorEntity):
"""integration_blueprint binary_sensor class."""
@property

View File

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

View File

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

View File

@@ -1,15 +1,15 @@
"""Sensor platform for integration_blueprint."""
from .const import DEFAULT_NAME, DOMAIN, ICON, SENSOR
from .entity import IntegrationBlueprintEntity
from .entity import OctopusEnergyEntity
async def async_setup_entry(hass, entry, async_add_devices):
"""Setup sensor platform."""
coordinator = hass.data[DOMAIN][entry.entry_id]
async_add_devices([IntegrationBlueprintSensor(coordinator, entry)])
async_add_devices([OctopusEnergySensor(coordinator, entry)])
class IntegrationBlueprintSensor(IntegrationBlueprintEntity):
class OctopusEnergySensor(OctopusEnergyEntity):
"""integration_blueprint Sensor class."""
@property

View File

@@ -2,16 +2,16 @@
from homeassistant.components.switch import SwitchEntity
from .const import DEFAULT_NAME, DOMAIN, ICON, SWITCH
from .entity import IntegrationBlueprintEntity
from .entity import OctopusEnergyEntity
async def async_setup_entry(hass, entry, async_add_devices):
"""Setup sensor platform."""
coordinator = hass.data[DOMAIN][entry.entry_id]
async_add_devices([IntegrationBlueprintBinarySwitch(coordinator, entry)])
async_add_devices([OctopusEnergyBinarySwitch(coordinator, entry)])
class IntegrationBlueprintBinarySwitch(IntegrationBlueprintEntity, SwitchEntity):
class OctopusEnergyBinarySwitch(OctopusEnergyEntity, SwitchEntity):
"""integration_blueprint switch class."""
async def async_turn_on(self, **kwargs): # pylint: disable=unused-argument