Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 26 additions & 26 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
// See https://aka.ms/vscode-remote/devcontainer.json for format details.
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/python
{
"image": "ludeeus/container:integration-debian",
"name": "Blueprint integration development",
"context": "..",
"appPort": ["9123:8123"],
"postCreateCommand": "container install",
"extensions": [
"ms-python.python",
"github.vscode-pull-request-github",
"ryanluker.vscode-coverage-gutters",
"ms-python.vscode-pylance"
],
"settings": {
"files.eol": "\n",
"editor.tabSize": 4,
"terminal.integrated.shell.linux": "/bin/bash",
"python.pythonPath": "/usr/bin/python3",
"python.analysis.autoSearchPaths": false,
"python.linting.pylintEnabled": true,
"python.linting.enabled": true,
"python.formatting.provider": "black",
"editor.formatOnPaste": false,
"editor.formatOnSave": true,
"editor.formatOnType": true,
"files.trimTrailingWhitespace": true
}
"name": "Python 3",
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
"image": "mcr.microsoft.com/devcontainers/python:1-3.12-bullseye",

// Use 'postCreateCommand' to run commands after the container is created.
"postCreateCommand": "pip install poetry setuptools wheel && zsh",
"runArgs": ["-e", "GIT_EDITOR=code --wait", "--network=host"],
// Configure tool-specific properties.
"customizations": {
"vscode": {
"extensions": [
"ms-python.python",
"github.vscode-pull-request-github",
"ryanluker.vscode-coverage-gutters",
"ms-python.vscode-pylance"
],
"settings": {
"files.eol": "\n",
"editor.tabSize": 4,
"terminal.integrated.shell.linux": "/bin/zsh"
}
}
},
"remoteUser": "root"
}
34 changes: 16 additions & 18 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,29 +50,27 @@ jobs:
shell: bash
run: echo ::set-output name=version::$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info))")

- name: 🏗 Install poetry
uses: abatilo/[email protected]
with:
poetry-version: 1.1.8
#- name: 🏗 Install poetry
# uses: abatilo/[email protected]
# with:
# poetry-version: 1.1.8

- name: 🔧 Set up cache
uses: actions/cache@v2
id: cache
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.full-python-version.outputs.version }}-${{ hashFiles('**/poetry.lock') }}
#- name: 🔧 Set up cache
# uses: actions/cache@v2
# id: cache
# with:
# path: .venv
# key: venv-${{ runner.os }}-${{ steps.full-python-version.outputs.version }}-${{ hashFiles('**/poetry.lock') }}

- name: 🔧 Ensure cache is healthy
if: steps.cache.outputs.cache-hit == 'true'
shell: bash
run: timeout 10s poetry run pip --version || rm -rf .venv
#- name: 🔧 Ensure cache is healthy
# if: steps.cache.outputs.cache-hit == 'true'
# shell: bash
# run: timeout 10s poetry run pip --version || rm -rf .venv

- name: 🏗 Install dependencies
shell: bash
run: poetry install
run: pip install -e .[dev]

- name: ✅ Run pytest
shell: bash
run: |
poetry run \
python -m pytest -qq --durations=10 -n auto -p no:sugar
run: python -m pytest -qq --durations=10 -n auto -p no:sugar
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ venv
.coverage
.mypy_cache
.pytest_cache
*.whl
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"python.formatting.provider": "black",
"python.sortImports.args": ["--profile", "black"],
"editor.codeActionsOnSave": {
"source.organizeImports": true
"source.organizeImports": "explicit"
},
"python.linting.enabled": true,
"python.linting.flake8Enabled": true
Expand Down
12 changes: 12 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "Copy custom_components into Home Assistant",
"type": "shell",
"command": "cp -r ${workspaceFolder}/custom_components ${workspaceFolder}/../core/config",
"problemMatcher": []
},
{
"label": "Copy back custom_components from Home Assistant",
"type": "shell",
"command": "cp -r ${workspaceFolder}/../core/config/custom_components ${workspaceFolder}",
"problemMatcher": []
},
{
"label": "Run Home Assistant on port 9123",
"type": "shell",
Expand Down
10 changes: 5 additions & 5 deletions custom_components/uhoo/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,23 @@
import asyncio
from typing import Dict, List

from pyuhoo import Client
from pyuhoo.device import Device
from pyuhoo.errors import UhooError, UnauthorizedError
from .pyuhoo.pyuhoo import Client
from .pyuhoo.pyuhoo.device import Device
from .pyuhoo.pyuhoo.errors import UhooError, UnauthorizedError

from homeassistant.config_entries import ConfigEntry
from homeassistant.const import UnitOfPressure, UnitOfTemperature, CONF_PASSWORD, CONF_USERNAME
from homeassistant.core_config import Config
from homeassistant.core import HomeAssistant
from homeassistant.exceptions import ConfigEntryNotReady
from homeassistant.helpers.aiohttp_client import async_get_clientsession
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed
from homeassistant.helpers.typing import ConfigType

from .const import DOMAIN, LOGGER, PLATFORMS, STARTUP_MESSAGE, UPDATE_INTERVAL

# https://github.com/home-assistant/example-custom-config/tree/master/custom_components

async def async_setup(hass: HomeAssistant, config: Config) -> bool:
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up all platforms for this device/entry."""
return True

Expand Down
4 changes: 2 additions & 2 deletions custom_components/uhoo/config_flow.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Config flow for uHoo."""

from pyuhoo import Client
from pyuhoo.errors import UnauthorizedError
from .pyuhoo.pyuhoo import Client
from .pyuhoo.pyuhoo.errors import UnauthorizedError
import voluptuous as vol

from homeassistant.config_entries import (
Expand Down
4 changes: 2 additions & 2 deletions custom_components/uhoo/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
MODEL = "uHoo Indoor Air Monitor"
MANUFACTURER = "uHoo"
DOMAIN = "uhoo"
VERSION = "0.0.4"
ISSUE_URL = "https://github.com/csacca/uhoo-homeassistant/issues"
VERSION = "0.0.7"
ISSUE_URL = "https://github.com/andrewleech/uhoo-homeassistant/issues"

# Platforms
SENSOR = "sensor"
Expand Down
22 changes: 16 additions & 6 deletions custom_components/uhoo/manifest.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
{
"domain": "uhoo",
"name": "uHoo",
"documentation": "https://github.com/csacca/uhoo-homeassistant",
"iot_class": "cloud_polling",
"issue_tracker": "https://github.com/csacca/uhoo-homeassistant/issues",
"version": "0.0.5",
"codeowners": [
"@andrewleech",
"@csacca",
"@srescio"
],
"config_flow": true,
"codeowners": ["@andrewleech", "@csacca"],
"requirements": ["pyuhoo @ git+https://github.com/andrewleech/pyuhoo.git@f2f05e756bd344b5571f76e3125d34ce56b7961c"]
"documentation": "https://github.com/andrewleech/uhoo-homeassistant/",
"iot_class": "cloud_polling",
"issue_tracker": "https://github.com/andrewleech/uhoo-homeassistant/issues",
"requirements": [
"aiohttp>=3.7.4",
"click>=8.0.1",
"pycryptodome>=3.10.1",
"pyyaml>=6.0",
"yarl>=1.8.1"
],
"version": "0.0.7"
}
24 changes: 24 additions & 0 deletions custom_components/uhoo/pyuhoo/.devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.194.0/containers/python-3/.devcontainer/base.Dockerfile

# [Choice] Python version: 3, 3.9, 3.8, 3.7, 3.6
ARG VARIANT="3.9"
FROM mcr.microsoft.com/vscode/devcontainers/python:0-${VARIANT}

# [Choice] Node.js version: none, lts/*, 16, 14, 12, 10
ARG NODE_VERSION="none"
RUN if [ "${NODE_VERSION}" != "none" ]; then su vscode -c "umask 0002 && . /usr/local/share/nvm/nvm.sh && nvm install ${NODE_VERSION} 2>&1"; fi

# [Optional] If your pip requirements rarely change, uncomment this section to add them to the image.
# COPY requirements.txt /tmp/pip-tmp/
# RUN pip3 --disable-pip-version-check --no-cache-dir install -r /tmp/pip-tmp/requirements.txt \
# && rm -rf /tmp/pip-tmp

# [Optional] Uncomment this section to install additional OS packages.
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
# && apt-get -y install --no-install-recommends <your-package-list-here>

# [Optional] Uncomment this line to install global node packages.
# RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && npm install -g <your-package-here>" 2>&1

# Install Poetry
RUN curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/install-poetry.py | POETRY_HOME=/usr/local python -
28 changes: 28 additions & 0 deletions custom_components/uhoo/pyuhoo/.devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"name": "Python 3",
"build": {
"dockerfile": "Dockerfile",
"context": "..",
"args": {
"VARIANT": "3.9",
"NODE_VERSION": "lts/*"
}
},
"settings": {
"python.pythonPath": "/usr/local/bin/python",
"python.languageServer": "Pylance",
"python.linting.enabled": true,
"python.linting.pylintEnabled": true,
"python.formatting.autopep8Path": "/usr/local/py-utils/bin/autopep8",
"python.formatting.blackPath": "/usr/local/py-utils/bin/black",
"python.formatting.yapfPath": "/usr/local/py-utils/bin/yapf",
"python.linting.banditPath": "/usr/local/py-utils/bin/bandit",
"python.linting.flake8Path": "/usr/local/py-utils/bin/flake8",
"python.linting.mypyPath": "/usr/local/py-utils/bin/mypy",
"python.linting.pycodestylePath": "/usr/local/py-utils/bin/pycodestyle",
"python.linting.pydocstylePath": "/usr/local/py-utils/bin/pydocstyle",
"python.linting.pylintPath": "/usr/local/py-utils/bin/pylint"
},
"extensions": ["ms-python.python", "ms-python.vscode-pylance"],
"remoteUser": "vscode"
}
11 changes: 11 additions & 0 deletions custom_components/uhoo/pyuhoo/.flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[flake8]
exclude = .git,.tox,__pycache__,.vscode,.venv,.mypy_cache
max-line-length = 88
# TODO: enable ANN aftewards
# TODO: enable PT (pytest) afterwards
# TODO: enable R for return values when __repr__ for containers is refactored
select = C,E,F,W,B,SIM,T
# the line lengths are enforced by black and docformatter
# therefore we ignore E501 and B950 here
# SIM119 - are irrelevant as we still support python 3.6 series
ignore = E501,B950,W503,E203,SIM119
Loading
Loading