Skip to content

Commit

Permalink
fix: bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
acesyde committed Sep 3, 2023
1 parent 3672af7 commit f6dd288
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 27 deletions.
7 changes: 5 additions & 2 deletions README.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,16 @@ English
|-------------------|--------------|------|--------------------|
| `sensor.total_m3` | Number of m3 | m3 | :white_check_mark: |

> [!NOTE]
> Data is updated every 24h.
## Installation

## Automatic
### 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
### 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.
Expand Down
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,16 @@ Français |
|-------------------|-----------------------|------|--------------------|
| `sensor.total_m3` | Nombre de m3 consommé | m3 | :white_check_mark: |

> [!NOTE]
> Les données sont mises à jour toutes les 24h.
## Installation

## Automatique
### Automatique

[![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)

## Manuelle
### Manuelle

1. À l'aide de l'outil de votre choix, ouvrez le répertoire (dossier) de votre configuration HA (où vous
trouvez `configuration.yaml`).
Expand Down
2 changes: 1 addition & 1 deletion custom_components/eau_agur/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
NAME = "EAU par Agur"
DOMAIN = "eau_agur"
PLATFORMS = [Platform.SENSOR]
VERSION = "0.0.1"
VERSION = "0.0.2"
COORDINATOR = "coordinator"
ATTRIBUTION = "Data provided by https://www.agur.fr/"
SCAN_INTERVAL_IN_MINUTES = 60 * 6 # 6 hours
Expand Down
2 changes: 1 addition & 1 deletion custom_components/eau_agur/coordinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ async def _async_update_data(self) -> dict[str, Any]:
await self._api_client.login(self._email, self._password)

# Get the consumption data
result = {"consumption": await self._api_client.get_consumption(self._contract_number) / 1000}
result = {"consumption": await self._api_client.get_consumption(self._contract_number)}

return result

Expand Down
2 changes: 1 addition & 1 deletion custom_components/eau_agur/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
"documentation": "https://github.com/acesyde/hassio_agur_integration",
"iot_class": "cloud_polling",
"issue_tracker": "https://github.com/acesyde/hassio_agur_integration/issues",
"version": "0.0.1"
"version": "0.0.2"
}
9 changes: 8 additions & 1 deletion custom_components/eau_agur/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ class EauAgurEntityDescription(
"""Describes Eau par Agur sensor entity."""


def read_consumption(data: dict[str, Any]):
consumption = data["consumption"]
if consumption is not None and consumption >= 0:
return consumption / 1000
return None


SENSORS = [
EauAgurEntityDescription(
key="total_m3",
Expand All @@ -37,7 +44,7 @@ class EauAgurEntityDescription(
native_unit_of_measurement=UnitOfVolume.CUBIC_METERS,
device_class=SensorDeviceClass.WATER,
state_class=SensorStateClass.TOTAL_INCREASING,
value_fn=lambda data: data["consumption"] or None,
value_fn=read_consumption,
)
]

Expand Down
36 changes: 18 additions & 18 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "eau_agur"
version = "0.0.6"
version = "0.0.2"
description = "EAU par Agur integration for Home Assistant"
authors = ["Pierre-Emmanuel Mercier <acesyde@gmail.com>"]
license = "MIT"
Expand Down

0 comments on commit f6dd288

Please sign in to comment.