Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
chriscamicas committed Nov 27, 2023
0 parents commit c70342f
Show file tree
Hide file tree
Showing 24 changed files with 4,935 additions and 0 deletions.
17 changes: 17 additions & 0 deletions .github/workflows/hacs-action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: HACS Action

on:
push:
pull_request:

jobs:
hacs:
name: HACS Action
runs-on: "ubuntu-latest"
steps:
- uses: "actions/checkout@v2"
- name: HACS Action
uses: "hacs/action@main"
with:
category: "integration"
ignore: archived, brands, requirements
12 changes: 12 additions & 0 deletions .github/workflows/hassfest-action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: Validate with hassfest

on:
push:
pull_request:

jobs:
validate:
runs-on: "ubuntu-latest"
steps:
- uses: "actions/checkout@v2"
- uses: "home-assistant/actions/hassfest@master"
129 changes: 129 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
pip-wheel-metadata/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
.python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/
8 changes: 8 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"python.analysis.typeCheckingMode": "basic",
"python.testing.pytestArgs": [
"tests"
],
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true
}
17 changes: 17 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "Deploy",
"type": "shell",
"command": "scp -r ./custom_components/gazdebordeaux hass:/root/homeassistant/custom_components",
"problemMatcher": [],
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# 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).

## [1.0.0] - 2023-11-27
21 changes: 21 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2023 Christophe Camicas

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
94 changes: 94 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
# Home Assistant Gaz De Bordeaux integration
Since Gaz De Bordeaux is a France specific provider, this README is in French

## Installation
### Method 1 : HACS (recommended)

Follow the steps described below to add GrDF Gazpar integration with [HACS](https://hacs.xyz/):

1. From [HACS](https://hacs.xyz/) (Home Assistant Community Store), open the upper left menu and select `Custom repositories` option to add the new repo.

2. Add the address <https://github.com/chriscamicas/gazdebordeaux-ha> with the category `Integration`, and click `ADD`. The new corresponding repo appears in the repo list.

3. Select this repo (this integration description is displayed in a window) and click on `INSTALL THIS REPOSITORY` button on the lower right of this window.

4. Keep the last version and click the button `INSTALL` on the lower right.

5. Do click on `RELOAD` button for completion! The integration is now ready. It remains the configuration.

### Method 2 : Manual

Copy the gazdebordeaux directory in HA config/custom_components/gazdebordeaux directory.

`scp -r ./gazdebordeaux hass:/root/config/custom_components`

## Configuration
After the installation, restart your HA application. You could now add the `Gaz De Bordeaux` directly like any other integration. You should be prompted with a form asking for your login and password.
This is the login you should use to check your consumption on the following website: https://life.gazdebordeaux.fr/

## Home Assistant Energy module integration

You probably want to integrate Gaz De Bordeaux data into the Home Assistant Energy module.

![Dashboard](images/energy_module.png)

In Home Assistant energy configuration panel, you can set directly the sensor `gazdebordeaux:energy_consumption` in the gas consumption section, and `sensor.currently_bill_cost_to_date`

## Specific dashboard

If you prefer a specific dashboard to the Energy module, I recommend using the following template
```yaml
- title: Energy
path: energy
icon: mdi:lightning-bolt
type: sidebar
badges: []
cards:
- chart_type: line
period: day
type: statistics-graph
entities:
- entity: gazdebordeaux:energy_consumption
name: Conso
stat_types:
- state
title: Conso kWh
hide_legend: true
- type: statistic
entity: gazdebordeaux:energy_consumption
period:
calendar:
period: month
stat_type: change
view_layout:
position: sidebar
name: Month consumption
- type: statistic
entity: gazdebordeaux:energy_cost
period:
calendar:
period: month
stat_type: change
unit:
view_layout:
position: sidebar
name: Month cost
- type: entities
entities:
- entity: sensor.current_bill_gas_cost_to_date
icon: mdi:currency-eur
- entity: sensor.current_bill_gas_usage_to_date
- entity: sensor.current_energy_usage_to_date
view_layout:
position: sidebar
- chart_type: line
period: day
type: statistics-graph
entities:
- entity: gazdebordeaux:energy_cost
name: Coût
stat_types:
- state
hide_legend: true
title: Coût €
```
31 changes: 31 additions & 0 deletions custom_components/gazdebordeaux/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
"""The Gaz de Bordeaux integration."""
from __future__ import annotations

from homeassistant.config_entries import ConfigEntry
from homeassistant.const import Platform
from homeassistant.core import HomeAssistant

from .const import DOMAIN
from .coordinator import GdbCoordinator

PLATFORMS: list[Platform] = [Platform.SENSOR]


async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Set up Gaz de Bordeaux from a config entry."""

coordinator = GdbCoordinator(hass, entry.data)
await coordinator.async_config_entry_first_refresh()
hass.data.setdefault(DOMAIN, {})[entry.entry_id] = coordinator

await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)

return True


async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Unload a config entry."""
if unload_ok := await hass.config_entries.async_unload_platforms(entry, PLATFORMS):
hass.data[DOMAIN].pop(entry.entry_id)

return unload_ok
Loading

0 comments on commit c70342f

Please sign in to comment.