Skip to content

Commit

Permalink
feat: move to liters
Browse files Browse the repository at this point in the history
  • Loading branch information
acesyde committed Sep 4, 2023
1 parent a389bb5 commit bff56cd
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 20 deletions.
6 changes: 3 additions & 3 deletions README.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ English

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

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

> [!NOTE]
> Data is updated every 24h.
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ Français |

**L'intégration ajoutera les composants suivants.**

| Platform | Description | Unit | Implemented |
|-------------------|-----------------------|------|--------------------|
| `sensor.total_m3` | Nombre de m3 consommé | m3 | :white_check_mark: |
| Platform | Description | Unit | Implemented |
| --------------------- | -------------------------- | ---- | ------------------ |
| `sensor.total_liters` | Nombre de litres consommés | m3 | :white_check_mark: |

> [!NOTE]
> Les données sont mises à jour toutes les 24h.
Expand Down
4 changes: 2 additions & 2 deletions custom_components/eau_agur/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
NAME = "EAU par Agur"
DOMAIN = "eau_agur"
PLATFORMS = [Platform.SENSOR]
VERSION = "0.0.2"
VERSION = "0.0.3"
COORDINATOR = "coordinator"
ATTRIBUTION = "Data provided by https://www.agur.fr/"
SCAN_INTERVAL_IN_MINUTES = 60 * 6 # 6 hours
SCAN_INTERVAL_IN_MINUTES = 60 * 4 # 4 hours

# Configuration
CONF_CONTRACT_NUMBER = "contract_number"
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.2"
"version": "0.0.3"
}
16 changes: 10 additions & 6 deletions custom_components/eau_agur/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,22 @@ class EauAgurEntityDescription(


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

consumption: float | None = data["consumption"]

if consumption is not None and consumption > 0:
return consumption
return None


SENSORS = [
EauAgurEntityDescription(
key="total_m3",
translation_key="total_m3",
key="total_liters",
translation_key="total_liters",
icon="mdi:gauge",
native_unit_of_measurement=UnitOfVolume.CUBIC_METERS,
native_unit_of_measurement=UnitOfVolume.LITERS,
unit_of_measurement=UnitOfVolume.LITERS,
device_class=SensorDeviceClass.WATER,
state_class=SensorStateClass.TOTAL_INCREASING,
value_fn=read_consumption,
Expand Down
4 changes: 2 additions & 2 deletions custom_components/eau_agur/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
},
"entity": {
"sensor": {
"total_m3": {
"name": "Total m3"
"total_liters": {
"name": "Total liters"
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions custom_components/eau_agur/translations/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
},
"entity": {
"sensor": {
"total_m3": {
"name": "Total m3"
"total_liters": {
"name": "Litres total"
}
}
}
Expand Down
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.2"
version = "0.0.3"
description = "EAU par Agur integration for Home Assistant"
authors = ["Pierre-Emmanuel Mercier <acesyde@gmail.com>"]
license = "MIT"
Expand Down

0 comments on commit bff56cd

Please sign in to comment.