-
-
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.
- Loading branch information
1 parent
c804afc
commit 954caf6
Showing
38 changed files
with
1,996 additions
and
489 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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
name: Validate with hassfest | ||
|
||
on: | ||
push: | ||
pull_request: | ||
schedule: | ||
- cron: "0 0 * * *" | ||
|
||
jobs: | ||
validate: | ||
runs-on: "ubuntu-latest" | ||
steps: | ||
- uses: "actions/checkout@v2" | ||
- uses: home-assistant/actions/hassfest@master |
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 |
---|---|---|
@@ -0,0 +1,34 @@ | ||
name: Release Workflow | ||
|
||
on: | ||
release: | ||
types: | ||
- published | ||
|
||
jobs: | ||
release: | ||
name: Release | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout the repository | ||
uses: actions/checkout@v4 | ||
- name: Get integration information | ||
id: information | ||
run: | | ||
name=$(find custom_components/ -type d -maxdepth 1 | tail -n 1 | cut -d "/" -f2) | ||
echo "name=$name" >> $GITHUB_OUTPUT | ||
- name: Adjust version number | ||
shell: bash | ||
run: | | ||
yq -i -o json '.version="${{ github.event.release.tag_name }}"' \ | ||
"${{ github.workspace }}/custom_components/${{ steps.information.outputs.name }}/manifest.json" | ||
- name: Create zip file for the integration | ||
shell: bash | ||
run: | | ||
cd "${{ github.workspace }}/custom_components/${{ steps.information.outputs.name }}" | ||
zip ${{ steps.information.outputs.name }}.zip -r ./ | ||
- name: Upload the zipfile as a release asset | ||
uses: softprops/action-gh-release@v1 | ||
with: | ||
files: ${{ github.workspace }}/custom_components/${{ steps.information.outputs.name }}/${{ steps.information.outputs.name }}.zip | ||
tag_name: ${{ github.event.release.tag_name }} |
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
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 |
---|---|---|
@@ -0,0 +1,53 @@ | ||
repos: | ||
- repo: https://github.com/astral-sh/ruff-pre-commit | ||
rev: v0.1.8 | ||
hooks: | ||
- id: ruff | ||
args: | ||
- --fix | ||
- id: ruff-format | ||
files: ^((custom_components/ha-mysmartbike|pylint|script|tests|simulator)/.+)?[^/]+\.py$ | ||
# - repo: https://github.com/codespell-project/codespell | ||
# rev: v2.2.2 | ||
# hooks: | ||
# - id: codespell | ||
# args: | ||
# - --ignore-words-list=alle,Sie,oder,additionals,alle,alot,bund,currenty,datas,farenheit,falsy,fo,haa,hass,iif,incomfort,ines,ist,nam,nd,pres,pullrequests,resset,rime,ser,serie,te,technik,ue,unsecure,withing,zar | ||
# - --skip="./.*,*.csv,*.json,*.ambr" | ||
# - --quiet-level=2 | ||
# exclude_types: [csv, json] | ||
# exclude: ^tests/fixtures/|homeassistant/generated/|tests/components/.*/snapshots/ | ||
- repo: https://github.com/adrienverge/yamllint.git | ||
rev: v1.32.0 | ||
hooks: | ||
- id: yamllint | ||
- repo: https://github.com/pre-commit/mirrors-prettier | ||
rev: v3.0.3 | ||
hooks: | ||
- id: prettier | ||
- repo: https://github.com/cdce8p/python-typing-update | ||
rev: v0.6.0 | ||
hooks: | ||
# Run `python-typing-update` hook manually from time to time | ||
# to update python typing syntax. | ||
# Will require manual work, before submitting changes! | ||
# pre-commit run --hook-stage manual python-typing-update --all-files | ||
- id: python-typing-update | ||
stages: [manual] | ||
args: | ||
- --py311-plus | ||
- --force | ||
- --keep-updates | ||
files: ^(custom_components/ha-mysmartbike|tests|script|simulator)/.+\.py$ | ||
- repo: local | ||
hooks: | ||
- id: const-check-simulator-not-disabled | ||
name: const-check-simulator-not-disabled | ||
entry: "USE_SIMULATOR = True" | ||
language: pygrep | ||
types: [python] | ||
- id: const-check-proxy-not-disabled | ||
name: const-check-proxy-not-disabled | ||
entry: "USE_PROXY = True" | ||
language: pygrep | ||
types: [python] |
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 |
---|---|---|
@@ -0,0 +1,62 @@ | ||
ignore: | | ||
azure-*.yml | ||
rules: | ||
braces: | ||
level: error | ||
min-spaces-inside: 0 | ||
max-spaces-inside: 1 | ||
min-spaces-inside-empty: -1 | ||
max-spaces-inside-empty: -1 | ||
brackets: | ||
level: error | ||
min-spaces-inside: 0 | ||
max-spaces-inside: 0 | ||
min-spaces-inside-empty: -1 | ||
max-spaces-inside-empty: -1 | ||
colons: | ||
level: error | ||
max-spaces-before: 0 | ||
max-spaces-after: 1 | ||
commas: | ||
level: error | ||
max-spaces-before: 0 | ||
min-spaces-after: 1 | ||
max-spaces-after: 1 | ||
comments: | ||
level: error | ||
require-starting-space: true | ||
min-spaces-from-content: 1 | ||
comments-indentation: | ||
level: error | ||
document-end: | ||
level: error | ||
present: false | ||
document-start: | ||
level: error | ||
present: false | ||
empty-lines: | ||
level: error | ||
max: 1 | ||
max-start: 0 | ||
max-end: 1 | ||
hyphens: | ||
level: error | ||
max-spaces-after: 1 | ||
indentation: | ||
level: error | ||
spaces: 2 | ||
indent-sequences: true | ||
check-multi-line-strings: false | ||
key-duplicates: | ||
level: error | ||
line-length: disable | ||
new-line-at-end-of-file: | ||
level: error | ||
new-lines: | ||
level: error | ||
type: unix | ||
trailing-spaces: | ||
level: error | ||
truthy: | ||
level: error | ||
allowed-values: ['true', 'false', 'on'] |
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
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
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
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 |
---|---|---|
@@ -0,0 +1,52 @@ | ||
"""The Link2Home integration.""" | ||
from __future__ import annotations | ||
|
||
from homeassistant.config_entries import ConfigEntry | ||
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME | ||
from homeassistant.core import HomeAssistant | ||
from homeassistant.helpers.aiohttp_client import async_get_clientsession | ||
|
||
from .const import DOMAIN, LOGGER, MYSMARTBIKE_PLATFORMS | ||
from .coordinator import MySmartBikeDataUpdateCoordinator | ||
|
||
|
||
async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry): | ||
"""Set up Link2Home from a config entry.""" | ||
|
||
username: str = config_entry.options[CONF_USERNAME] | ||
password: str = config_entry.options[CONF_PASSWORD] | ||
|
||
websession = async_get_clientsession(hass) | ||
|
||
coordinator = MySmartBikeDataUpdateCoordinator(hass, websession, username, password) | ||
await coordinator.async_init() | ||
|
||
await coordinator.async_config_entry_first_refresh() | ||
|
||
hass.data.setdefault(DOMAIN, {})[config_entry.entry_id] = coordinator | ||
|
||
await hass.config_entries.async_forward_entry_setups(config_entry, MYSMARTBIKE_PLATFORMS) | ||
|
||
config_entry.add_update_listener(config_entry_update_listener) | ||
|
||
return True | ||
|
||
|
||
async def config_entry_update_listener(hass: HomeAssistant, entry: ConfigEntry) -> None: | ||
"""Update listener, called when the config entry options are changed.""" | ||
LOGGER.debug("Start config_entry_update_listener") | ||
await hass.config_entries.async_reload(entry.entry_id) | ||
|
||
|
||
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry): | ||
"""Unload a config entry.""" | ||
LOGGER.debug("Start async_unload_entry") | ||
|
||
# coordinator: MySmartBikeDataUpdateCoordinator = hass.data[DOMAIN][entry.entry_id] | ||
|
||
unload_ok = await hass.config_entries.async_unload_platforms(entry, MYSMARTBIKE_PLATFORMS) | ||
|
||
if unload_ok: | ||
hass.data[DOMAIN].pop(entry.entry_id) | ||
|
||
return unload_ok |
Oops, something went wrong.