Compare commits
103 Commits
main
..
907de1aaab
| Author | SHA1 | Date | |
|---|---|---|---|
| 907de1aaab | |||
| b7a5860bbf | |||
| 3a2ced07f2 | |||
| fbf793c4c3 | |||
| d288b706ef | |||
| 13a80e6af5 | |||
| cb91d2f547 | |||
| a11ab703b1 | |||
| 93ed8a4c15 | |||
| 70330a886d | |||
| 52057dff79 | |||
| 20575023cc | |||
| 8637de6b1f | |||
| 1033955ee1 | |||
| e059bc7cc5 | |||
| f85cbb043d | |||
| 75670b7d06 | |||
| 39186e56af | |||
| 8b3b9d380a | |||
| 668bd9d0bc | |||
| bf76923975 | |||
| f2b72debbe | |||
| 9f9d0e8106 | |||
| 871f00ebdc | |||
| 891cd4c4e0 | |||
| 3c2cd2413d | |||
| 227bd66972 | |||
| 99b07e5a7a | |||
| b22ae5949b | |||
| 411ea16668 | |||
| 15c2139381 | |||
| 0cd664e2a6 | |||
| 97dd68da95 | |||
| a727e061d6 | |||
| a53b0f75a1 | |||
| d408fbec4a | |||
| 48eb57ef70 | |||
| 0a3a92db07 | |||
| a7d67066d4 | |||
| 123f34de02 | |||
| 73ff34ff9a | |||
| db21a76885 | |||
| 5b045f8c4f | |||
| 6691cd0df9 | |||
| d156150ef0 | |||
| 92ae97dc5f | |||
| 0037bb63fe | |||
| f2a65e77b6 | |||
| 4701c3cd46 | |||
| 8457aefc77 | |||
| 45617d8515 | |||
| 59463b5f70 | |||
| a3ec139da7 | |||
| 6f7550f085 | |||
| 23207e0d53 | |||
| b4796efba9 | |||
| 3bdee78f8e | |||
| c33b946cc3 | |||
| 2ff5a884ce | |||
| 17b1faf7df | |||
| 0f8e201567 | |||
| 6d01a5d62c | |||
| 94c21d1eea | |||
| 6e2def9513 | |||
| f8d10d2612 | |||
| 56d61a8c1f | |||
| 6ab2f89a30 | |||
| 551e08ef37 | |||
| 616119eb09 | |||
| 9e26772a1a | |||
| 775d56196c | |||
| 44df9faee0 | |||
| f891b56cb2 | |||
| 239ab126fb | |||
| 45e8c03424 | |||
| 72f0635833 | |||
| 3865152f5f | |||
| 2010ee4d02 | |||
| 3cdebc5097 | |||
| dc7824b765 | |||
| bac1074a71 | |||
| 20a36692e7 | |||
| 53f2adf129 | |||
| a7c74fdf86 | |||
| 011400bb38 | |||
| 9a4a86bfea | |||
| 3717319711 | |||
| 01d25d9908 | |||
| 43652bc1c2 | |||
| cd150f816f | |||
| 43e6ba2f25 | |||
| f95c60fc53 | |||
| 523126d0a9 | |||
| 2750137017 | |||
| 2f48db9582 | |||
| 6a043f9e29 | |||
| 6bd7005957 | |||
| 1c072fb5fa | |||
| ce2d663821 | |||
| 08fbf028d3 | |||
| bf3dab8782 | |||
| ad2e54a710 | |||
| f686660196 |
@@ -3,7 +3,7 @@ default_config:
|
|||||||
logger:
|
logger:
|
||||||
default: info
|
default: info
|
||||||
logs:
|
logs:
|
||||||
custom_components.octopusenergy: debug
|
custom_components.integration_blueprint: debug
|
||||||
|
|
||||||
# If you need to debug uncomment the line below (doc: https://www.home-assistant.io/integrations/debugpy/)
|
# If you need to debug uncomment the line below (doc: https://www.home-assistant.io/integrations/debugpy/)
|
||||||
# debugpy:
|
# debugpy:
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ jobs:
|
|||||||
--timeout=9 \
|
--timeout=9 \
|
||||||
--durations=10 \
|
--durations=10 \
|
||||||
-n auto \
|
-n auto \
|
||||||
--cov custom_components.octopusenergy \
|
--cov custom_components.integration_blueprint \
|
||||||
-o console_output_style=count \
|
-o console_output_style=count \
|
||||||
-p no:sugar \
|
-p no:sugar \
|
||||||
tests
|
tests
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ jobs:
|
|||||||
--timeout=9 \
|
--timeout=9 \
|
||||||
--durations=10 \
|
--durations=10 \
|
||||||
-n auto \
|
-n auto \
|
||||||
--cov custom_components.octopusenergy \
|
--cov custom_components.integration_blueprint \
|
||||||
-o console_output_style=count \
|
-o console_output_style=count \
|
||||||
-p no:sugar \
|
-p no:sugar \
|
||||||
tests
|
tests
|
||||||
@@ -24,21 +24,21 @@ File | Purpose
|
|||||||
`.github/ISSUE_TEMPLATE/feature_request.md` | Template for Feature Requests
|
`.github/ISSUE_TEMPLATE/feature_request.md` | Template for Feature Requests
|
||||||
`.github/ISSUE_TEMPLATE/issue.md` | Template for issues
|
`.github/ISSUE_TEMPLATE/issue.md` | Template for issues
|
||||||
`.vscode/tasks.json` | Tasks for the devcontainer.
|
`.vscode/tasks.json` | Tasks for the devcontainer.
|
||||||
`custom_components/octopusenergy/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/octopusenergy/__init__.py` | The component file for the integration.
|
`custom_components/integration_blueprint/__init__.py` | The component file for the integration.
|
||||||
`custom_components/octopusenergy/api.py` | This is a sample API client.
|
`custom_components/integration_blueprint/api.py` | This is a sample API client.
|
||||||
`custom_components/octopusenergy/binary_sensor.py` | Binary sensor platform for the integration.
|
`custom_components/integration_blueprint/binary_sensor.py` | Binary sensor platform for the integration.
|
||||||
`custom_components/octopusenergy/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/octopusenergy/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/octopusenergy/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/octopusenergy/sensor.py` | Sensor platform for the integration.
|
`custom_components/integration_blueprint/sensor.py` | Sensor platform for the integration.
|
||||||
`custom_components/octopusenergy/switch.py` | Switch sensor platform for the integration.
|
`custom_components/integration_blueprint/switch.py` | Switch sensor platform for the integration.
|
||||||
`tests/__init__.py` | Makes the `tests` folder a module.
|
`tests/__init__.py` | Makes the `tests` folder a module.
|
||||||
`tests/conftest.py` | Global [fixtures](https://docs.pytest.org/en/stable/fixture.html) used in tests to [patch](https://docs.python.org/3/library/unittest.mock.html#unittest.mock.patch) functions.
|
`tests/conftest.py` | Global [fixtures](https://docs.pytest.org/en/stable/fixture.html) used in tests to [patch](https://docs.python.org/3/library/unittest.mock.html#unittest.mock.patch) functions.
|
||||||
`tests/test_api.py` | Tests for `custom_components/octopusenergy/api.py`.
|
`tests/test_api.py` | Tests for `custom_components/integration_blueprint/api.py`.
|
||||||
`tests/test_config_flow.py` | Tests for `custom_components/octopusenergy/config_flow.py`.
|
`tests/test_config_flow.py` | Tests for `custom_components/integration_blueprint/config_flow.py`.
|
||||||
`tests/test_init.py` | Tests for `custom_components/octopusenergy/__init__.py`.
|
`tests/test_init.py` | Tests for `custom_components/integration_blueprint/__init__.py`.
|
||||||
`tests/test_switch.py` | Tests for `custom_components/octopusenergy/switch.py`.
|
`tests/test_switch.py` | Tests for `custom_components/integration_blueprint/switch.py`.
|
||||||
`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]).
|
||||||
@@ -72,7 +72,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:
|
||||||
***
|
***
|
||||||
|
|
||||||
# octopusenergy
|
# integration_blueprint
|
||||||
|
|
||||||
[![GitHub Release][releases-shield]][releases]
|
[![GitHub Release][releases-shield]][releases]
|
||||||
[![GitHub Activity][commits-shield]][commits]
|
[![GitHub Activity][commits-shield]][commits]
|
||||||
@@ -85,7 +85,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 [octopusenergy][octopusenergy]._
|
_Component to integrate with [integration_blueprint][integration_blueprint]._
|
||||||
|
|
||||||
**This component will set up the following platforms.**
|
**This component will set up the following platforms.**
|
||||||
|
|
||||||
@@ -101,8 +101,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 `octopusenergy`.
|
3. In the `custom_components` directory (folder) create a new folder called `integration_blueprint`.
|
||||||
4. Download _all_ the files from the `custom_components/octopusenergy/` 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 "Integration blueprint"
|
7. In the HA UI go to "Configuration" -> "Integrations" click "+" and search for "Integration blueprint"
|
||||||
@@ -110,17 +110,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/octopusenergy/translations/en.json
|
custom_components/integration_blueprint/translations/en.json
|
||||||
custom_components/octopusenergy/translations/nb.json
|
custom_components/integration_blueprint/translations/nb.json
|
||||||
custom_components/octopusenergy/translations/sensor.nb.json
|
custom_components/integration_blueprint/translations/sensor.nb.json
|
||||||
custom_components/octopusenergy/__init__.py
|
custom_components/integration_blueprint/__init__.py
|
||||||
custom_components/octopusenergy/api.py
|
custom_components/integration_blueprint/api.py
|
||||||
custom_components/octopusenergy/binary_sensor.py
|
custom_components/integration_blueprint/binary_sensor.py
|
||||||
custom_components/octopusenergy/config_flow.py
|
custom_components/integration_blueprint/config_flow.py
|
||||||
custom_components/octopusenergy/const.py
|
custom_components/integration_blueprint/const.py
|
||||||
custom_components/octopusenergy/manifest.json
|
custom_components/integration_blueprint/manifest.json
|
||||||
custom_components/octopusenergy/sensor.py
|
custom_components/integration_blueprint/sensor.py
|
||||||
custom_components/octopusenergy/switch.py
|
custom_components/integration_blueprint/switch.py
|
||||||
```
|
```
|
||||||
|
|
||||||
## Configuration is done in the UI
|
## Configuration is done in the UI
|
||||||
@@ -133,11 +133,11 @@ If you want to contribute to this please read the [Contribution guidelines](CONT
|
|||||||
|
|
||||||
***
|
***
|
||||||
|
|
||||||
[octopusenergy]: https://github.com/custom-components/octopusenergy
|
[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/octopusenergy/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
|
||||||
@@ -148,4 +148,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/octopusenergy/releases
|
[releases]: https://github.com/custom-components/integration_blueprint/releases
|
||||||
|
|||||||
+5
-5
@@ -1,8 +1,8 @@
|
|||||||
"""
|
"""
|
||||||
Custom integration to integrate octopusenergy 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/octopusenergy
|
https://github.com/custom-components/integration_blueprint
|
||||||
"""
|
"""
|
||||||
import asyncio
|
import asyncio
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
@@ -14,7 +14,7 @@ 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 OctopusEnergyApiClient
|
from .api import IntegrationBlueprintApiClient
|
||||||
|
|
||||||
from .const import (
|
from .const import (
|
||||||
CONF_PASSWORD,
|
CONF_PASSWORD,
|
||||||
@@ -44,7 +44,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
|
|||||||
password = entry.data.get(CONF_PASSWORD)
|
password = entry.data.get(CONF_PASSWORD)
|
||||||
|
|
||||||
session = async_get_clientsession(hass)
|
session = async_get_clientsession(hass)
|
||||||
client = OctopusEnergyApiClient(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()
|
||||||
@@ -69,7 +69,7 @@ class BlueprintDataUpdateCoordinator(DataUpdateCoordinator):
|
|||||||
"""Class to manage fetching data from the API."""
|
"""Class to manage fetching data from the API."""
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self, hass: HomeAssistant, client: OctopusEnergyApiClient
|
self, hass: HomeAssistant, client: IntegrationBlueprintApiClient
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Initialize."""
|
"""Initialize."""
|
||||||
self.api = client
|
self.api = client
|
||||||
+1
-1
@@ -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 OctopusEnergyApiClient:
|
class IntegrationBlueprintApiClient:
|
||||||
def __init__(
|
def __init__(
|
||||||
self, username: str, password: str, session: aiohttp.ClientSession
|
self, username: str, password: str, session: aiohttp.ClientSession
|
||||||
) -> None:
|
) -> None:
|
||||||
+5
-5
@@ -1,4 +1,4 @@
|
|||||||
"""Binary sensor platform for octopusenergy."""
|
"""Binary sensor platform for integration_blueprint."""
|
||||||
from homeassistant.components.binary_sensor import BinarySensorEntity
|
from homeassistant.components.binary_sensor import BinarySensorEntity
|
||||||
|
|
||||||
from .const import (
|
from .const import (
|
||||||
@@ -7,17 +7,17 @@ from .const import (
|
|||||||
DEFAULT_NAME,
|
DEFAULT_NAME,
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
)
|
)
|
||||||
from .entity import OctopusEnergyEntity
|
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([OctopusEnergyBinarySensor(coordinator, entry)])
|
async_add_devices([IntegrationBlueprintBinarySensor(coordinator, entry)])
|
||||||
|
|
||||||
|
|
||||||
class OctopusEnergyBinarySensor(OctopusEnergyEntity, BinarySensorEntity):
|
class IntegrationBlueprintBinarySensor(IntegrationBlueprintEntity, BinarySensorEntity):
|
||||||
"""octopusenergy binary_sensor class."""
|
"""integration_blueprint binary_sensor class."""
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
+2
-2
@@ -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 OctopusEnergyApiClient
|
from .api import IntegrationBlueprintApiClient
|
||||||
from .const import (
|
from .const import (
|
||||||
CONF_PASSWORD,
|
CONF_PASSWORD,
|
||||||
CONF_USERNAME,
|
CONF_USERNAME,
|
||||||
@@ -73,7 +73,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 = OctopusEnergyApiClient(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
|
||||||
+3
-3
@@ -1,11 +1,11 @@
|
|||||||
"""Constants for octopusenergy."""
|
"""Constants for integration_blueprint."""
|
||||||
# Base component constants
|
# Base component constants
|
||||||
NAME = "Integration blueprint"
|
NAME = "Integration blueprint"
|
||||||
DOMAIN = "octopusenergy"
|
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/octopusenergy/issues"
|
ISSUE_URL = "https://github.com/custom-components/integration_blueprint/issues"
|
||||||
|
|
||||||
# Icons
|
# Icons
|
||||||
ICON = "mdi:format-quote-close"
|
ICON = "mdi:format-quote-close"
|
||||||
+1
-1
@@ -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 OctopusEnergyEntity(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
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
{
|
||||||
|
"domain": "integration_blueprint",
|
||||||
|
"name": "Integration blueprint",
|
||||||
|
"documentation": "https://github.com/custom-components/integration_blueprint",
|
||||||
|
"iot_class": "cloud_polling",
|
||||||
|
"issue_tracker": "https://github.com/custom-components/integration_blueprint/issues",
|
||||||
|
"version": "0.0.0",
|
||||||
|
"config_flow": true,
|
||||||
|
"codeowners": [
|
||||||
|
"@ludeeus"
|
||||||
|
]
|
||||||
|
}
|
||||||
+5
-5
@@ -1,16 +1,16 @@
|
|||||||
"""Sensor platform for octopusenergy."""
|
"""Sensor platform for integration_blueprint."""
|
||||||
from .const import DEFAULT_NAME, DOMAIN, ICON, SENSOR
|
from .const import DEFAULT_NAME, DOMAIN, ICON, SENSOR
|
||||||
from .entity import OctopusEnergyEntity
|
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([OctopusEnergySensor(coordinator, entry)])
|
async_add_devices([IntegrationBlueprintSensor(coordinator, entry)])
|
||||||
|
|
||||||
|
|
||||||
class OctopusEnergySensor(OctopusEnergyEntity):
|
class IntegrationBlueprintSensor(IntegrationBlueprintEntity):
|
||||||
"""octopusenergy Sensor class."""
|
"""integration_blueprint Sensor class."""
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
+5
-5
@@ -1,18 +1,18 @@
|
|||||||
"""Switch platform for octopusenergy."""
|
"""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 OctopusEnergyEntity
|
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([OctopusEnergyBinarySwitch(coordinator, entry)])
|
async_add_devices([IntegrationBlueprintBinarySwitch(coordinator, entry)])
|
||||||
|
|
||||||
|
|
||||||
class OctopusEnergyBinarySwitch(OctopusEnergyEntity, SwitchEntity):
|
class IntegrationBlueprintBinarySwitch(IntegrationBlueprintEntity, SwitchEntity):
|
||||||
"""octopusenergy 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."""
|
||||||
+1
-1
@@ -3,7 +3,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/octopusenergy",
|
"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"
|
||||||
+1
-1
@@ -3,7 +3,7 @@
|
|||||||
"step": {
|
"step": {
|
||||||
"user": {
|
"user": {
|
||||||
"title": "Blueprint",
|
"title": "Blueprint",
|
||||||
"description": "Si vous avez besoin d'aide pour la configuration, regardez ici: https://github.com/custom-components/octopusenergy",
|
"description": "Si vous avez besoin d'aide pour la configuration, regardez ici: https://github.com/custom-components/integration_blueprint",
|
||||||
"data": {
|
"data": {
|
||||||
"username": "Identifiant",
|
"username": "Identifiant",
|
||||||
"password": "Mot de Passe"
|
"password": "Mot de Passe"
|
||||||
+1
-1
@@ -3,7 +3,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/octopusenergy",
|
"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"
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
{
|
|
||||||
"domain": "octopusenergy",
|
|
||||||
"name": "Integration blueprint",
|
|
||||||
"documentation": "https://github.com/custom-components/octopusenergy",
|
|
||||||
"iot_class": "cloud_polling",
|
|
||||||
"issue_tracker": "https://github.com/custom-components/octopusenergy/issues",
|
|
||||||
"version": "0.0.0",
|
|
||||||
"config_flow": true,
|
|
||||||
"codeowners": [
|
|
||||||
"@ludeeus"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
@@ -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 [octopusenergy][octopusenergy]._
|
_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
|
|||||||
|
|
||||||
***
|
***
|
||||||
|
|
||||||
[octopusenergy]: https://github.com/custom-components/octopusenergy
|
[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/octopusenergy.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/octopusenergy/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/octopusenergy/blob/main/LICENSE
|
[license]: https://github.com/custom-components/integration_blueprint/blob/main/LICENSE
|
||||||
[license-shield]: https://img.shields.io/github/license/custom-components/octopusenergy.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/octopusenergy.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/octopusenergy/releases
|
[releases]: https://github.com/custom-components/integration_blueprint/releases
|
||||||
[user_profile]: https://github.com/ludeeus
|
[user_profile]: https://github.com/ludeeus
|
||||||
|
|||||||
@@ -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.octopusenergy, tests
|
known_first_party = custom_components.integration_blueprint, tests
|
||||||
combine_as_imports = true
|
combine_as_imports = true
|
||||||
|
|||||||
+1
-1
@@ -20,5 +20,5 @@ This will install `homeassistant`, `pytest`, and `pytest-homeassistant-custom-co
|
|||||||
Command | Description
|
Command | Description
|
||||||
------- | -----------
|
------- | -----------
|
||||||
`pytest tests/` | This will run all tests in `tests/` and tell you how many passed/failed
|
`pytest tests/` | This will run all tests in `tests/` and tell you how many passed/failed
|
||||||
`pytest --durations=10 --cov-report term-missing --cov=custom_components.octopusenergy tests` | This tells `pytest` that your target module to test is `custom_components.octopusenergy` so that it can give you a [code coverage](https://en.wikipedia.org/wiki/Code_coverage) summary, including % of code that was executed and the line numbers of missed executions.
|
`pytest --durations=10 --cov-report term-missing --cov=custom_components.integration_blueprint tests` | This tells `pytest` that your target module to test is `custom_components.integration_blueprint` so that it can give you a [code coverage](https://en.wikipedia.org/wiki/Code_coverage) summary, including % of code that was executed and the line numbers of missed executions.
|
||||||
`pytest tests/test_init.py -k test_setup_unload_and_reload_entry` | Runs the `test_setup_unload_and_reload_entry` test function located in `tests/test_init.py`
|
`pytest tests/test_init.py -k test_setup_unload_and_reload_entry` | Runs the `test_setup_unload_and_reload_entry` test function located in `tests/test_init.py`
|
||||||
|
|||||||
+1
-1
@@ -1 +1 @@
|
|||||||
"""Tests for octopusenergy integration."""
|
"""Tests for integration_blueprint integration."""
|
||||||
|
|||||||
+3
-3
@@ -1,4 +1,4 @@
|
|||||||
"""Global fixtures for octopusenergy integration."""
|
"""Global fixtures for integration_blueprint integration."""
|
||||||
# Fixtures allow you to replace functions with a Mock object. You can perform
|
# Fixtures allow you to replace functions with a Mock object. You can perform
|
||||||
# many options via the Mock to reflect a particular behavior from the original
|
# many options via the Mock to reflect a particular behavior from the original
|
||||||
# function that you want to see without going through the function's actual logic.
|
# function that you want to see without going through the function's actual logic.
|
||||||
@@ -46,7 +46,7 @@ def skip_notifications_fixture():
|
|||||||
def bypass_get_data_fixture():
|
def bypass_get_data_fixture():
|
||||||
"""Skip calls to get data from API."""
|
"""Skip calls to get data from API."""
|
||||||
with patch(
|
with patch(
|
||||||
"custom_components.octopusenergy.OctopusEnergyApiClient.async_get_data"
|
"custom_components.integration_blueprint.IntegrationBlueprintApiClient.async_get_data"
|
||||||
):
|
):
|
||||||
yield
|
yield
|
||||||
|
|
||||||
@@ -57,7 +57,7 @@ def bypass_get_data_fixture():
|
|||||||
def error_get_data_fixture():
|
def error_get_data_fixture():
|
||||||
"""Simulate error when retrieving data from API."""
|
"""Simulate error when retrieving data from API."""
|
||||||
with patch(
|
with patch(
|
||||||
"custom_components.octopusenergy.OctopusEnergyApiClient.async_get_data",
|
"custom_components.integration_blueprint.IntegrationBlueprintApiClient.async_get_data",
|
||||||
side_effect=Exception,
|
side_effect=Exception,
|
||||||
):
|
):
|
||||||
yield
|
yield
|
||||||
|
|||||||
+2
-2
@@ -1,5 +1,5 @@
|
|||||||
"""Constants for octopusenergy tests."""
|
"""Constants for integration_blueprint tests."""
|
||||||
from custom_components.octopusenergy.const import CONF_PASSWORD, CONF_USERNAME
|
from custom_components.integration_blueprint.const import CONF_PASSWORD, CONF_USERNAME
|
||||||
|
|
||||||
# Mock config data to be used across multiple tests
|
# Mock config data to be used across multiple tests
|
||||||
MOCK_CONFIG = {CONF_USERNAME: "test_username", CONF_PASSWORD: "test_password"}
|
MOCK_CONFIG = {CONF_USERNAME: "test_username", CONF_PASSWORD: "test_password"}
|
||||||
|
|||||||
+3
-3
@@ -1,17 +1,17 @@
|
|||||||
"""Tests for octopusenergy api."""
|
"""Tests for integration_blueprint api."""
|
||||||
import asyncio
|
import asyncio
|
||||||
|
|
||||||
import aiohttp
|
import aiohttp
|
||||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||||
|
|
||||||
from custom_components.octopusenergy.api import OctopusEnergyApiClient
|
from custom_components.integration_blueprint.api import IntegrationBlueprintApiClient
|
||||||
|
|
||||||
|
|
||||||
async def test_api(hass, aioclient_mock, caplog):
|
async def test_api(hass, aioclient_mock, caplog):
|
||||||
"""Test API calls."""
|
"""Test API calls."""
|
||||||
|
|
||||||
# To test the api submodule, we first create an instance of our API client
|
# To test the api submodule, we first create an instance of our API client
|
||||||
api = OctopusEnergyApiClient("test", "test", async_get_clientsession(hass))
|
api = IntegrationBlueprintApiClient("test", "test", async_get_clientsession(hass))
|
||||||
|
|
||||||
# Use aioclient_mock which is provided by `pytest_homeassistant_custom_components`
|
# Use aioclient_mock which is provided by `pytest_homeassistant_custom_components`
|
||||||
# to mock responses to aiohttp requests. In this case we are telling the mock to
|
# to mock responses to aiohttp requests. In this case we are telling the mock to
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
"""Test octopusenergy config flow."""
|
"""Test integration_blueprint config flow."""
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
|
|
||||||
from homeassistant import config_entries, data_entry_flow
|
from homeassistant import config_entries, data_entry_flow
|
||||||
import pytest
|
import pytest
|
||||||
from pytest_homeassistant_custom_component.common import MockConfigEntry
|
from pytest_homeassistant_custom_component.common import MockConfigEntry
|
||||||
|
|
||||||
from custom_components.octopusenergy.const import (
|
from custom_components.integration_blueprint.const import (
|
||||||
BINARY_SENSOR,
|
BINARY_SENSOR,
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
PLATFORMS,
|
PLATFORMS,
|
||||||
@@ -23,10 +23,10 @@ from .const import MOCK_CONFIG
|
|||||||
def bypass_setup_fixture():
|
def bypass_setup_fixture():
|
||||||
"""Prevent setup."""
|
"""Prevent setup."""
|
||||||
with patch(
|
with patch(
|
||||||
"custom_components.octopusenergy.async_setup",
|
"custom_components.integration_blueprint.async_setup",
|
||||||
return_value=True,
|
return_value=True,
|
||||||
), patch(
|
), patch(
|
||||||
"custom_components.octopusenergy.async_setup_entry",
|
"custom_components.integration_blueprint.async_setup_entry",
|
||||||
return_value=True,
|
return_value=True,
|
||||||
):
|
):
|
||||||
yield
|
yield
|
||||||
|
|||||||
+4
-4
@@ -1,15 +1,15 @@
|
|||||||
"""Test octopusenergy setup process."""
|
"""Test integration_blueprint setup process."""
|
||||||
from homeassistant.exceptions import ConfigEntryNotReady
|
from homeassistant.exceptions import ConfigEntryNotReady
|
||||||
import pytest
|
import pytest
|
||||||
from pytest_homeassistant_custom_component.common import MockConfigEntry
|
from pytest_homeassistant_custom_component.common import MockConfigEntry
|
||||||
|
|
||||||
from custom_components.octopusenergy import (
|
from custom_components.integration_blueprint import (
|
||||||
BlueprintDataUpdateCoordinator,
|
BlueprintDataUpdateCoordinator,
|
||||||
async_reload_entry,
|
async_reload_entry,
|
||||||
async_setup_entry,
|
async_setup_entry,
|
||||||
async_unload_entry,
|
async_unload_entry,
|
||||||
)
|
)
|
||||||
from custom_components.octopusenergy.const import DOMAIN
|
from custom_components.integration_blueprint.const import DOMAIN
|
||||||
|
|
||||||
from .const import MOCK_CONFIG
|
from .const import MOCK_CONFIG
|
||||||
|
|
||||||
@@ -26,7 +26,7 @@ async def test_setup_unload_and_reload_entry(hass, bypass_get_data):
|
|||||||
|
|
||||||
# Set up the entry and assert that the values set during setup are where we expect
|
# Set up the entry and assert that the values set during setup are where we expect
|
||||||
# them to be. Because we have patched the BlueprintDataUpdateCoordinator.async_get_data
|
# them to be. Because we have patched the BlueprintDataUpdateCoordinator.async_get_data
|
||||||
# call, no code from custom_components/octopusenergy/api.py actually runs.
|
# call, no code from custom_components/integration_blueprint/api.py actually runs.
|
||||||
assert await async_setup_entry(hass, config_entry)
|
assert await async_setup_entry(hass, config_entry)
|
||||||
assert DOMAIN in hass.data and config_entry.entry_id in hass.data[DOMAIN]
|
assert DOMAIN in hass.data and config_entry.entry_id in hass.data[DOMAIN]
|
||||||
assert (
|
assert (
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
"""Test octopusenergy switch."""
|
"""Test integration_blueprint switch."""
|
||||||
from unittest.mock import call, patch
|
from unittest.mock import call, patch
|
||||||
|
|
||||||
from homeassistant.components.switch import SERVICE_TURN_OFF, SERVICE_TURN_ON
|
from homeassistant.components.switch import SERVICE_TURN_OFF, SERVICE_TURN_ON
|
||||||
from homeassistant.const import ATTR_ENTITY_ID
|
from homeassistant.const import ATTR_ENTITY_ID
|
||||||
from pytest_homeassistant_custom_component.common import MockConfigEntry
|
from pytest_homeassistant_custom_component.common import MockConfigEntry
|
||||||
|
|
||||||
from custom_components.octopusenergy import async_setup_entry
|
from custom_components.integration_blueprint import async_setup_entry
|
||||||
from custom_components.octopusenergy.const import DEFAULT_NAME, DOMAIN, SWITCH
|
from custom_components.integration_blueprint.const import DEFAULT_NAME, DOMAIN, SWITCH
|
||||||
|
|
||||||
from .const import MOCK_CONFIG
|
from .const import MOCK_CONFIG
|
||||||
|
|
||||||
@@ -21,7 +21,7 @@ async def test_switch_services(hass):
|
|||||||
# Functions/objects can be patched directly in test code as well and can be used to test
|
# Functions/objects can be patched directly in test code as well and can be used to test
|
||||||
# additional things, like whether a function was called or what arguments it was called with
|
# additional things, like whether a function was called or what arguments it was called with
|
||||||
with patch(
|
with patch(
|
||||||
"custom_components.octopusenergy.OctopusEnergyApiClient.async_set_title"
|
"custom_components.integration_blueprint.IntegrationBlueprintApiClient.async_set_title"
|
||||||
) as title_func:
|
) as title_func:
|
||||||
await hass.services.async_call(
|
await hass.services.async_call(
|
||||||
SWITCH,
|
SWITCH,
|
||||||
|
|||||||
Reference in New Issue
Block a user