gazpar2haws 0.1.0__py3-none-any.whl → 0.1.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.
- CHANGELOG.md +18 -1
- gazpar2haws/gazpar.py +39 -14
- gazpar2haws/haws.py +1 -1
- gazpar2haws-0.1.2.dist-info/METADATA +265 -0
- gazpar2haws-0.1.2.dist-info/RECORD +12 -0
- gazpar2haws-0.1.0.dist-info/METADATA +0 -122
- gazpar2haws-0.1.0.dist-info/RECORD +0 -12
- {gazpar2haws-0.1.0.dist-info → gazpar2haws-0.1.2.dist-info}/LICENSE +0 -0
- {gazpar2haws-0.1.0.dist-info → gazpar2haws-0.1.2.dist-info}/WHEEL +0 -0
CHANGELOG.md
CHANGED
@@ -4,6 +4,23 @@ All notable changes to this project will be documented in this file.
|
|
4
4
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
5
5
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
6
6
|
|
7
|
-
## [0.1.
|
7
|
+
## [0.1.2] - 2024-12-30
|
8
|
+
|
9
|
+
### Added
|
10
|
+
[#2](https://github.com/ssenart/gazpar2haws/issues/2): DockerHub deployment.
|
11
|
+
|
12
|
+
### Fixed
|
13
|
+
[#9](https://github.com/ssenart/gazpar2haws/issues/9): Incorrect timezone info creates duplicate import.
|
14
|
+
|
15
|
+
[#6](https://github.com/ssenart/gazpar2haws/issues/6): The last meter value may be imported multiple times and cause the today value being wrong.
|
16
|
+
|
17
|
+
[#3](https://github.com/ssenart/gazpar2haws/issues/3): reset=false makes the meter import to restart from zero.
|
18
|
+
|
19
|
+
## [0.1.1] - 2024-12-22
|
20
|
+
|
21
|
+
### Added
|
22
|
+
[#1](https://github.com/ssenart/gazpar2haws/issues/1): Publish energy indicator in kWh.
|
23
|
+
|
24
|
+
## [0.1.0] - 2024-12-21
|
8
25
|
|
9
26
|
First version of the project.
|
gazpar2haws/gazpar.py
CHANGED
@@ -34,43 +34,63 @@ class Gazpar:
|
|
34
34
|
# Publish Gaspar data to Home Assistant WS
|
35
35
|
async def publish(self):
|
36
36
|
|
37
|
+
# Volume and energy sensor names.
|
38
|
+
volume_sensor_name = f"sensor.{self._name}_volume"
|
39
|
+
energy_sensor_name = f"sensor.{self._name}_energy"
|
40
|
+
|
37
41
|
# Eventually reset the sensor in Home Assistant
|
38
42
|
if self._reset:
|
39
43
|
try:
|
40
|
-
await self._homeassistant.clear_statistics([
|
44
|
+
await self._homeassistant.clear_statistics([volume_sensor_name, energy_sensor_name])
|
41
45
|
except Exception:
|
42
46
|
errorMessage = f"Error while resetting the sensor in Home Assistant: {traceback.format_exc()}"
|
43
47
|
Logger.warning(errorMessage)
|
44
48
|
raise Exception(errorMessage)
|
45
49
|
|
50
|
+
# Publish volume sensor
|
51
|
+
await self._publish_entity(volume_sensor_name, pygazpar.PropertyName.VOLUME.value, "m³")
|
52
|
+
await self._publish_entity(energy_sensor_name, pygazpar.PropertyName.ENERGY.value, "kWh")
|
53
|
+
|
54
|
+
# ----------------------------------
|
55
|
+
# Publish a sensor to Home Assistant
|
56
|
+
async def _publish_entity(self, entity_id: str, property_name: str, unit_of_measurement: str):
|
57
|
+
|
46
58
|
# Check the existence of the sensor in Home Assistant
|
47
59
|
try:
|
48
|
-
exists_statistic_id = await self._homeassistant.exists_statistic_id(
|
60
|
+
exists_statistic_id = await self._homeassistant.exists_statistic_id(entity_id, "sum")
|
49
61
|
except Exception:
|
50
62
|
errorMessage = f"Error while checking the existence of the sensor in Home Assistant: {traceback.format_exc()}"
|
51
63
|
Logger.warning(errorMessage)
|
52
64
|
raise Exception(errorMessage)
|
53
65
|
|
54
66
|
if exists_statistic_id:
|
55
|
-
# Get last
|
67
|
+
# Get the last statistic from Home Assistant
|
56
68
|
try:
|
57
|
-
|
69
|
+
last_statistic = await self._homeassistant.get_last_statistic(entity_id)
|
58
70
|
except Exception:
|
59
71
|
errorMessage = f"Error while fetching last statistics from Home Assistant: {traceback.format_exc()}"
|
60
72
|
Logger.warning(errorMessage)
|
61
73
|
raise Exception(errorMessage)
|
62
74
|
|
63
75
|
# Extract the end date of the last statistics from the unix timestamp
|
64
|
-
last_date = datetime.fromtimestamp(
|
76
|
+
last_date = datetime.fromtimestamp(last_statistic.get("start") / 1000, tz=pytz.timezone(self._timezone))
|
65
77
|
|
66
78
|
# Compute the number of days since the last statistics
|
67
|
-
last_days = (datetime.now() - last_date).days
|
79
|
+
last_days = (datetime.now(tz=pytz.timezone(self._timezone)) - last_date).days
|
80
|
+
|
81
|
+
# Get the last meter value
|
82
|
+
last_value = last_statistic.get("sum")
|
68
83
|
else:
|
69
84
|
# If the sensor does not exist in Home Assistant, fetch the last days defined in the configuration
|
70
85
|
last_days = self._last_days
|
71
86
|
|
72
87
|
# Compute the corresponding last_date
|
73
|
-
last_date = datetime.now() - timedelta(days=last_days)
|
88
|
+
last_date = datetime.now(tz=pytz.timezone(self._timezone)) - timedelta(days=last_days)
|
89
|
+
|
90
|
+
# If no statistic, the last value is initialized to zero
|
91
|
+
last_value = 0
|
92
|
+
|
93
|
+
Logger.debug(f"Last date: {last_date}, last days: {last_days}, last value: {last_value}")
|
74
94
|
|
75
95
|
# Initialize PyGazpar client
|
76
96
|
client = pygazpar.Client(pygazpar.JsonWebDataSource(username=self._username, password=self._password))
|
@@ -85,29 +105,34 @@ class Gazpar:
|
|
85
105
|
# Timezone
|
86
106
|
timezone = pytz.timezone(self._timezone)
|
87
107
|
|
88
|
-
#
|
108
|
+
# Compute and fill statistics.
|
89
109
|
daily = data.get(pygazpar.Frequency.DAILY.value)
|
90
110
|
statistics = []
|
111
|
+
total = last_value
|
91
112
|
for reading in daily:
|
92
113
|
# Parse date format DD/MM/YYYY into datetime.
|
93
114
|
date = datetime.strptime(reading[pygazpar.PropertyName.TIME_PERIOD.value], "%d/%m/%Y")
|
94
115
|
|
116
|
+
# Set the timezone
|
117
|
+
date = timezone.localize(date)
|
118
|
+
|
95
119
|
# Skip all readings before the last statistic date.
|
96
|
-
if date
|
120
|
+
if date <= last_date:
|
121
|
+
Logger.debug(f"Skip date: {date} <= {last_date}")
|
97
122
|
continue
|
98
123
|
|
99
|
-
#
|
100
|
-
|
124
|
+
# Compute the total volume and energy
|
125
|
+
total += reading[property_name]
|
101
126
|
|
102
127
|
statistics.append({
|
103
128
|
"start": date.isoformat(),
|
104
|
-
"state":
|
105
|
-
"sum":
|
129
|
+
"state": total,
|
130
|
+
"sum": total
|
106
131
|
})
|
107
132
|
|
108
133
|
# Publish statistics to Home Assistant
|
109
134
|
try:
|
110
|
-
await self._homeassistant.import_statistics(
|
135
|
+
await self._homeassistant.import_statistics(entity_id, "recorder", "gazpar2haws", unit_of_measurement, statistics)
|
111
136
|
except Exception:
|
112
137
|
errorMessage = f"Error while importing statistics to Home Assistant: {traceback.format_exc()}"
|
113
138
|
Logger.warning(errorMessage)
|
gazpar2haws/haws.py
CHANGED
@@ -73,7 +73,7 @@ class HomeAssistantWS:
|
|
73
73
|
|
74
74
|
response_data = json.loads(response)
|
75
75
|
|
76
|
-
Logger.debug(
|
76
|
+
Logger.debug("Received response")
|
77
77
|
|
78
78
|
if response_data.get("type") != "result":
|
79
79
|
raise Exception(f"Invalid response message: {response_data}")
|
@@ -0,0 +1,265 @@
|
|
1
|
+
Metadata-Version: 2.1
|
2
|
+
Name: gazpar2haws
|
3
|
+
Version: 0.1.2
|
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
|
+
License: MIT
|
6
|
+
Author: Stéphane Senart
|
7
|
+
Requires-Python: >=3.12,<4.0
|
8
|
+
Classifier: License :: OSI Approved :: MIT License
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
10
|
+
Classifier: Programming Language :: Python :: 3.12
|
11
|
+
Classifier: Programming Language :: Python :: 3.13
|
12
|
+
Requires-Dist: pygazpar (==1.2.5)
|
13
|
+
Requires-Dist: pytest-asyncio (>=0.25.0,<0.26.0)
|
14
|
+
Requires-Dist: pyyaml (>=6.0.2,<7.0.0)
|
15
|
+
Requires-Dist: websockets (>=14.1,<15.0)
|
16
|
+
Description-Content-Type: text/markdown
|
17
|
+
|
18
|
+
# gazpar2haws
|
19
|
+
Gazpar2HAWS is a gateway that reads data history from the GrDF (French gas provider) meter and send it to Home Assistant using WebSocket interface.
|
20
|
+
|
21
|
+
It is compatible with Home Assistant Energy Dashboard and permits to upload the history and keep it updated with the latest readings.
|
22
|
+
|
23
|
+
## Installation
|
24
|
+
|
25
|
+
Gazpar2HAWS can be installed on any host as a standalone program.
|
26
|
+
|
27
|
+
### 1. Using source files
|
28
|
+
|
29
|
+
The project requires [Poetry](https://python-poetry.org/) tool for dependency and package management.
|
30
|
+
|
31
|
+
```sh
|
32
|
+
$ cd /path/to/my_install_folder/
|
33
|
+
|
34
|
+
$ git clone https://github.com/ssenart/gazpar2haws.git
|
35
|
+
|
36
|
+
$ cd gazpar2haws
|
37
|
+
|
38
|
+
$ poetry install
|
39
|
+
|
40
|
+
$ poetry shell
|
41
|
+
|
42
|
+
```
|
43
|
+
|
44
|
+
### 2. Using PIP package
|
45
|
+
|
46
|
+
```sh
|
47
|
+
$ cd /path/to/my_install_folder/
|
48
|
+
|
49
|
+
$ mkdir gazpar2haws
|
50
|
+
|
51
|
+
$ cd gazpar2haws
|
52
|
+
|
53
|
+
$ python -m venv .venv
|
54
|
+
|
55
|
+
$ source .venv/bin/activate
|
56
|
+
|
57
|
+
$ pip install gazpar2haws
|
58
|
+
|
59
|
+
```
|
60
|
+
|
61
|
+
### 3. Using Dockerfile
|
62
|
+
|
63
|
+
The following steps permit to build the Docker image based on the local source files.
|
64
|
+
|
65
|
+
1. Clone the repo locally:
|
66
|
+
```sh
|
67
|
+
$ cd /path/to/my_install_folder/
|
68
|
+
|
69
|
+
$ git clone https://github.com/ssenart/gazpar2haws.git
|
70
|
+
```
|
71
|
+
2. Edit the docker-compose.yaml file by setting the environment variables corresponding to your GrDF account and Home Assistant setup:
|
72
|
+
|
73
|
+
```yaml
|
74
|
+
environment:
|
75
|
+
- GRDF_USERNAME=<GrDF account username>
|
76
|
+
- GRDF_PASSWORD=<GrDF account password>
|
77
|
+
- GRDF_PCE_IDENTIFIER=<GrDF PCE meter identifier>
|
78
|
+
- HOMEASSISTANT_HOST=<Home Assistant instance host name>
|
79
|
+
- HOMEASSISTANT_PORT=<Home Assistant instance port number>
|
80
|
+
- HOMEASSISTANT_TOKEN=<Home Assistant access token>
|
81
|
+
```
|
82
|
+
3. Build the image:
|
83
|
+
```sh
|
84
|
+
$ docker compose -f docker/docker-compose.yaml build
|
85
|
+
```
|
86
|
+
4. Run the container:
|
87
|
+
```sh
|
88
|
+
$ docker compose -f docker/docker-compose.yaml up -d
|
89
|
+
```
|
90
|
+
|
91
|
+
### 4. Using Docker Hub
|
92
|
+
|
93
|
+
The following steps permits to run a container from an existing image available in the Docker Hub repository.
|
94
|
+
|
95
|
+
1. Copy and save the following docker-compose.yaml file:
|
96
|
+
|
97
|
+
```yaml
|
98
|
+
services:
|
99
|
+
gazpar2haws:
|
100
|
+
image: ssenart/gazpar2haws:latest
|
101
|
+
container_name: gazpar2haws
|
102
|
+
restart: unless-stopped
|
103
|
+
network_mode: bridge
|
104
|
+
user: "1000:1000"
|
105
|
+
volumes:
|
106
|
+
- ./gazpar2haws/config:/app/config
|
107
|
+
- ./gazpar2haws/log:/app/log
|
108
|
+
environment:
|
109
|
+
- GRDF_USERNAME=<GrDF account username>
|
110
|
+
- GRDF_PASSWORD=<GrDF account password>
|
111
|
+
- GRDF_PCE_IDENTIFIER=<GrDF PCE meter identifier>
|
112
|
+
- HOMEASSISTANT_HOST=<Home Assistant instance host name>
|
113
|
+
- HOMEASSISTANT_TOKEN=<Home Assistant access token>
|
114
|
+
```
|
115
|
+
|
116
|
+
Edit the environment variable section according to your setup.
|
117
|
+
|
118
|
+
2. Run the container:
|
119
|
+
```sh
|
120
|
+
$ docker compose up -d
|
121
|
+
```
|
122
|
+
|
123
|
+
## Usage
|
124
|
+
|
125
|
+
### Command line
|
126
|
+
|
127
|
+
```sh
|
128
|
+
$ python -m gazpar2haws --config /path/to/configuration.yaml --secrets /path/to/secrets.yaml
|
129
|
+
```
|
130
|
+
|
131
|
+
### Configuration file
|
132
|
+
|
133
|
+
The default configuration file is below.
|
134
|
+
|
135
|
+
```yaml
|
136
|
+
logging:
|
137
|
+
file: log/gazpar2haws.log
|
138
|
+
console: true
|
139
|
+
level: debug
|
140
|
+
format: '%(asctime)s %(levelname)s [%(name)s] %(message)s'
|
141
|
+
|
142
|
+
grdf:
|
143
|
+
scan_interval: 0 # Number of minutes between each data retrieval (0 means no scan: a single data retrieval at startup, then stops).
|
144
|
+
devices:
|
145
|
+
- name: gazpar2haws # Name of the device in home assistant. It will be used as the entity_ids: sensor.${name}_volume and sensor.${name}_energy.
|
146
|
+
username: "!secret grdf.username"
|
147
|
+
password: "!secret grdf.password"
|
148
|
+
pce_identifier: "!secret grdf.pce_identifier"
|
149
|
+
timezone: Europe/Paris
|
150
|
+
last_days: 365 # Number of days of data to retrieve
|
151
|
+
reset: false # If true, the data will be reset before the first data retrieval
|
152
|
+
|
153
|
+
homeassistant:
|
154
|
+
host: "!secret homeassistant.host"
|
155
|
+
port: "!secret homeassistant.port"
|
156
|
+
token: "!secret homeassistant.token"
|
157
|
+
```
|
158
|
+
|
159
|
+
The default secret file:
|
160
|
+
|
161
|
+
```yaml
|
162
|
+
grdf.username: ${GRDF_USERNAME}
|
163
|
+
grdf.password: ${GRDF_PASSWORD}
|
164
|
+
grdf.pce_identifier: ${GRDF_PCE_IDENTIFIER}
|
165
|
+
|
166
|
+
homeassistant.host: ${HA_HOST}
|
167
|
+
homeassistant.port: ${HA_PORT}
|
168
|
+
homeassistant.token: ${HA_TOKEN}
|
169
|
+
```
|
170
|
+
|
171
|
+
The history is uploaded on the entities with names:
|
172
|
+
- sensor.${name}_volume: Volume history in m³.
|
173
|
+
- sensor.${name}_energy: Energy history in kWh.
|
174
|
+
|
175
|
+
${name} is 'gazpar2haws' defined in the above configuration file. It can be replaced by any other name.
|
176
|
+
|
177
|
+
Those two entities have to already exist in Home Assistant.
|
178
|
+
|
179
|
+
They may be created using the following templates:
|
180
|
+
|
181
|
+
```yaml
|
182
|
+
|
183
|
+
- name: gazpar2haws_volume
|
184
|
+
unit_of_measurement: 'm³'
|
185
|
+
availability: true
|
186
|
+
state: 0
|
187
|
+
icon: mdi:fire
|
188
|
+
device_class: gas
|
189
|
+
state_class: total_increasing
|
190
|
+
|
191
|
+
- name: gazpar2haws_energy
|
192
|
+
unit_of_measurement: 'kWh'
|
193
|
+
availability: true
|
194
|
+
state: 0
|
195
|
+
icon: mdi:fire
|
196
|
+
device_class: energy
|
197
|
+
state_class: total_increasing
|
198
|
+
|
199
|
+
```
|
200
|
+
|
201
|
+
### Environment variable for Docker
|
202
|
+
|
203
|
+
In a Docker environment, the configurations files are instantiated by replacing the environment variables below in the template files:
|
204
|
+
|
205
|
+
| Environment variable | Description | Required | Default value |
|
206
|
+
|---|---|---|---|
|
207
|
+
| GRDF_USERNAME | GrDF account user name | Yes | - |
|
208
|
+
| GRDF_PASSWORD | GrDF account password (avoid using special characters) | Yes | - |
|
209
|
+
| GRDF_PCE_IDENTIFIER | GrDF meter PCE identifier | Yes | - |
|
210
|
+
| GRDF_SCAN_INTERVAL | Period in minutes to refresh meter data (0 means one single refresh and stop) | No | 480 (8 hours) |
|
211
|
+
| GRDF_LAST_DAYS | Number of days of history data to retrieve | No | 1095 (3 years) |
|
212
|
+
| HOMEASSISTANT_HOST | Home Assistant instance host name | Yes | - |
|
213
|
+
| HOMEASSISTANT_PORT | Home Assistant instance port number | No | 8123 |
|
214
|
+
| HOMEASSISTANT_TOKEN | Home Assistant access token | Yes | - |
|
215
|
+
|
216
|
+
You can setup them directly in a docker-compose.yaml file (environment section) or from a Docker command line (-e option).
|
217
|
+
|
218
|
+
## Publish a new image on Docker Hub
|
219
|
+
|
220
|
+
1. List all local images
|
221
|
+
|
222
|
+
```sh
|
223
|
+
$ docker image ls
|
224
|
+
```
|
225
|
+
|
226
|
+
2. Build a new local image
|
227
|
+
|
228
|
+
```sh
|
229
|
+
$ docker compose -f docker/docker-compose.yaml build
|
230
|
+
```
|
231
|
+
|
232
|
+
3. Tag the new built image with the version number
|
233
|
+
|
234
|
+
```sh
|
235
|
+
$ docker image tag ssenart/gazpar2haws:latest ssenart/gazpar2haws:0.1.2
|
236
|
+
```
|
237
|
+
|
238
|
+
4. Login in Docker Hub
|
239
|
+
|
240
|
+
```sh
|
241
|
+
$ docker login
|
242
|
+
```
|
243
|
+
|
244
|
+
5. Push all the tagged local images to Docker Hub
|
245
|
+
|
246
|
+
```sh
|
247
|
+
$ docker push --all-tags ssenart/gazpar2haws
|
248
|
+
```
|
249
|
+
|
250
|
+
All the gazpar2haws images are available [here](https://hub.docker.com/repository/docker/ssenart/gazpar2haws/general).
|
251
|
+
|
252
|
+
## Contributing
|
253
|
+
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
|
254
|
+
|
255
|
+
Please make sure to update tests as appropriate.
|
256
|
+
|
257
|
+
## License
|
258
|
+
[MIT](https://choosealicense.com/licenses/mit/)
|
259
|
+
|
260
|
+
## Project status
|
261
|
+
Gazpar2HAWS has been initiated for integration with [Home Assistant](https://www.home-assistant.io/) energy dashboard.
|
262
|
+
|
263
|
+
|
264
|
+
|
265
|
+
|
@@ -0,0 +1,12 @@
|
|
1
|
+
CHANGELOG.md,sha256=ViL-BtLOsttdVoe_XUsE8CPmI1Unpb9d-YRFsUMJaYo,946
|
2
|
+
gazpar2haws/__init__.py,sha256=yzol8uZSBI7pIRGUmYJ6-vRBwkM4MI3IGf5cQpNsaFw,57
|
3
|
+
gazpar2haws/__main__.py,sha256=g8xk0x_kprBHKHLzgf9y9EY2_gKC9V3k4z0n-EDTd-I,3253
|
4
|
+
gazpar2haws/bridge.py,sha256=TiPmvRBxzgwOKKmWNXMOaP0pLg-Wls_SmiwHczNEM_4,3466
|
5
|
+
gazpar2haws/config_utils.py,sha256=D0lu-3KY-vLEyD2vDN05UABkMnpMJjqw1RuDJVrkGFs,2123
|
6
|
+
gazpar2haws/gazpar.py,sha256=8yrMzs9HfMSgq3HPeJs64SHWb5RWm7ZL3tgfzhlwHFQ,5754
|
7
|
+
gazpar2haws/haws.py,sha256=SiVM5QTANMmUq66IAsFn68jwej-Rdpqg6dIqTeTadmw,6765
|
8
|
+
gazpar2haws/version.py,sha256=ebdTNl4h0hNKmN3Gbs592VJsYbMmrkB47WyZMJevaQo,86
|
9
|
+
gazpar2haws-0.1.2.dist-info/LICENSE,sha256=G6JttcnlwcRHYzIcDflSGOVrHTtaP3BEegM2lH00xHw,1094
|
10
|
+
gazpar2haws-0.1.2.dist-info/METADATA,sha256=1duww4kuumkMKGB1XufxPyjClZmmkSA8QnrbheRoB7M,7359
|
11
|
+
gazpar2haws-0.1.2.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
|
12
|
+
gazpar2haws-0.1.2.dist-info/RECORD,,
|
@@ -1,122 +0,0 @@
|
|
1
|
-
Metadata-Version: 2.1
|
2
|
-
Name: gazpar2haws
|
3
|
-
Version: 0.1.0
|
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
|
-
License: MIT
|
6
|
-
Author: Stéphane Senart
|
7
|
-
Requires-Python: >=3.12,<4.0
|
8
|
-
Classifier: License :: OSI Approved :: MIT License
|
9
|
-
Classifier: Programming Language :: Python :: 3
|
10
|
-
Classifier: Programming Language :: Python :: 3.12
|
11
|
-
Classifier: Programming Language :: Python :: 3.13
|
12
|
-
Requires-Dist: pygazpar (==1.2.5)
|
13
|
-
Requires-Dist: pytest-asyncio (>=0.25.0,<0.26.0)
|
14
|
-
Requires-Dist: pyyaml (>=6.0.2,<7.0.0)
|
15
|
-
Requires-Dist: websockets (>=14.1,<15.0)
|
16
|
-
Description-Content-Type: text/markdown
|
17
|
-
|
18
|
-
# gazpar2haws
|
19
|
-
Gazpar2HAWS is a gateway that reads data history from the GrDF (French gas provider) meter and send it to Home Assistant using WebSocket interface.
|
20
|
-
|
21
|
-
It is compatible with Home Assistant Energy Dashboard and permits to upload the history and keep it updated with the latest readings.
|
22
|
-
|
23
|
-
## Installation
|
24
|
-
|
25
|
-
Gazpar2HAWS can be installed on any host as a standalone program.
|
26
|
-
|
27
|
-
### 1. Using source files
|
28
|
-
|
29
|
-
The project requires [Poetry](https://python-poetry.org/) tool for dependency and package management.
|
30
|
-
|
31
|
-
```sh
|
32
|
-
$ cd /path/to/my_install_folder/
|
33
|
-
|
34
|
-
$ git clone https://github.com/ssenart/gazpar2haws.git
|
35
|
-
|
36
|
-
$ cd gazpar2haws
|
37
|
-
|
38
|
-
$ poetry install
|
39
|
-
|
40
|
-
$ poetry shell
|
41
|
-
|
42
|
-
```
|
43
|
-
|
44
|
-
### 2. Using PIP package
|
45
|
-
|
46
|
-
```sh
|
47
|
-
$ cd /path/to/my_install_folder/
|
48
|
-
|
49
|
-
$ mkdir gazpar2haws
|
50
|
-
|
51
|
-
$ cd gazpar2haws
|
52
|
-
|
53
|
-
$ python -m venv .venv
|
54
|
-
|
55
|
-
$ source .venv/bin/activate
|
56
|
-
|
57
|
-
$ pip install gazpar2haws
|
58
|
-
|
59
|
-
```
|
60
|
-
|
61
|
-
## Usage
|
62
|
-
|
63
|
-
### Command line
|
64
|
-
|
65
|
-
```sh
|
66
|
-
$ python -m gazpar2haws --config /path/to/configuration.yaml --secrets /path/to/secrets.yaml
|
67
|
-
```
|
68
|
-
|
69
|
-
### Configuration file
|
70
|
-
|
71
|
-
The default configuration file is below.
|
72
|
-
|
73
|
-
```yaml
|
74
|
-
logging:
|
75
|
-
file: log/gazpar2haws.log
|
76
|
-
console: true
|
77
|
-
level: debug
|
78
|
-
format: '%(asctime)s %(levelname)s [%(name)s] %(message)s'
|
79
|
-
|
80
|
-
grdf:
|
81
|
-
scan_interval: 0 # Number of minutes between each data retrieval (0 means no scan: a single data retrieval at startup, then stops).
|
82
|
-
devices:
|
83
|
-
- name: gazpar2haws
|
84
|
-
username: "!secret grdf.username"
|
85
|
-
password: "!secret grdf.password"
|
86
|
-
pce_identifier: "!secret grdf.pce_identifier"
|
87
|
-
timezone: Europe/Paris
|
88
|
-
last_days: 365 # Number of days of data to retrieve
|
89
|
-
reset: false # If true, the data will be reset before the first data retrieval
|
90
|
-
|
91
|
-
homeassistant:
|
92
|
-
host: "!secret homeassistant.host"
|
93
|
-
port: "!secret homeassistant.port"
|
94
|
-
token: "!secret homeassistant.token"
|
95
|
-
```
|
96
|
-
|
97
|
-
The default secret file:
|
98
|
-
|
99
|
-
```yaml
|
100
|
-
grdf.username: ${GRDF_USERNAME}
|
101
|
-
grdf.password: ${GRDF_PASSWORD}
|
102
|
-
grdf.pce_identifier: ${GRDF_PCE_IDENTIFIER}
|
103
|
-
|
104
|
-
homeassistant.host: ${HA_HOST}
|
105
|
-
homeassistant.port: ${HA_PORT}
|
106
|
-
homeassistant.token: ${HA_TOKEN}
|
107
|
-
```
|
108
|
-
|
109
|
-
## Contributing
|
110
|
-
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
|
111
|
-
|
112
|
-
Please make sure to update tests as appropriate.
|
113
|
-
|
114
|
-
## License
|
115
|
-
[MIT](https://choosealicense.com/licenses/mit/)
|
116
|
-
|
117
|
-
## Project status
|
118
|
-
Gazpar2HAWS has been initiated for integration with [Home Assistant](https://www.home-assistant.io/) energy dashboard.
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
@@ -1,12 +0,0 @@
|
|
1
|
-
CHANGELOG.md,sha256=8JDG8V_DLBTwnVlZErwlK9PNI-xiwpU6vaqSKavYvKw,316
|
2
|
-
gazpar2haws/__init__.py,sha256=yzol8uZSBI7pIRGUmYJ6-vRBwkM4MI3IGf5cQpNsaFw,57
|
3
|
-
gazpar2haws/__main__.py,sha256=g8xk0x_kprBHKHLzgf9y9EY2_gKC9V3k4z0n-EDTd-I,3253
|
4
|
-
gazpar2haws/bridge.py,sha256=TiPmvRBxzgwOKKmWNXMOaP0pLg-Wls_SmiwHczNEM_4,3466
|
5
|
-
gazpar2haws/config_utils.py,sha256=D0lu-3KY-vLEyD2vDN05UABkMnpMJjqw1RuDJVrkGFs,2123
|
6
|
-
gazpar2haws/gazpar.py,sha256=4bEp0JDrLAFxbADSoRH76UD3OC8ls5GBhUcoBQ9WQxw,4663
|
7
|
-
gazpar2haws/haws.py,sha256=EXs5Tdla4u2BVtupCCLITyvdL_W288LrCxrTzskWSRY,6783
|
8
|
-
gazpar2haws/version.py,sha256=ebdTNl4h0hNKmN3Gbs592VJsYbMmrkB47WyZMJevaQo,86
|
9
|
-
gazpar2haws-0.1.0.dist-info/LICENSE,sha256=G6JttcnlwcRHYzIcDflSGOVrHTtaP3BEegM2lH00xHw,1094
|
10
|
-
gazpar2haws-0.1.0.dist-info/METADATA,sha256=H6EGtnQczzLQKLDwdPtAd2TwAzzVIi82AURA36Khwns,3099
|
11
|
-
gazpar2haws-0.1.0.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
|
12
|
-
gazpar2haws-0.1.0.dist-info/RECORD,,
|
File without changes
|
File without changes
|