Skip to content

Commit

Permalink
Updated pre-commit
Browse files Browse the repository at this point in the history
  • Loading branch information
elad-bar committed Apr 24, 2022
1 parent fc2d5f2 commit 67d9873
Show file tree
Hide file tree
Showing 14 changed files with 190 additions and 208 deletions.
8 changes: 7 additions & 1 deletion .github/workflows/hassfest.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
---

name: Validate with hassfest

on:
Expand All @@ -13,4 +12,11 @@ jobs:
runs-on: "ubuntu-latest"
steps:
- uses: "actions/checkout@v2"

- name: HACS validation
uses: "hacs/action@main"
with:
category: "integration"
ignore: brands

- uses: home-assistant/actions/hassfest@master
54 changes: 2 additions & 52 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,63 +1,13 @@
---

repos:
- repo: https://github.com/asottile/pyupgrade
rev: v2.7.2
hooks:
- id: pyupgrade
args: [--py38-plus]
- repo: https://github.com/psf/black
rev: 21.7b0
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.8.4
hooks:
- id: flake8
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: 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
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v2.2.1
hooks:
- id: prettier
stages: [manual]
20 changes: 10 additions & 10 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"configurations": [
{
"name": "Pre-commit",
"request": "launch",
"type": "python",
"cwd": "${workspaceFolder}",
"program": "${workspaceFolder}/venv/Scripts/pre-commit.exe",
"args": ["run", "--all-files", "--show-diff-on-failure", "--color=always"]
}
]
"configurations": [
{
"name": "Pre-commit",
"request": "launch",
"type": "python",
"cwd": "${workspaceFolder}",
"program": "${workspaceFolder}/venv/Scripts/pre-commit.exe",
"args": ["run", "--all-files", "--show-diff-on-failure", "--color=always"]
}
]
}
7 changes: 4 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

- Removed entity / device delete upon restarting HA
-

## 1.0.5

- Added support for long term statistics
Expand Down Expand Up @@ -81,14 +82,14 @@

- Fix disabled entities still being triggered for updates [\#52](https://github.com/elad-bar/ha-hpprinter/issues/52)
- Fix image drum OPC name [\#51](https://github.com/elad-bar/ha-hpprinter/issues/51)
- Fix Sensor 'status' stays on after power off [\#45](https://github.com/elad-bar/ha-hpprinter/issues/45)
- Fix Sensor 'status' stays on after power off [\#45](https://github.com/elad-bar/ha-hpprinter/issues/45)

## 2020-04-26

**Fixed bugs:**

- Fix disabled entities are getting enabled after periodic update (update interval)
- Fix offline printer is not updating entities correctly and after restart [\#45](https://github.com/elad-bar/ha-hpprinter/issues/45) [\#47](https://github.com/elad-bar/ha-hpprinter/issues/47)
- Fix offline printer is not updating entities correctly and after restart [\#45](https://github.com/elad-bar/ha-hpprinter/issues/45) [\#47](https://github.com/elad-bar/ha-hpprinter/issues/47)

## 2020-04-24 #6

Expand Down Expand Up @@ -130,7 +131,7 @@
**Implemented enhancements:**

- Added changelog
- Added ability to configure update entities interval in seconds (Integrations -> Integration Name -> Options) [\#31](https://github.com/elad-bar/ha-hpprinter/issues/31)
- Added ability to configure update entities interval in seconds (Integrations -> Integration Name -> Options) [\#31](https://github.com/elad-bar/ha-hpprinter/issues/31)
- Added validation to add new integration, display error in case printer is unreachable or unsupported [\#15](https://github.com/elad-bar/ha-hpprinter/issues/15) [\#11](https://github.com/elad-bar/ha-hpprinter/issues/11)
- Moved code to new file structure
- More logs added for easier debugging
Expand Down
51 changes: 32 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# HP Printer integration for Home Assistant

### Description

Configuration support multiple HP Printer devices through Configuration -> Integrations

[Changelog](https://github.com/elad-bar/ha-hpprinter/blob/master/CHANGELOG.md)
Expand All @@ -9,23 +11,26 @@ Configuration support multiple HP Printer devices through Configuration -> Integ
Look for "HP Printers Integration" and install

#### Requirements
* HP Printer supporting XML API

- HP Printer supporting XML API
to check printer's compatibility to the component try to get to the printer's XML API (replace placeholder with real IP / Hostname):
`http://{IP}//DevMgmt/ProductStatusDyn.xml`

#### Basic configuration
* Configuration should be done via Configuration -> Integrations.
* In case you are already using that integration with YAML Configuration - please remove it
* Integration supports **multiple** devices
* In the setup form, the following details are mandatory:
* Name - Unique
* Host (or IP)
* Upon submitting the form of creating an integration, a request to the printer will take place and will cause failure in case:
* Unsupported API
* Invalid server details - when cannot reach host

- Configuration should be done via Configuration -> Integrations.
- In case you are already using that integration with YAML Configuration - please remove it
- Integration supports **multiple** devices
- In the setup form, the following details are mandatory:
- Name - Unique
- Host (or IP)
- Upon submitting the form of creating an integration, a request to the printer will take place and will cause failure in case:
- Unsupported API
- Invalid server details - when cannot reach host

#### Settings for Monitoring interfaces, devices, tracked devices and update interval
*Configuration -> Integrations -> {Integration} -> Options* <br />

_Configuration -> Integrations -> {Integration} -> Options_ <br />

```
Name - Unique
Expand All @@ -36,30 +41,36 @@ Should store responses?: Check-box, saves XML and JSON files for debugging purpo
```

###### 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.

Upon startup or integration's option update, based on the value chosen, the component will make a service call to `logger.set_level` for that component with the desired value,

In case `Default` option is chosen, flow will skip calling the service, after changing from any other option to `Default`, it will not take place automatically, only after restart

###### Store responses
Stores the XML and JSON of each request and final JSON to files, Path in CONFIG_PATH/*,

Stores the XML and JSON of each request and final JSON to files, Path in CONFIG_PATH/\*,
Files that will be generated (Prefix to the file is name of the integration):
- ProductUsageDyn.XML - Raw XML from HP Printer of Usage Details
- ProductUsageDyn.json - JSON based on the Raw XML of Usage Details after transformed by the component
- ConsumableConfigDyn.XML - Raw XML from HP Printer of consumable details
- ConsumableConfigDyn.json - JSON based on the Raw XML of consumable details after transformed by the component
- ProductConfigDyn.XML - Raw XML from HP Printer of Config Details
- ProductConfigDyn.json - JSON based on the Raw XML of Config Details after transformed by the component
- Final.json - JSON based on the 2 JSONs above, merged into simpler data structure for the HA to create sensor based on

- ProductUsageDyn.XML - Raw XML from HP Printer of Usage Details
- ProductUsageDyn.json - JSON based on the Raw XML of Usage Details after transformed by the component
- ConsumableConfigDyn.XML - Raw XML from HP Printer of consumable details
- ConsumableConfigDyn.json - JSON based on the Raw XML of consumable details after transformed by the component
- ProductConfigDyn.XML - Raw XML from HP Printer of Config Details
- ProductConfigDyn.json - JSON based on the Raw XML of Config Details after transformed by the component
- Final.json - JSON based on the 2 JSONs above, merged into simpler data structure for the HA to create sensor based on

## Components:

#### Device status - Binary Sensor

```
State: connected?
```

#### Printer details - Sensor

```
State: # of pages printed
Attributes:
Expand All @@ -70,6 +81,7 @@ Attributes:
```

#### Scanner details - Sensor (For AIO only)

```
State: # of pages scanned
Attributes:
Expand All @@ -81,6 +93,7 @@ Attributes:
```

#### Cartridges details - Sensor (Per cartridge)

```
State: Remaining level %
Attributes:
Expand Down
22 changes: 11 additions & 11 deletions custom_components/hpprinter/manifest.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"domain": "hpprinter",
"name": "HP Printer",
"documentation": "https://github.com/elad-bar/ha-hpprinter",
"issue_tracker": "https://github.com/elad-bar/ha-hpprinter/issues",
"codeowners": ["@elad-bar"],
"dependencies": [],
"after_dependencies": [ "logger" ],
"requirements": ["xmltodict==0.12.0"],
"config_flow": true,
"version": "1.0.7",
"iot_class": "local_polling"
"domain": "hpprinter",
"name": "HP Printer",
"documentation": "https://github.com/elad-bar/ha-hpprinter",
"issue_tracker": "https://github.com/elad-bar/ha-hpprinter/issues",
"codeowners": ["@elad-bar"],
"dependencies": [],
"after_dependencies": ["logger"],
"requirements": ["xmltodict==0.12.0"],
"config_flow": true,
"version": "1.0.7",
"iot_class": "local_polling"
}
26 changes: 13 additions & 13 deletions custom_components/hpprinter/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,19 @@
}
},
"options": {
"step": {
"hp_printer_additional_settings": {
"title": "Options for HP Printer.",
"description": "Define additional settings for HP Printer integration",
"data": {
"host": "Host",
"name": "Name",
"update_interval": "Update interval (Seconds)",
"log_level": "Log level",
"store_data": "Should store responses?"
}
}
},
"step": {
"hp_printer_additional_settings": {
"title": "Options for HP Printer.",
"description": "Define additional settings for HP Printer integration",
"data": {
"host": "Host",
"name": "Name",
"update_interval": "Update interval (Seconds)",
"log_level": "Log level",
"store_data": "Should store responses?"
}
}
},
"error": {
"error_400": "Invalid server details, please try manually access to `http://{IP}//DevMgmt/ProductStatusDyn.xml` (Replace placeholder with IP or Hostname), in case it's accessible, please report the issue with logs",
"error_404": "Unsupported API",
Expand Down
26 changes: 13 additions & 13 deletions custom_components/hpprinter/translations/dk.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,19 @@
}
},
"options": {
"step": {
"hp_printer_additional_settings": {
"title": "Indstillinger for HP Printer.",
"description": "Definer yderligere indstillinger for HP Printer integration ",
"data": {
"host": "Vært",
"name": "Navn",
"update_interval": "Opdateringsinterval (sekunder)",
"log_level": "Log level",
"store_data": "Skal svar gemmes?"
}
}
},
"step": {
"hp_printer_additional_settings": {
"title": "Indstillinger for HP Printer.",
"description": "Definer yderligere indstillinger for HP Printer integration ",
"data": {
"host": "Vært",
"name": "Navn",
"update_interval": "Opdateringsinterval (sekunder)",
"log_level": "Log level",
"store_data": "Skal svar gemmes?"
}
}
},
"error": {
"error_400": "Ugyldige serveroplysninger, prøv venligst manuelt at få adgang til `http://{IP}//DevMgmt/ProductStatusDyn.xml` (Erstat pladsholder med IP eller værtsnavn ), hvis det er tilgængeligt, bedes du rapportere problemet med logfiler",
"error_404": "Ikke understøttet API",
Expand Down
26 changes: 13 additions & 13 deletions custom_components/hpprinter/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,19 @@
}
},
"options": {
"step": {
"hp_printer_additional_settings": {
"title": "Options for HP Printer.",
"description": "Define additional settings for HP Printer integration",
"data": {
"host": "Host",
"name": "Name",
"update_interval": "Update interval (Seconds)",
"log_level": "Log level",
"store_data": "Should store responses?"
}
}
},
"step": {
"hp_printer_additional_settings": {
"title": "Options for HP Printer.",
"description": "Define additional settings for HP Printer integration",
"data": {
"host": "Host",
"name": "Name",
"update_interval": "Update interval (Seconds)",
"log_level": "Log level",
"store_data": "Should store responses?"
}
}
},
"error": {
"error_400": "Invalid server details, please try manually access to `http://{IP}//DevMgmt/ProductStatusDyn.xml` (Replace placeholder with IP or Hostname), in case it's accessible, please report the issue with logs",
"error_404": "Unsupported API",
Expand Down
Loading

0 comments on commit 67d9873

Please sign in to comment.