Skip to content

Commit

Permalink
feat: first version (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
acesyde committed Sep 2, 2023
1 parent 63ec7e8 commit 3672af7
Show file tree
Hide file tree
Showing 27 changed files with 1,090 additions and 195 deletions.
18 changes: 13 additions & 5 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
root = true

[*]
charset = utf-8
end_of_line = lf
indent_style = space
indent_size = 4
insert_final_newline = true
trim_trailing_whitespace = true
ident_size = 4

[*.py]
max_line_length = 120
[*.md]
ident_size = 2
trim_trailing_whitespace = false

[*.yml]
indent_size = 2
[*.json]
ident_size = 2

[{.gitignore,.gitkeep,.editorconfig}]
ident_size = 2
8 changes: 4 additions & 4 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,17 @@ jobs:

steps:
- name: 📥 Checkout the repository
uses: actions/checkout@v3.3.0
uses: actions/checkout@v3
with:
fetch-depth: 2

- name: 🔁 Initialize CodeQL
uses: github/codeql-action/init@v2.21.4
uses: github/codeql-action/init@v2
with:
languages: python

- name: 🛠️ Autobuild
uses: github/codeql-action/autobuild@v2.21.4
uses: github/codeql-action/autobuild@v2

- name: 🏃 Run CodeQL Analysis
uses: github/codeql-action/analyze@v2.21.4
uses: github/codeql-action/analyze@v2
10 changes: 5 additions & 5 deletions .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,15 @@ jobs:
cache: 'poetry'

- name: 📦 Install requirements
run: task install
run: task poetry-install

- name: 🏃 Run tests
env:
PYTEST: true
run: task tests

- name: 📤 Upload coverage to Codecov
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
if: ${{ matrix.python_version == '3.11' }}
run: |
task coverage
curl -sfSL https://codecov.io/bash | bash -
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
2 changes: 2 additions & 0 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,5 @@ jobs:
uses: "hacs/action@main"
with:
category: "integration"
# Remove this 'ignore' key when you have added brand images for your integration to https://github.com/home-assistant/brands
ignore: "brands"
62 changes: 31 additions & 31 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
repos:
- repo: https://github.com/commitizen-tools/commitizen
rev: 3.6.0
hooks:
- id: commitizen
- id: commitizen-branch
stages: [ push ]
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.0.284
hooks:
- id: ruff
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: no-commit-to-branch
args:
- --branch=main
- repo: local
hooks:
- id: test
name: test
entry: task tests
language: system
types:
- python
pass_filenames: false
- repo: https://github.com/commitizen-tools/commitizen
rev: 3.7.0
hooks:
- id: commitizen
- id: commitizen-branch
stages: [ push ]
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.0.286
hooks:
- id: ruff
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: no-commit-to-branch
args:
- --branch=main
- repo: local
hooks:
- id: test
name: test
entry: task tests
language: system
types:
- python
pass_filenames: false
62 changes: 62 additions & 0 deletions README.en.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# EAU par Agur

[![GitHub Release][releases-shield]][releases]
[![GitHub Activity][commits-shield]][commits]
[![License][license-shield]](LICENSE)

[![hacs][hacsbadge]][hacs]
![Project Maintenance][maintenance-shield]

_Integration to integrate with [EAU par Agur][eau_agur]._

🌏
[**Français**](README.md) |
English

**This integration will set up the following platforms.**

| Platform | Description | Unit | Implemented |
|-------------------|--------------|------|--------------------|
| `sensor.total_m3` | Number of m3 | m3 | :white_check_mark: |

## Installation

## Automatic

[![Open your Home Assistant instance and open a repository inside the Home Assistant Community Store.](https://my.home-assistant.io/badges/hacs_repository.svg)](https://my.home-assistant.io/redirect/hacs_repository/?owner=acesyde&repository=hassio_agur_integration&category=integration)

## Manual

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.
3In the `custom_components` directory (folder) create a new folder called `eau_agur`.
3. Download _all_ the files from the `custom_components/eau_agur/` directory (folder) in this repository.
4. Place the files you downloaded in the new directory (folder) you created.
5. Restart Home Assistant
6. In the HA UI go to "Configuration" -> "Integrations" click "+" and search for "EAU par Agur"

## Configuration is done in the UI

## Contributions are welcome!

If you want to contribute to this please read the [Contribution guidelines](CONTRIBUTING.md)

***

[eau_agur]: https://www.agur.fr/

[commits-shield]: https://img.shields.io/github/commit-activity/y/acesyde/hassio_agur_integration.svg?style=for-the-badge

[commits]: https://github.com/acesyde/hassio_agur_integration/commits/main

[hacs]: https://github.com/hacs/integration

[hacsbadge]: https://img.shields.io/badge/HACS-Custom-orange.svg?style=for-the-badge

[license-shield]: https://img.shields.io/github/license/acesyde/hassio_agur_integration.svg?style=for-the-badge

[maintenance-shield]: https://img.shields.io/badge/maintainer-Pierre%20Emmanuel%20Mercier%20%40acesyde-blue.svg?style=for-the-badge

[releases-shield]: https://img.shields.io/github/release/acesyde/hassio_agur_integration.svg?style=for-the-badge

[releases]: https://github.com/acesyde/hassio_agur_integration/releases
42 changes: 23 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,35 +7,39 @@
[![hacs][hacsbadge]][hacs]
![Project Maintenance][maintenance-shield]

_Integration to integrate with [EAU par Agur][eau_agur]._
_Intégration pour [EAU par Agur][eau_agur]._

**This integration will set up the following platforms.**
🌏
Français |
[**English**](README.en.md)

| Platform | Description | Unit | Implemented |
| ------------- | ----------- | ---- | ------------------ |
| `sensor.xxxx` | xxxxx. | xxx | :white_check_mark: |
**L'intégration ajoutera les composants suivants.**

## Installation
| Platform | Description | Unit | Implemented |
|-------------------|-----------------------|------|--------------------|
| `sensor.total_m3` | Nombre de m3 consommé | m3 | :white_check_mark: |

## Automatic
## Installation

[![Open your Home Assistant instance and open a repository inside the Home Assistant Community Store.](https://my.home-assistant.io/badges/hacs_repository.svg)](https://my.home-assistant.io/redirect/hacs_repository/?owner=acesyde&repository=hassio_agur_integration&category=integration)
## Automatique

## Manual
[![Ouvrez votre instance Home Assistant et ajouter un dépôt personnalisé.](https://my.home-assistant.io/badges/hacs_repository.svg)](https://my.home-assistant.io/redirect/hacs_repository/?owner=acesyde&repository=hassio_agur_integration&category=integration)

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.
3In the `custom_components` directory (folder) create a new folder called `eau_agur`.
3. Download _all_ the files from the `custom_components/eau_agur/` directory (folder) in this repository.
4. Place the files you downloaded in the new directory (folder) you created.
5. Restart Home Assistant
6. In the HA UI go to "Configuration" -> "Integrations" click "+" and search for "EAU par Agur"
## Manuelle

## Configuration is done in the UI
1. À l'aide de l'outil de votre choix, ouvrez le répertoire (dossier) de votre configuration HA (où vous
trouvez `configuration.yaml`).
2. Si vous n'avez pas le répertoire `custom_components`, il vous faudra le créer.
3. Dans le répertoire `custom_components`, créez un nouveau dossier nommé `eau_agur`.
4. Téléchargez _tous_ les fichiers du répertoire (dossier) `custom_components/eau_agur/` dans ce référentiel.
5. Placez les fichiers que vous avez téléchargés dans le nouveau répertoire (dossier) que vous avez créé.
6. Redémarrer Home Assistant.
7. Dans l'interface utilisateur HA, allez dans "Configuration" -> "Intégrations", cliquez sur "+" et recherchez "EAU par
Agur".

## Contributions are welcome!
## Les contributions sont les bienvenues !

If you want to contribute to this please read the [Contribution guidelines](CONTRIBUTING.md)
Si vous souhaitez y contribuer, veuillez lire les [Directives de contribution](CONTRIBUTING.md)

***

Expand Down
42 changes: 42 additions & 0 deletions custom_components/eau_agur/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant
from homeassistant.helpers.aiohttp_client import async_get_clientsession

from .api import AgurApiClient
from .const import DOMAIN, PLATFORMS, COORDINATOR
from .coordinator import EauAgurDataUpdateCoordinator


async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Set up EAU par Agur from a config entry."""
session = async_get_clientsession(hass)
client = AgurApiClient(
session=session,
)

local_coordinator = EauAgurDataUpdateCoordinator(hass=hass, api_client=client, entry=entry)

hass.data.setdefault(DOMAIN, {})[entry.entry_id] = {COORDINATOR: local_coordinator}

# https://developers.home-assistant.io/docs/integration_fetching_data#coordinated-single-api-poll-for-data-for-all-entities
await local_coordinator.async_config_entry_first_refresh()

await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
entry.async_on_unload(entry.add_update_listener(async_reload_entry))

return True


async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Handle removal of an entry."""
if unloaded := await hass.config_entries.async_unload_platforms(
entry, PLATFORMS
):
hass.data[DOMAIN].pop(entry.entry_id)
return unloaded


async def async_reload_entry(hass: HomeAssistant, entry: ConfigEntry) -> None:
"""Reload config entry."""
await async_unload_entry(hass, entry)
await async_setup_entry(hass, entry)
5 changes: 5 additions & 0 deletions custom_components/eau_agur/api/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
"""Api package for EAU par Agur."""
from .agur_api_client import AgurApiClient
from .exceptions import AgurApiConnectionError, AgurApiError, AgurApiUnauthorizedError

__all__ = ["AgurApiClient", "AgurApiConnectionError", "AgurApiError", "AgurApiUnauthorizedError"]
Loading

0 comments on commit 3672af7

Please sign in to comment.