gazpar2haws 0.3.0b44__py3-none-any.whl → 0.3.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- gazpar2haws/gazpar.py +19 -8
- gazpar2haws/model.py +1 -1
- {gazpar2haws-0.3.0b44.dist-info → gazpar2haws-0.3.2.dist-info}/METADATA +52 -2
- {gazpar2haws-0.3.0b44.dist-info → gazpar2haws-0.3.2.dist-info}/RECORD +6 -6
- {gazpar2haws-0.3.0b44.dist-info → gazpar2haws-0.3.2.dist-info}/WHEEL +1 -1
- {gazpar2haws-0.3.0b44.dist-info → gazpar2haws-0.3.2.dist-info}/LICENSE +0 -0
gazpar2haws/gazpar.py
CHANGED
@@ -76,10 +76,18 @@ class Gazpar:
|
|
76
76
|
def name(self):
|
77
77
|
return self._name
|
78
78
|
|
79
|
+
# ----------------------------------
|
80
|
+
def as_of_date(self):
|
81
|
+
return date.today() if self._as_of_date is None else self._as_of_date
|
82
|
+
|
79
83
|
# ----------------------------------
|
80
84
|
# Publish Gaspar data to Home Assistant WS
|
81
85
|
async def publish(self): # pylint: disable=too-many-branches, too-many-statements
|
82
86
|
|
87
|
+
# As of date
|
88
|
+
as_of_date = self.as_of_date()
|
89
|
+
Logger.debug(f"As of date: {as_of_date}")
|
90
|
+
|
83
91
|
# Volume, energy and cost sensor names.
|
84
92
|
volume_sensor_name = f"sensor.{self._name}_volume"
|
85
93
|
energy_sensor_name = f"sensor.{self._name}_energy"
|
@@ -100,9 +108,7 @@ class Gazpar:
|
|
100
108
|
last_date_and_value_by_sensor[cost_sensor_name] = await self.find_last_date_and_value(cost_sensor_name)
|
101
109
|
|
102
110
|
# Compute the start date as the minimum of the last dates plus one day
|
103
|
-
start_date = min(
|
104
|
-
min(v[0] for v in last_date_and_value_by_sensor.values()) + timedelta(days=1), self._as_of_date
|
105
|
-
)
|
111
|
+
start_date = min(min(v[0] for v in last_date_and_value_by_sensor.values()) + timedelta(days=1), as_of_date)
|
106
112
|
|
107
113
|
# Get all start dates
|
108
114
|
energy_start_date = last_date_and_value_by_sensor[energy_sensor_name][0] + timedelta(days=1)
|
@@ -115,7 +121,7 @@ class Gazpar:
|
|
115
121
|
Logger.debug(f"Cost start date: {cost_start_date}")
|
116
122
|
|
117
123
|
# Fetch the data from GrDF and publish it to Home Assistant
|
118
|
-
daily_history = self.fetch_daily_gazpar_history(start_date,
|
124
|
+
daily_history = self.fetch_daily_gazpar_history(start_date, as_of_date)
|
119
125
|
|
120
126
|
# The end date is the last date of the daily history
|
121
127
|
if daily_history is None or len(daily_history) == 0:
|
@@ -319,6 +325,9 @@ class Gazpar:
|
|
319
325
|
# Find last date, value of the entity.
|
320
326
|
async def find_last_date_and_value(self, entity_id: str) -> tuple[date, float]:
|
321
327
|
|
328
|
+
# As of date
|
329
|
+
as_of_date = self.as_of_date()
|
330
|
+
|
322
331
|
# Check the existence of the sensor in Home Assistant
|
323
332
|
try:
|
324
333
|
exists_statistic_id = await self._homeassistant.exists_statistic_id(entity_id, "sum")
|
@@ -331,10 +340,12 @@ class Gazpar:
|
|
331
340
|
if exists_statistic_id:
|
332
341
|
# Get the last statistic from Home Assistant
|
333
342
|
try:
|
334
|
-
|
335
|
-
|
343
|
+
as_of_datetime = datetime.combine(as_of_date, datetime.min.time())
|
344
|
+
as_of_datetime = pytz.timezone(self._timezone).localize(as_of_datetime)
|
336
345
|
|
337
|
-
last_statistic = await self._homeassistant.get_last_statistic(
|
346
|
+
last_statistic = await self._homeassistant.get_last_statistic(
|
347
|
+
entity_id, as_of_datetime, self._last_days
|
348
|
+
)
|
338
349
|
except HomeAssistantWSException:
|
339
350
|
Logger.warning(
|
340
351
|
f"Error while fetching last statistics of the entity '{entity_id}' from Home Assistant: {traceback.format_exc()}"
|
@@ -359,7 +370,7 @@ class Gazpar:
|
|
359
370
|
Logger.debug(f"Entity '{entity_id}' does not exist in Home Assistant.")
|
360
371
|
|
361
372
|
# Compute the corresponding last_date
|
362
|
-
last_date =
|
373
|
+
last_date = as_of_date - timedelta(days=self._last_days)
|
363
374
|
|
364
375
|
# If no statistic, the last value is initialized to zero
|
365
376
|
last_value = 0
|
gazpar2haws/model.py
CHANGED
@@ -54,7 +54,7 @@ class Device(BaseModel):
|
|
54
54
|
name: str
|
55
55
|
data_source: str = "json"
|
56
56
|
tmp_dir: DirectoryPath = DirectoryPath("/tmp")
|
57
|
-
as_of_date: date =
|
57
|
+
as_of_date: Optional[date] = None
|
58
58
|
username: Optional[EmailStr] = None
|
59
59
|
password: Optional[SecretStr] = None
|
60
60
|
pce_identifier: Optional[SecretStr] = None
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.3
|
2
2
|
Name: gazpar2haws
|
3
|
-
Version: 0.3.
|
3
|
+
Version: 0.3.2
|
4
4
|
Summary: Gazpar2HAWS is a gateway that reads data history from the GrDF (French gas provider) meter and send it to Home Assistant using WebSocket interface
|
5
5
|
License: MIT License
|
6
6
|
|
@@ -31,7 +31,7 @@ Classifier: Programming Language :: Python :: 3.12
|
|
31
31
|
Classifier: Programming Language :: Python :: 3.13
|
32
32
|
Requires-Dist: pydantic-extra-types (>=2.10.2,<3.0.0)
|
33
33
|
Requires-Dist: pydantic[email] (>=2.10.6,<3.0.0)
|
34
|
-
Requires-Dist: pygazpar (>=1.3.
|
34
|
+
Requires-Dist: pygazpar (>=1.3.0)
|
35
35
|
Requires-Dist: pyyaml (>=6.0.2)
|
36
36
|
Requires-Dist: websockets (>=14.1)
|
37
37
|
Description-Content-Type: text/markdown
|
@@ -491,6 +491,56 @@ In a Docker environment, the configurations files are instantiated by replacing
|
|
491
491
|
|
492
492
|
You can setup them directly in a docker-compose.yaml file (environment section) or from a Docker command line (-e option).
|
493
493
|
|
494
|
+
## FAQ
|
495
|
+
|
496
|
+
- *Is it an official GrDF application ?*
|
497
|
+
|
498
|
+
No, absolutely not. It was made by reverse engineering GrDF website without any guarantee of long-term operation. Indeed, any modification made to their website risks breaking it.
|
499
|
+
|
500
|
+
- *I'm confused. What are the differences between [PyGazpar](https://github.com/ssenart/PyGazpar), [home-assistant-gazpar](https://github.com/ssenart/home-assistant-gazpar), [lovelace-gazpar-card](https://github.com/ssenart/lovelace-gazpar-card), [Gazpar2MQTT](https://github.com/ssenart/gazpar2mqtt), [Gazpar2HAWS](https://github.com/ssenart/gazpar2haws) ?*
|
501
|
+
|
502
|
+
- [PyGazpar](https://github.com/ssenart/PyGazpar) is the low-level Python library used to query GrDF data. It was written for use by other Python programs.
|
503
|
+
- [home-assistant-gazpar](https://github.com/ssenart/home-assistant-gazpar) is the first program using PyGazpar. This is a Home Assistant integration which makes it possible to provide an energy sensor. Coupled with the Recorder integration, it is capable of building a history (called statistics in HA) and displaying it using the Energy Dashboard. It is also compatible with the [lovelace-gazpar-card](https://github.com/ssenart/lovelace-gazpar-card).
|
504
|
+
- [lovelace-gazpar-card](https://github.com/ssenart/lovelace-gazpar-card) is a HA card which nicely displays historical data in the form of tables or bar graphs. It is also compatible with [Gazpar2MQTT](https://github.com/ssenart/gazpar2mqtt).
|
505
|
+
- [Gazpar2MQTT](https://github.com/ssenart/gazpar2mqtt) offers exactly the same functionality as [home-assistant-gazpar](https://github.com/ssenart/home-assistant-gazpar) but runs outside of HA as a standalone application, in a Docker container or in an HA add-on.
|
506
|
+
- [Gazpar2HAWS](https://github.com/ssenart/gazpar2haws) replaces the use of home-assistant-gazpar/Gazpar2MQTT with the HA Recorder integration to create a data history (for Energy dashboard integration). The disadvantage of the latter solution is the non-alignment of the actual reading date and its publication date. Reading values are made available for 2 to 5 days (and sometimes longer). [Gazpar2HAWS](https://github.com/ssenart/gazpar2haws) timestamps the reading value exactly to the observation dates without any offset. In addition, [Gazpar2HAWS](https://github.com/ssenart/gazpar2haws) is able to reconstruct the complete history of your data up to 3 years in the past, which is very practical in the event of data loss. Finally, it provides ways to calculate and publish energy costs.
|
507
|
+
|
508
|
+
- *My PCE ID has a leading zero (e.g. "0123456789") and the application fails with an error indicating that the PCE number is unknown. I can see in the log file that it uses "123456789" without the leading zero. What happened ?*
|
509
|
+
|
510
|
+
The cause is in your configuration file (grdf.devices[].pce_identifier) where you configured your PCE identifier and you did not quote it. Your PCE number is then interpreted as a number instead of a string.
|
511
|
+
|
512
|
+
## Troubleshooting
|
513
|
+
|
514
|
+
Sometimes, for any reason, the application does not work as expected. No entities is created in HA, some error messages are displayed, nothing happens...
|
515
|
+
|
516
|
+
In this situation, the most valuable tool for troubleshooting what is happening is the log file.
|
517
|
+
|
518
|
+
Take a look at it, try to find a clue that might help solve the problem. Sorry, the log file can sometimes appear cryptic.
|
519
|
+
|
520
|
+
If your configuration is correct, you may have spotted a bug.
|
521
|
+
|
522
|
+
In this case, capture a Github issue [here](https://github.com/ssenart/gazpar2haws/issues) with the following information:
|
523
|
+
1. What kind of setup do you use ? Standalone application, Docker container or HA addon.
|
524
|
+
2. Is this a first installation or a version upgrade ? If upgrading version, what was the previous version and did it work well ?
|
525
|
+
3. Describe as precisely as possible what is happening.
|
526
|
+
4. Provide the complete log file (from start to finish) and make sure to erase all your secrets from it.
|
527
|
+
|
528
|
+
The first log lines should be similar to:
|
529
|
+
```log
|
530
|
+
2025-02-17 02:01:17,626 INFO [__main__] Starting Gazpar2HAWS version 0.3.0
|
531
|
+
2025-02-17 02:01:17,627 INFO [__main__] Running on Python version: 3.12.9 (main, Feb 7 2025, 01:03:02) [GCC 12.2.0]
|
532
|
+
```
|
533
|
+
|
534
|
+
The normal last lines of the log should be:
|
535
|
+
```log
|
536
|
+
2025-02-17 10:02:42,162 INFO [gazpar2haws.gazpar] No volume data to publish
|
537
|
+
2025-02-17 10:02:42,162 INFO [gazpar2haws.gazpar] No energy data to publish
|
538
|
+
2025-02-17 10:02:42,162 INFO [gazpar2haws.gazpar] No cost data to publish
|
539
|
+
2025-02-17 10:02:42,162 INFO [gazpar2haws.bridge] Device 'gazpar2haws' data published to Home Assistant WS.
|
540
|
+
2025-02-17 10:02:42,162 INFO [gazpar2haws.bridge] Gazpar data published to Home Assistant WS.
|
541
|
+
2025-02-17 10:02:42,166 INFO [gazpar2haws.bridge] Waiting 480 minutes before next scan...
|
542
|
+
```
|
543
|
+
|
494
544
|
## Publish a new image on Docker Hub
|
495
545
|
|
496
546
|
1. List all local images
|
@@ -4,12 +4,12 @@ gazpar2haws/bridge.py,sha256=VEl22xt2Szgk_FVrxSvZNxp3T5Q2JXc9ulfrunHHkmo,3685
|
|
4
4
|
gazpar2haws/config_utils.py,sha256=yT2G-naMA2Vst6bQdm1bD2oVsPTU3Q_RuukCs-dZ6Ak,2280
|
5
5
|
gazpar2haws/configuration.py,sha256=24q8FUBMS1vpqU6RYAv5Au179HbiBk1CZIEMiBGuXq0,722
|
6
6
|
gazpar2haws/date_array.py,sha256=q3xTX-KS2KOtFSB042OJVerZFtS-Jw9Iin5RHKnobPs,10108
|
7
|
-
gazpar2haws/gazpar.py,sha256=
|
7
|
+
gazpar2haws/gazpar.py,sha256=XcfT_U4QiHmg0P9pO4boueDLr52UXR2GBKdRmhu8BQw,14586
|
8
8
|
gazpar2haws/haws.py,sha256=1ELdompdACNf5XkpjCN6Bdiw7stPfzar3x8OjoBmhxQ,7969
|
9
|
-
gazpar2haws/model.py,sha256=
|
9
|
+
gazpar2haws/model.py,sha256=RnKmWVLkzLsS_-r60CjXgzRfzoj_GopBAYBEuZjDT_I,7105
|
10
10
|
gazpar2haws/pricer.py,sha256=7xlLlPU6pXQcOnyaeoR_UEQOwuPwUG_V17FvPgSxzmM,22434
|
11
11
|
gazpar2haws/version.py,sha256=9Iq5Jm63Ev7QquCjhDqa9_KAgHdKl9FJHynq8M6JNrY,83
|
12
|
-
gazpar2haws-0.3.
|
13
|
-
gazpar2haws-0.3.
|
14
|
-
gazpar2haws-0.3.
|
15
|
-
gazpar2haws-0.3.
|
12
|
+
gazpar2haws-0.3.2.dist-info/LICENSE,sha256=ajApZPyhVx8AU9wN7DXeRGhoWFqY2ylBZUa5GRhTmok,1073
|
13
|
+
gazpar2haws-0.3.2.dist-info/METADATA,sha256=Zj_3TuzFM1BCAegCkBg8KL4hZUD2R62hhMjaCQF1yP8,22170
|
14
|
+
gazpar2haws-0.3.2.dist-info/WHEEL,sha256=XbeZDeTWKc1w7CSIyre5aMDU_-PohRwTQceYnisIYYY,88
|
15
|
+
gazpar2haws-0.3.2.dist-info/RECORD,,
|
File without changes
|