Skip to content

Commit

Permalink
Fix pre-commit
Browse files Browse the repository at this point in the history
  • Loading branch information
elad-bar committed Apr 27, 2021
1 parent a2ee59d commit 325d0d2
Show file tree
Hide file tree
Showing 13 changed files with 128 additions and 67 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/constraints.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
pip==20.3.3
pre-commit==2.9.3
nox==2020.12.31
2 changes: 2 additions & 0 deletions .github/workflows/hassfest.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
---

name: Validate with hassfest

on:
Expand Down
46 changes: 34 additions & 12 deletions .github/workflows/pre-commit.yaml
Original file line number Diff line number Diff line change
@@ -1,20 +1,42 @@
name: pre-commit
name: Linting

on:
pull_request:
push:
branches: [master]
branches:
- main
- master
- dev
pull_request:

jobs:
pre-commit:
runs-on: ubuntu-latest
name: pre-commit
steps:
- uses: actions/checkout@v1
- uses: actions/setup-python@v1
- name: set PY
run: echo "::set-env name=PY::$(python -c 'import hashlib, sys;print(hashlib.sha256(sys.version.encode()+sys.executable.encode()).hexdigest())')"
- uses: actions/cache@v1
with:
path: ~/.cache/pre-commit
key: pre-commit|${{ env.PY }}|${{ hashFiles('.pre-commit-config.yaml') }}
- uses: pre-commit/[email protected]
- uses: actions/[email protected]
- uses: actions/[email protected]
with:
python-version: "3.9"
- run: |
pip install --constraint=.github/workflows/constraints.txt pip
pip install --constraint=.github/workflows/constraints.txt pre-commit
- name: Compute cache key prefix
if: matrix.os != 'windows-latest'
id: cache_key_prefix
shell: python
run: |
import hashlib
import sys
python = "py{}.{}".format(*sys.version_info[:2])
payload = sys.version.encode() + sys.executable.encode()
digest = hashlib.sha256(payload).hexdigest()
result = "${{ runner.os }}-{}-{}-pre-commit".format(python, digest)
print("::set-output name=result::{}".format(result))
- uses: actions/[email protected]
if: matrix.os != 'windows-latest'
with:
path: ~/.cache/pre-commit
key: ${{ steps.cache_key_prefix.outputs.result }}-${{ hashFiles('.pre-commit-config.yaml') }}
restore-keys: |
${{ steps.cache_key_prefix.outputs.result }}-
- run: pre-commit run --all-files --show-diff-on-failure --color=always
57 changes: 46 additions & 11 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,28 +1,63 @@
---

repos:
- repo: https://github.com/asottile/pyupgrade
rev: v2.1.0
rev: v2.7.2
hooks:
- id: pyupgrade
args: [--py37-plus]
args: [--py38-plus]
- repo: https://github.com/psf/black
rev: 19.10b0
rev: 20.8b1
hooks:
- id: black
args:
- --safe
- --quiet
files: ^((homeassistant|script|tests)/.+)?[^/]+\.py$
- repo: https://github.com/codespell-project/codespell
rev: v2.0.0
hooks:
- id: codespell
args:
- --ignore-words-list=hass,alot,datas,dof,dur,ether,farenheit,hist,iff,ines,ist,lightsensor,mut,nd,pres,referer,ser,serie,te,technik,ue,uint,visability,wan,wanna,withing,iam,incomfort
- --skip="./.*,*.csv,*.json"
- --quiet-level=2
exclude_types: [csv, json]
exclude: ^tests/fixtures/
- repo: https://gitlab.com/pycqa/flake8
rev: 3.7.9
rev: 3.8.4
hooks:
- id: flake8
#additional_dependencies:
# - flake8-docstrings==1.5.0
# - pydocstyle==5.0.2
- repo: https://github.com/pre-commit/mirrors-isort
rev: v4.3.21
additional_dependencies:
- flake8-docstrings==1.5.0
- pydocstyle==5.1.1
files: ^(homeassistant|script|tests)/.+\.py$
- repo: https://github.com/PyCQA/bandit
rev: 1.7.0
hooks:
- id: bandit
args:
- --quiet
- --format=custom
- --configfile=tests/bandit.yaml
files: ^(homeassistant|script|tests)/.+\.py$
- repo: https://github.com/PyCQA/isort
rev: 5.5.3
hooks:
- id: isort
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.4.0
rev: v3.2.0
hooks:
- id: check-executables-have-shebangs
stages: [manual]
- id: check-json
exclude: (.vscode|.devcontainer)
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
- id: check-added-large-files
- repo: https://github.com/prettier/prettier
rev: 2.0.4
hooks:
- id: check-json
- id: prettier
stages: [manual]
14 changes: 7 additions & 7 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
**Implemented enhancements:**

- Moved encryption key of component to .storage directory
- Removed support for non encrypted password (**Breaking Change**)
- Removed support for non encrypted password (**Breaking Change**)

**Fixed bugs:**

Expand Down Expand Up @@ -75,7 +75,7 @@

- Fix incorrect error message displayed when WebSocket or API request failed
- Fix retry mechanism of API requests
- Fix integration's options error when device or interface list is empty
- Fix integration's options error when device or interface list is empty

## 2020-05-14

Expand All @@ -94,7 +94,7 @@

**Fixed bugs:**

- Fix redundant calculation of bits to bytes as data is already bytes
- Fix redundant calculation of bits to bytes as data is already bytes

## 2020-05-08 #1

Expand All @@ -104,7 +104,7 @@

**Fixed bugs:**

- Fix default value of unit in integration's options
- Fix default value of unit in integration's options

## 2020-05-06

Expand All @@ -129,7 +129,7 @@

- More enhancements to options, ability to change setup details
- Support new translation format of HA 0.109.0
- Added __main__.py to root directory for debugging
- Added __main__.py to root directory for debugging

## 2020-04-28 #3

Expand Down Expand Up @@ -165,7 +165,7 @@

**Implemented enhancements:**

- Simplified the way calculating whether device is connected or not, based on report of traffic analysis instead of calculating amount of traffic (bps) over the last 3 minutes [\#24](https://github.com/elad-bar/ha-edgeos/issues/24)
- Simplified the way calculating whether device is connected or not, based on report of traffic analysis instead of calculating amount of traffic (bps) over the last 3 minutes [\#24](https://github.com/elad-bar/ha-edgeos/issues/24)
- Moved service `edgeos.save_debug_data` to Integration -> Options as configuration (that being reset after doing the action once)
- Moved service `edgeos.log_events` to Integration -> Options as configuration to toggle upon need
- Added ability to configure the log level of the component from Integration - Options, more details in README
Expand Down Expand Up @@ -196,4 +196,4 @@

**Fixed bugs:**

- Login failure initiated reconnect mechanism instead of die gracefully
- Login failure initiated reconnect mechanism instead of die gracefully
30 changes: 15 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ Fields name | Type | Required | Default | Description
Name | Textbox | + | - | Represents the integration name
Host | Textbox | + | - | Hostname or IP address to access EdgeOS device
Username | Textbox | + | - | Username of user with `Operator` level access or higher, better to create a dedicated user for that integration for faster issues identification
Password | Textbox | + | - |
Unit | Drop-down | + | Bytes | Unit for sensors, available options are: Bytes, KiloBytes, MegaBytes
Password | Textbox | + | - |
Unit | Drop-down | + | Bytes | Unit for sensors, available options are: Bytes, KiloBytes, MegaBytes

###### EdgeOS Device validation errors
Errors |
--- |
--- |
Cannot reach device (404) |
Invalid credentials (403) |
General authentication error (when failed to get valid response from device) |
Expand All @@ -53,10 +53,10 @@ Fields name | Type | Required | Default | Description
--- | --- | --- | --- | --- |
Host | Textbox | + | - | Hostname or IP address to access EdgeOS device
Username | Textbox | + | - | Username of user with `Operator` level access or higher, better to create a dedicated user for that integration for faster issues identification
Password | Textbox | + | - |
Password | Textbox | + | - |
Clear credentials | Check-box | + | Unchecked | Will reset username and password (Not being stored under options)
Unit | Drop-down | + | Bytes | Unit for sensors, available options are: Bytes, KiloBytes, MegaBytes
Consider away interval | Textbox | + | 180 | Consider away interval in seconds
Unit | Drop-down | + | Bytes | Unit for sensors, available options are: Bytes, KiloBytes, MegaBytes
Consider away interval | Textbox | + | 180 | Consider away interval in seconds
Monitored devices | Drop-down | + | NONE | Devices to monitor using binary_sensor and sensor
Monitored interfaces | Drop-down | + | NONE | Interfaces to monitor using binary_sensor and sensor,
Track | Drop-down | + | NONE | Devices to track using device_trac
Expand All @@ -65,7 +65,7 @@ Update Entities Interval | Textbox | + | 1 | Number of seconds to update entitie
Save debug file | Check-box | + | Unchecked | Will store debug file, more details below (Not being stored under options)
Log level | Drop-down | + | Default | Changes component's log level (more details below)
Log incoming messages | Check-box | + | Unchecked | Whether to log as DEBUG incoming web-socket messages or not

###### Log Level's drop-down
New feature to set the log level for the component without need to set log_level in `customization:` and restart or call manually `logger.set_level` and loose it after restart.

Expand All @@ -75,28 +75,28 @@ In case `Default` option is chosen, flow will skip calling the service, after ch

###### Save debug file
Will store debug data from the component to HA CONFIG path named `edgeos_data.log`

## Components
#### Default
Name | Type | State | Attributes |
--- | --- | --- | --- |
--- | --- | --- | --- |
{Integration Name} System Status | Binary Sensor | Connected or not | CPU<br /> Memory<br /> Up-time<br /> API Last Update<br /> WS Last Update
{Integration Name} System Uptime | Sensor | Time since restart in seconds | CPU<br /> Memory<br /> Is Alive<br /> API Last Update<br /> WS Last Update
{Integration Name} Unknown Devices | Sensor | Number of unknown devices | Unknown Devices description

#### Monitored Devices
#### Monitored Devices
Name | Type | State | Attributes |
--- | --- | --- | --- |
--- | --- | --- | --- |
{Integration Name} Device {Device Name} | Binary Sensor | Connected or not | IP<br /> MAC<br /> Name<br /> {Unit}Bytes (Sent)<br /> {Unit}Bytes/ps (Sent)<br />{Unit}Bytes (Received)<br />{Unit}Bytes/ps (Received)<br />Last Activity<br />Last Changed

#### Monitored Interfaces
#### Monitored Interfaces
Name | Type | State | Attributes |
--- | --- | --- | --- |
--- | --- | --- | --- |
{Integration Name} Interface {Interface Name} | Binary Sensor | Connected or not | Name<br /> Duplex<br /> Link Speed (Mbps)<br /> address<br /> Packets (Received)<br />Packets (Sent)<br /> Errors (Received)<br />Errors (Sent)<br />Dropped packets (Received)<br />Dropped packets (Sent)<br/>{Unit}Bytes (Received)<br/>{Unit}Bytes (Sent)<br/>{Unit}Bytes/ps (Received)<br/>{Unit}Bytes/ps (Sent)<br />Multicast<br />Last Changed

#### Tracked Devices
Name | Type | State | Attributes |
--- | --- | --- | --- |
--- | --- | --- | --- |
{Integration Name} {Device Name} | Device Tracker | Home or Away | Host<br /> IP<br /> MAC<br /> Name<br /> Last Activity<br /> Connected

### Setting up the integration
Expand Down
4 changes: 2 additions & 2 deletions __main__.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import asyncio
import logging

from test_consts import *

from custom_components.edgeos.managers.configuration_manager import ConfigManager
from custom_components.edgeos.managers.data_manager import EdgeOSData
from custom_components.edgeos.managers.password_manager import PasswordManager
from custom_components.edgeos.managers.version_check import VersionCheck
from custom_components.edgeos.models.config_data import ConfigData
from test_consts import *

from homeassistant.core import HomeAssistant

logging.basicConfig(filename="log.txt", filemode="a", level="DEBUG")
Expand Down
2 changes: 1 addition & 1 deletion _config.yml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
theme: jekyll-theme-slate
theme: jekyll-theme-slate
1 change: 0 additions & 1 deletion custom_components/edgeos/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
async_setup_base_entry,
)
from custom_components.edgeos.models.entity_data import EntityData

from homeassistant.core import HomeAssistant

_LOGGER = logging.getLogger(__name__)
Expand Down
2 changes: 1 addition & 1 deletion edgeos.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@
"https://raw.githubusercontent.com/elad-bar/ha-edgeos/master/custom_components/edgeos/manifest.json"
]
}
}
}
30 changes: 15 additions & 15 deletions info.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ Fields name | Type | Required | Default | Description
Name | Textbox | + | - | Represents the integration name
Host | Textbox | + | - | Hostname or IP address to access EdgeOS device
Username | Textbox | + | - | Username of user with `Operator` level access or higher, better to create a dedicated user for that integration for faster issues identification
Password | Textbox | + | - |
Unit | Drop-down | + | Bytes | Unit for sensors, available options are: Bytes, KiloBytes, MegaBytes
Password | Textbox | + | - |
Unit | Drop-down | + | Bytes | Unit for sensors, available options are: Bytes, KiloBytes, MegaBytes

###### EdgeOS Device validation errors
Errors |
--- |
--- |
Cannot reach device (404) |
Invalid credentials (403) |
General authentication error (when failed to get valid response from device) |
Expand All @@ -53,10 +53,10 @@ Fields name | Type | Required | Default | Description
--- | --- | --- | --- | --- |
Host | Textbox | + | - | Hostname or IP address to access EdgeOS device
Username | Textbox | + | - | Username of user with `Operator` level access or higher, better to create a dedicated user for that integration for faster issues identification
Password | Textbox | + | - |
Password | Textbox | + | - |
Clear credentials | Check-box | + | Unchecked | Will reset username and password (Not being stored under options)
Unit | Drop-down | + | Bytes | Unit for sensors, available options are: Bytes, KiloBytes, MegaBytes
Consider away interval | Textbox | + | 180 | Consider away interval in seconds
Unit | Drop-down | + | Bytes | Unit for sensors, available options are: Bytes, KiloBytes, MegaBytes
Consider away interval | Textbox | + | 180 | Consider away interval in seconds
Monitored devices | Drop-down | + | NONE | Devices to monitor using binary_sensor and sensor
Monitored interfaces | Drop-down | + | NONE | Interfaces to monitor using binary_sensor and sensor,
Track | Drop-down | + | NONE | Devices to track using device_trac
Expand All @@ -65,7 +65,7 @@ Update Entities Interval | Textbox | + | 1 | Number of seconds to update entitie
Save debug file | Check-box | + | Unchecked | Will store debug file, more details below (Not being stored under options)
Log level | Drop-down | + | Default | Changes component's log level (more details below)
Log incoming messages | Check-box | + | Unchecked | Whether to log as DEBUG incoming web-socket messages or not

###### Log Level's drop-down
New feature to set the log level for the component without need to set log_level in `customization:` and restart or call manually `logger.set_level` and loose it after restart.

Expand All @@ -75,28 +75,28 @@ In case `Default` option is chosen, flow will skip calling the service, after ch

###### Save debug file
Will store debug data from the component to HA CONFIG path named `edgeos_data.log`

## Components
#### Default
Name | Type | State | Attributes |
--- | --- | --- | --- |
--- | --- | --- | --- |
{Integration Name} System Status | Binary Sensor | Connected or not | CPU<br /> Memory<br /> Up-time<br /> API Last Update<br /> WS Last Update
{Integration Name} System Uptime | Sensor | Time since restart in seconds | CPU<br /> Memory<br /> Is Alive<br /> API Last Update<br /> WS Last Update
{Integration Name} Unknown Devices | Sensor | Number of unknown devices | Unknown Devices description

#### Monitored Devices
#### Monitored Devices
Name | Type | State | Attributes |
--- | --- | --- | --- |
--- | --- | --- | --- |
{Integration Name} Device {Device Name} | Binary Sensor | Connected or not | IP<br /> MAC<br /> Name<br /> {Unit}Bytes (Sent)<br /> {Unit}Bytes/ps (Sent)<br />{Unit}Bytes (Received)<br />{Unit}Bytes/ps (Received)<br />Last Activity<br />Last Changed

#### Monitored Interfaces
#### Monitored Interfaces
Name | Type | State | Attributes |
--- | --- | --- | --- |
--- | --- | --- | --- |
{Integration Name} Interface {Interface Name} | Binary Sensor | Connected or not | Name<br /> Duplex<br /> Link Speed (Mbps)<br /> address<br /> Packets (Received)<br />Packets (Sent)<br /> Errors (Received)<br />Errors (Sent)<br />Dropped packets (Received)<br />Dropped packets (Sent)<br/>{Unit}Bytes (Received)<br/>{Unit}Bytes (Sent)<br/>{Unit}Bytes/ps (Received)<br/>{Unit}Bytes/ps (Sent)<br />Multicast<br />Last Changed

#### Tracked Devices
Name | Type | State | Attributes |
--- | --- | --- | --- |
--- | --- | --- | --- |
{Integration Name} {Device Name} | Device Tracker | Home or Away | Host<br /> IP<br /> MAC<br /> Name<br /> Last Activity<br /> Connected

### Setting up the integration
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[tool.black]
target-version = ["py37", "py38"]
target-version = ["py38"]
Loading

0 comments on commit 325d0d2

Please sign in to comment.