Skip to content

Commit

Permalink
Merging 'blueprint/main' into 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
Limych committed Jan 4, 2025
2 parents ace665c + 4e4be70 commit 6f1e989
Show file tree
Hide file tree
Showing 12 changed files with 44 additions and 51 deletions.
10 changes: 9 additions & 1 deletion .devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,13 @@
}
},
"remoteUser": "vscode",
"features": {}
"features": {
"ghcr.io/devcontainers-extra/features/apt-packages:1": {
"packages": [
"ffmpeg",
"libturbojpeg0",
"libpcap-dev"
]
}
}
}
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ body:
- type: textarea
attributes:
label: "Debug logs"
description: "To enable debug logs check this https://www.home-assistant.io/integrations/logger/, this **needs** to install _everything_ from startup of Home Assistant to the point where you encounter the issue."
description: "To enable debug logs check this https://www.home-assistant.io/integrations/logger/, this **needs** to include _everything_ from startup of Home Assistant to the point where you encounter the issue."
render: text
validations:
required: true
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
runs-on: "ubuntu-latest"
steps:
- name: "Checkout the repository"
uses: "actions/checkout@v4.1.7"
uses: "actions/checkout@v4.2.2"

- name: "Run hassfest validation"
uses: "home-assistant/actions/hassfest@master"
Expand All @@ -27,7 +27,7 @@ jobs:
runs-on: "ubuntu-latest"
steps:
- name: "Checkout the repository"
uses: "actions/checkout@v4.1.7"
uses: "actions/checkout@v4.2.2"

- name: "Run HACS validation"
uses: "hacs/action@main"
Expand Down
11 changes: 0 additions & 11 deletions .vscode/tasks.json

This file was deleted.

1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ File | Purpose | Documentation
-- | -- | --
`.devcontainer.json` | Used for development/testing with Visual Studio Code. | [Documentation](https://code.visualstudio.com/docs/remote/containers)
`.github/ISSUE_TEMPLATE/*.yml` | Templates for the issue tracker | [Documentation](https://help.github.com/en/github/building-a-strong-community/configuring-issue-templates-for-your-repository)
`.vscode/tasks.json` | Tasks for the devcontainer. | [Documentation](https://code.visualstudio.com/docs/editor/tasks)
`custom_components/integration_blueprint/*` | Integration files, this is where everything happens. | [Documentation](https://developers.home-assistant.io/docs/creating_component_index)
`tests/*` | Integration unit tests. |
`CONTRIBUTING.md` | Guidelines on how to contribute. | [Documentation](https://help.github.com/en/github/building-a-strong-community/setting-guidelines-for-repository-contributors)
Expand Down
5 changes: 5 additions & 0 deletions custom_components/integration_blueprint/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@

from __future__ import annotations

from datetime import timedelta
from typing import TYPE_CHECKING

from homeassistant.const import CONF_PASSWORD, CONF_USERNAME, Platform
from homeassistant.helpers.aiohttp_client import async_get_clientsession
from homeassistant.loader import async_get_loaded_integration

from .api import IntegrationBlueprintApiClient
from .const import DOMAIN, LOGGER
from .coordinator import BlueprintDataUpdateCoordinator
from .data import IntegrationBlueprintData

Expand All @@ -37,6 +39,9 @@ async def async_setup_entry(
"""Set up this integration using UI."""
coordinator = BlueprintDataUpdateCoordinator(
hass=hass,
logger=LOGGER,
name=DOMAIN,
update_interval=timedelta(hours=1),
)
entry.runtime_data = IntegrationBlueprintData(
client=IntegrationBlueprintApiClient(
Expand Down
12 changes: 10 additions & 2 deletions custom_components/integration_blueprint/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
from __future__ import annotations

import voluptuous as vol
from homeassistant import config_entries, data_entry_flow
from homeassistant import config_entries
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
from homeassistant.helpers import selector
from homeassistant.helpers.aiohttp_client import async_create_clientsession
from slugify import slugify

from .api import (
IntegrationBlueprintApiClient,
Expand All @@ -25,7 +26,7 @@ class BlueprintFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_user(
self,
user_input: dict | None = None,
) -> data_entry_flow.FlowResult:
) -> config_entries.ConfigFlowResult:
"""Handle a flow initialized by the user."""
_errors = {}
if user_input is not None:
Expand All @@ -44,6 +45,13 @@ async def async_step_user(
LOGGER.exception(exception)
_errors["base"] = "unknown"
else:
await self.async_set_unique_id(
## Do NOT use this in production code
## The unique_id should never be something that can change
## https://developers.home-assistant.io/docs/config_entries_config_flow_handler#unique-ids
unique_id=slugify(user_input[CONF_USERNAME])
)
self._abort_if_unique_id_configured()
return self.async_create_entry(
title=user_input[CONF_USERNAME],
data=user_input,
Expand Down
16 changes: 0 additions & 16 deletions custom_components/integration_blueprint/coordinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

from __future__ import annotations

from datetime import timedelta
from typing import TYPE_CHECKING, Any

from homeassistant.exceptions import ConfigEntryAuthFailed
Expand All @@ -12,11 +11,8 @@
IntegrationBlueprintApiClientAuthenticationError,
IntegrationBlueprintApiClientError,
)
from .const import DOMAIN, LOGGER

if TYPE_CHECKING:
from homeassistant.core import HomeAssistant

from .data import IntegrationBlueprintConfigEntry


Expand All @@ -26,18 +22,6 @@ class BlueprintDataUpdateCoordinator(DataUpdateCoordinator):

config_entry: IntegrationBlueprintConfigEntry

def __init__(
self,
hass: HomeAssistant,
) -> None:
"""Initialize."""
super().__init__(
hass=hass,
logger=LOGGER,
name=DOMAIN,
update_interval=timedelta(hours=1),
)

async def _async_update_data(self) -> Any:
"""Update data via library."""
try:
Expand Down
26 changes: 11 additions & 15 deletions custom_components/integration_blueprint/manifest.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
{
"domain": "integration_blueprint",
"name": "Integration blueprint",
"codeowners": [
"@Limych"
],
"config_flow": true,
"dependencies": [],
"documentation": "https://github.com/Limych/ha-blueprint",
"iot_class": "cloud_polling",
"issue_tracker": "https://github.com/Limych/ha-blueprint/issues",
"requirements": [
"pip>=21.3.1"
],
"version": "0.0.0"
}
"domain": "integration_blueprint",
"name": "Integration blueprint",
"codeowners": [
"@ludeeus"
],
"config_flow": true,
"documentation": "https://github.com/ludeeus/integration_blueprint",
"iot_class": "cloud_polling",
"issue_tracker": "https://github.com/ludeeus/integration_blueprint/issues",
"version": "0.1.0"
}
3 changes: 3 additions & 0 deletions custom_components/integration_blueprint/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
"auth": "Username/Password is wrong.",
"connection": "Unable to connect to the server.",
"unknown": "Unknown error occurred."
},
"abort": {
"already_configured": "This entry is already configured."
}
}
}
3 changes: 2 additions & 1 deletion hacs.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "Integration blueprint",
"hide_default_branch": true,
"homeassistant": "2024.6.0",
"homeassistant": "2024.12.0",
"hacs": "2.0.1",
"render_readme": true
}
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
homeassistant>=2024.6.0
homeassistant>=2024.11.0
pip>=21.3.1

0 comments on commit 6f1e989

Please sign in to comment.