-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16 from ssenart/feature/15-websocket_endpoint
[#15] Using HassIO, websocket endpoint is /core/websocket.
- Loading branch information
Showing
11 changed files
with
708 additions
and
685 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,48 @@ | ||
# Changelog | ||
|
||
All notable changes to this project will be documented in this file. | ||
|
||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), | ||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). | ||
|
||
## [0.1.4] - 2025-01-04 | ||
|
||
### Fixed | ||
|
||
[#13](https://github.com/ssenart/gazpar2haws/issues/13): Using HassIO, connection to the supervisor requires Authorization header. | ||
|
||
## [0.1.3] - 2025-01-03 | ||
|
||
### Changed | ||
|
||
[#11](https://github.com/ssenart/gazpar2haws/issues/11): Upgrade PyGazpar version to 1.2.6. | ||
|
||
## [0.1.2] - 2024-12-30 | ||
|
||
### Added | ||
|
||
[#2](https://github.com/ssenart/gazpar2haws/issues/2): DockerHub deployment. | ||
|
||
### Fixed | ||
|
||
[#9](https://github.com/ssenart/gazpar2haws/issues/9): Incorrect timezone info creates duplicate import. | ||
|
||
[#6](https://github.com/ssenart/gazpar2haws/issues/6): The last meter value may be imported multiple times and cause the today value being wrong. | ||
|
||
[#3](https://github.com/ssenart/gazpar2haws/issues/3): reset=false makes the meter import to restart from zero. | ||
|
||
## [0.1.1] - 2024-12-22 | ||
|
||
### Added | ||
|
||
[#1](https://github.com/ssenart/gazpar2haws/issues/1): Publish energy indicator in kWh. | ||
|
||
## [0.1.0] - 2024-12-21 | ||
|
||
First version of the project. | ||
# Changelog | ||
|
||
All notable changes to this project will be documented in this file. | ||
|
||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), | ||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). | ||
|
||
## [0.1.5] - 2025-01-04 | ||
|
||
### Added | ||
|
||
[#15](https://github.com/ssenart/gazpar2haws/issues/15): Using HassIO, websocket endpoint is /core/websocket. | ||
|
||
## [0.1.4] - 2025-01-04 | ||
|
||
### Fixed | ||
|
||
[#13](https://github.com/ssenart/gazpar2haws/issues/13): Using HassIO, connection to the supervisor requires Authorization header. | ||
|
||
## [0.1.3] - 2025-01-03 | ||
|
||
### Changed | ||
|
||
[#11](https://github.com/ssenart/gazpar2haws/issues/11): Upgrade PyGazpar version to 1.2.6. | ||
|
||
## [0.1.2] - 2024-12-30 | ||
|
||
### Added | ||
|
||
[#2](https://github.com/ssenart/gazpar2haws/issues/2): DockerHub deployment. | ||
|
||
### Fixed | ||
|
||
[#9](https://github.com/ssenart/gazpar2haws/issues/9): Incorrect timezone info creates duplicate import. | ||
|
||
[#6](https://github.com/ssenart/gazpar2haws/issues/6): The last meter value may be imported multiple times and cause the today value being wrong. | ||
|
||
[#3](https://github.com/ssenart/gazpar2haws/issues/3): reset=false makes the meter import to restart from zero. | ||
|
||
## [0.1.1] - 2024-12-22 | ||
|
||
### Added | ||
|
||
[#1](https://github.com/ssenart/gazpar2haws/issues/1): Publish energy indicator in kWh. | ||
|
||
## [0.1.0] - 2024-12-21 | ||
|
||
First version of the project. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,22 @@ | ||
logging: | ||
file: log/gazpar2haws.log | ||
console: true | ||
level: debug | ||
format: '%(asctime)s %(levelname)s [%(name)s] %(message)s' | ||
|
||
grdf: | ||
scan_interval: ${GRDF_SCAN_INTERVAL} # Number of minutes between each data retrieval (0 means no scan: a single data retrieval at startup, then stops). | ||
devices: | ||
- name: gazpar2haws # Name of the device in home assistant. It will be used as the entity_id: sensor.${name}. | ||
username: "!secret grdf.username" | ||
password: "!secret grdf.password" | ||
pce_identifier: "!secret grdf.pce_identifier" | ||
timezone: Europe/Paris | ||
last_days: ${GRDF_LAST_DAYS} # Number of days of data to retrieve | ||
reset: false # If true, the data will be reset before the first data retrieval. If false, the data will be kept and new data will be added. | ||
|
||
homeassistant: | ||
host: "!secret homeassistant.host" | ||
port: "!secret homeassistant.port" | ||
token: "!secret homeassistant.token" | ||
logging: | ||
file: log/gazpar2haws.log | ||
console: true | ||
level: debug | ||
format: '%(asctime)s %(levelname)s [%(name)s] %(message)s' | ||
|
||
grdf: | ||
scan_interval: ${GRDF_SCAN_INTERVAL} # Number of minutes between each data retrieval (0 means no scan: a single data retrieval at startup, then stops). | ||
devices: | ||
- name: gazpar2haws # Name of the device in home assistant. It will be used as the entity_id: sensor.${name}. | ||
username: "!secret grdf.username" | ||
password: "!secret grdf.password" | ||
pce_identifier: "!secret grdf.pce_identifier" | ||
timezone: Europe/Paris | ||
last_days: ${GRDF_LAST_DAYS} # Number of days of data to retrieve | ||
reset: false # If true, the data will be reset before the first data retrieval. If false, the data will be kept and new data will be added. | ||
|
||
homeassistant: | ||
host: "!secret homeassistant.host" | ||
port: "!secret homeassistant.port" | ||
endpoint: ${HOMEASSISTANT_ENDPOINT} | ||
token: "!secret homeassistant.token" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,22 @@ | ||
logging: | ||
file: log/gazpar2haws.log | ||
console: true | ||
level: info | ||
format: '%(asctime)s %(levelname)s [%(name)s] %(message)s' | ||
|
||
grdf: | ||
scan_interval: 1440 # Number of minutes between each data retrieval (0 means no scan: a single data retrieval at startup, then stops). | ||
devices: | ||
- name: gazpar2haws # Name of the device in home assistant. It will be used as the entity_id: sensor.${name}. | ||
username: "!secret grdf.username" | ||
password: "!secret grdf.password" | ||
pce_identifier: "!secret grdf.pce_identifier" | ||
timezone: Europe/Paris | ||
last_days: 365 # Number of days of data to retrieve. | ||
reset: false # If true, the data will be reset before the first data retrieval. If false, the data will be kept and new data will be added. | ||
|
||
homeassistant: | ||
host: "!secret homeassistant.host" | ||
port: "!secret homeassistant.port" | ||
token: "!secret homeassistant.token" | ||
logging: | ||
file: log/gazpar2haws.log | ||
console: true | ||
level: debug | ||
format: '%(asctime)s %(levelname)s [%(name)s] %(message)s' | ||
|
||
grdf: | ||
scan_interval: 0 # Number of minutes between each data retrieval (0 means no scan: a single data retrieval at startup, then stops). | ||
devices: | ||
- name: gazpar2haws # Name of the device in home assistant. It will be used as the entity_id: sensor.${name}. | ||
username: "!secret grdf.username" | ||
password: "!secret grdf.password" | ||
pce_identifier: "!secret grdf.pce_identifier" | ||
timezone: Europe/Paris | ||
last_days: 365 # Number of days of data to retrieve. | ||
reset: false # If true, the data will be reset before the first data retrieval. If false, the data will be kept and new data will be added. | ||
|
||
homeassistant: | ||
host: "!secret homeassistant.host" | ||
port: "!secret homeassistant.port" | ||
endpoint: "/api/websocket" | ||
token: "!secret homeassistant.token" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,52 @@ | ||
# The builder image, used to build the virtual environment | ||
FROM python:3.12-bookworm AS builder | ||
|
||
RUN pip install poetry==1.8.4 | ||
|
||
ENV POETRY_NO_INTERACTION=1 \ | ||
POETRY_VIRTUALENVS_IN_PROJECT=1 \ | ||
POETRY_VIRTUALENVS_CREATE=1 \ | ||
POETRY_CACHE_DIR=/tmp/poetry_cache | ||
|
||
WORKDIR /app | ||
|
||
COPY pyproject.toml poetry.lock ./ | ||
RUN touch README.md | ||
|
||
COPY gazpar2haws/ /app/gazpar2haws | ||
|
||
RUN poetry install --without dev && rm -rf $POETRY_CACHE_DIR | ||
|
||
# The runtime image, used to just run the code provided its virtual environment | ||
FROM python:3.12-slim-bookworm AS runtime | ||
|
||
# Environment variables | ||
# GRDF_USERNAME: The username to use to authenticate to the GRDF API | ||
# GRDF_PASSWORD: The password to use to authenticate to the GRDF API | ||
# GRDF_PCE_IDENTIFIER: The identifier of the PCE to use to fetch the data | ||
# GRDF_SCAN_INTERVAL: The interval in minutes between two scans of the GRDF API | ||
# GRDF_LAST_DAYS: The number of days to fetch when fetching the data | ||
# HOME_ASSISTANT_HOST: The hostname of the Home Assistant instance | ||
# HOME_ASSISTANT_PORT: The port of the Home Assistant instance | ||
# HOME_ASSISTANT_TOKEN: The long-lived access token to use to authenticate to the Home Assistant instance | ||
|
||
# Install the required system dependencies: envsubst | ||
RUN apt-get update && apt-get install -y gettext-base | ||
|
||
WORKDIR /app | ||
|
||
ENV VIRTUAL_ENV=/app/.venv \ | ||
PATH="/app/.venv/bin:$PATH" | ||
|
||
COPY --from=builder ${VIRTUAL_ENV} ${VIRTUAL_ENV} | ||
|
||
COPY docker/entrypoint.sh /app | ||
RUN chmod +x /app/entrypoint.sh | ||
COPY gazpar2haws/ /app/gazpar2haws | ||
RUN mkdir /app/config | ||
RUN mkdir /app/log | ||
COPY config/configuration.template.yaml /app | ||
COPY config/secrets.template.yaml /app | ||
|
||
ENTRYPOINT ["/bin/sh", "/app/entrypoint.sh"] | ||
# The builder image, used to build the virtual environment | ||
FROM python:3.12-bookworm AS builder | ||
|
||
RUN pip install poetry==1.8.4 | ||
|
||
ENV POETRY_NO_INTERACTION=1 \ | ||
POETRY_VIRTUALENVS_IN_PROJECT=1 \ | ||
POETRY_VIRTUALENVS_CREATE=1 \ | ||
POETRY_CACHE_DIR=/tmp/poetry_cache | ||
|
||
WORKDIR /app | ||
|
||
COPY pyproject.toml poetry.lock ./ | ||
RUN touch README.md | ||
|
||
COPY gazpar2haws/ /app/gazpar2haws | ||
|
||
RUN poetry install --without dev && rm -rf $POETRY_CACHE_DIR | ||
|
||
# The runtime image, used to just run the code provided its virtual environment | ||
FROM python:3.12-slim-bookworm AS runtime | ||
|
||
# Environment variables | ||
# GRDF_USERNAME: The username to use to authenticate to the GRDF API | ||
# GRDF_PASSWORD: The password to use to authenticate to the GRDF API | ||
# GRDF_PCE_IDENTIFIER: The identifier of the PCE to use to fetch the data | ||
# GRDF_SCAN_INTERVAL: The interval in minutes between two scans of the GRDF API | ||
# GRDF_LAST_DAYS: The number of days to fetch when fetching the data | ||
# HOMEASSISTANT_HOST: The hostname of the Home Assistant instance | ||
# HOMEASSISTANT_PORT: The port of the Home Assistant instance | ||
# HOMEASSISTANT_ENDPOINT: The endpoint to use to send the data to the Home Assistant | ||
# HOMEASSISTANT_TOKEN: The long-lived access token to use to authenticate to the Home Assistant instance | ||
|
||
# Install the required system dependencies: envsubst | ||
RUN apt-get update && apt-get install -y gettext-base | ||
|
||
WORKDIR /app | ||
|
||
ENV VIRTUAL_ENV=/app/.venv \ | ||
PATH="/app/.venv/bin:$PATH" | ||
|
||
COPY --from=builder ${VIRTUAL_ENV} ${VIRTUAL_ENV} | ||
|
||
COPY docker/entrypoint.sh /app | ||
RUN chmod +x /app/entrypoint.sh | ||
COPY gazpar2haws/ /app/gazpar2haws | ||
RUN mkdir /app/config | ||
RUN mkdir /app/log | ||
COPY config/configuration.template.yaml /app | ||
COPY config/secrets.template.yaml /app | ||
|
||
ENTRYPOINT ["/bin/sh", "/app/entrypoint.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,41 @@ | ||
#!/bin/sh | ||
|
||
# Check/Set default values to optional environment variables | ||
: "${GRDF_USERNAME:?GRDF_USERNAME is required and not set.}" | ||
: "${GRDF_PASSWORD:?GRDF_PASSWORD is required and not set.}" | ||
: "${GRDF_PCE_IDENTIFIER:?GRDF_PCE_IDENTIFIER is required and not set.}" | ||
: "${GRDF_SCAN_INTERVAL:="480"}" # 8 hours | ||
: "${GRDF_LAST_DAYS:="1095"}" # 3 years | ||
|
||
: "${HOMEASSISTANT_HOST:?HOMEASSISTANT_HOST is required and not set.}" | ||
: "${HOMEASSISTANT_PORT:="8123"}" # Default Home Assistant port | ||
: "${HOMEASSISTANT_TOKEN:?HOMEASSISTANT_TOKEN is required and not set.}" | ||
|
||
# Display environment variables | ||
echo "GRDF_USERNAME: ${GRDF_USERNAME}" | ||
echo "GRDF_PASSWORD: ***************" | ||
echo "GRDF_PCE_IDENTIFIER: ${GRDF_PCE_IDENTIFIER}" | ||
echo "GRDF_SCAN_INTERVAL: ${GRDF_SCAN_INTERVAL}" | ||
echo "GRDF_LAST_DAYS: ${GRDF_LAST_DAYS}" | ||
echo "HOMEASSISTANT_HOST: ${HOMEASSISTANT_HOST}" | ||
echo "HOMEASSISTANT_PORT: ${HOMEASSISTANT_PORT}" | ||
echo "HOMEASSISTANT_TOKEN: ***************" | ||
|
||
# Export environment variables | ||
export GRDF_USERNAME GRDF_PASSWORD GRDF_PCE_IDENTIFIER GRDF_SCAN_INTERVAL GRDF_LAST_DAYS HOMEASSISTANT_HOST HOMEASSISTANT_PORT HOMEASSISTANT_TOKEN | ||
|
||
# Instantiate the template config | ||
if [ ! -e /app/config/configuration.yaml ]; then | ||
envsubst < "/app/configuration.template.yaml" > "/app/config/configuration.yaml" | ||
fi | ||
|
||
# Instantiate the template secrets | ||
if [ ! -e /app/config/secrets.yaml ]; then | ||
envsubst < "/app/secrets.template.yaml" > "/app/config/secrets.yaml" | ||
fi | ||
|
||
# Run the gazpar2haws python program | ||
cd /app | ||
python3 -m gazpar2haws | ||
#!/bin/sh | ||
|
||
# Check/Set default values to optional environment variables | ||
: "${GRDF_USERNAME:?GRDF_USERNAME is required and not set.}" | ||
: "${GRDF_PASSWORD:?GRDF_PASSWORD is required and not set.}" | ||
: "${GRDF_PCE_IDENTIFIER:?GRDF_PCE_IDENTIFIER is required and not set.}" | ||
: "${GRDF_SCAN_INTERVAL:="480"}" # 8 hours | ||
: "${GRDF_LAST_DAYS:="1095"}" # 3 years | ||
|
||
: "${HOMEASSISTANT_HOST:?HOMEASSISTANT_HOST is required and not set.}" | ||
: "${HOMEASSISTANT_PORT:="8123"}" # Default Home Assistant port | ||
: "${HOMEASSISTANT_ENDPOINT:="/api/websocket"}" # Default Home Assistant endpoint | ||
: "${HOMEASSISTANT_TOKEN:?HOMEASSISTANT_TOKEN is required and not set.}" | ||
|
||
# Display environment variables | ||
echo "GRDF_USERNAME: ${GRDF_USERNAME}" | ||
echo "GRDF_PASSWORD: ***************" | ||
echo "GRDF_PCE_IDENTIFIER: ${GRDF_PCE_IDENTIFIER}" | ||
echo "GRDF_SCAN_INTERVAL: ${GRDF_SCAN_INTERVAL}" | ||
echo "GRDF_LAST_DAYS: ${GRDF_LAST_DAYS}" | ||
echo "HOMEASSISTANT_HOST: ${HOMEASSISTANT_HOST}" | ||
echo "HOMEASSISTANT_ENDPOINT: ${HOMEASSISTANT_ENDPOINT}" | ||
echo "HOMEASSISTANT_PORT: ${HOMEASSISTANT_PORT}" | ||
echo "HOMEASSISTANT_TOKEN: ***************" | ||
|
||
# Export environment variables | ||
export GRDF_USERNAME GRDF_PASSWORD GRDF_PCE_IDENTIFIER GRDF_SCAN_INTERVAL GRDF_LAST_DAYS HOMEASSISTANT_HOST HOMEASSISTANT_PORT HOMEASSISTANT_ENDPOINT HOMEASSISTANT_TOKEN | ||
|
||
# Instantiate the template config | ||
if [ ! -e /app/config/configuration.yaml ]; then | ||
envsubst < "/app/configuration.template.yaml" > "/app/config/configuration.yaml" | ||
fi | ||
|
||
# Instantiate the template secrets | ||
if [ ! -e /app/config/secrets.yaml ]; then | ||
envsubst < "/app/secrets.template.yaml" > "/app/config/secrets.yaml" | ||
fi | ||
|
||
# Run the gazpar2haws python program | ||
cd /app | ||
python3 -m gazpar2haws |
Oops, something went wrong.