Skip to content

Commit 50d7de0

Browse files
authored
Extend precommit with more hooks (#4245)
* chore: extend precommit with more hooks * chore: extend precommit with more hooks * chore: extend precommit with more hooks * chore: extend precommit with more hooks
1 parent 432b23e commit 50d7de0

28 files changed

Lines changed: 71 additions & 28 deletions

File tree

.github/workflows/lint.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,13 @@ jobs:
2222
with:
2323
activate-environment: true
2424
enable-cache: "true"
25+
cache-dependency-glob: |
26+
pyproject.toml
27+
uv.lock
2528
- run: uv sync
2629
- uses: j178/prek-action@bdca6f102f98e2b4c7029491a53dfd366469e33d # v2
30+
with:
31+
cache: true
2732
- uses: pre-commit-ci/lite-action@5d6cc0eb514c891a40562a58a8e71576c5c7fb43 # v1.1.0
2833
if: always()
2934
with:

.pre-commit-config.yaml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,30 @@ repos:
4444
types: [python]
4545
require_serial: true
4646
files: ^custom_components/powercalc
47+
- id: ty
48+
name: ty
49+
entry: uv run ty check custom_components/powercalc
50+
language: system
51+
pass_filenames: false
52+
files: ^custom_components/powercalc/.*\.py$
53+
- id: uv-lock
54+
name: uv lock --check
55+
entry: uv lock --check
56+
language: system
57+
pass_filenames: false
58+
files: ^(pyproject\.toml|uv\.lock)$
59+
- id: uv-lock-measure
60+
name: uv lock --check (utils/measure)
61+
entry: uv --directory utils/measure lock --check
62+
language: system
63+
pass_filenames: false
64+
files: ^utils/measure/(pyproject\.toml|uv\.lock)$
65+
- id: uv-lock-visualize
66+
name: uv lock --check (utils/visualize)
67+
entry: uv --directory utils/visualize lock --check
68+
language: system
69+
pass_filenames: false
70+
files: ^utils/visualize/(pyproject\.toml|uv\.lock)$
4771

4872
- repo: https://github.com/codespell-project/codespell
4973
rev: v2.4.1
@@ -55,6 +79,14 @@ repos:
5579
hooks:
5680
- id: check-github-workflows
5781
args: [ "--verbose" ]
82+
- id: check-jsonschema
83+
name: validate power profile model.json
84+
args: [--schemafile, profile_library/model_schema.json]
85+
files: ^profile_library/[^/]+/[^/]+/model\.json$
86+
- id: check-jsonschema
87+
name: validate power profile manufacturer.json
88+
args: [ --schemafile, profile_library/manufacturer_schema.json ]
89+
files: ^profile_library/[^/]+/manufacturer\.json$
5890

5991
- repo: https://github.com/rhysd/actionlint
6092
rev: v1.7.10
@@ -66,3 +98,9 @@ repos:
6698
hooks:
6799
- id: zizmor
68100
args: [--no-progress, --fix]
101+
102+
- repo: https://github.com/shellcheck-py/shellcheck-py
103+
rev: v0.11.0.1
104+
hooks:
105+
- id: shellcheck
106+
files: \.sh$

custom_components/powercalc/config_flow.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ async def _validate_form_step_input(
273273
return user_input
274274

275275
validated_input = form_step.validate_user_input(user_input)
276-
return await validated_input if isawaitable(validated_input) else validated_input
276+
return await validated_input if isawaitable(validated_input) else validated_input # ty: ignore[invalid-return-type]
277277

278278
def _store_form_step_input(
279279
self,

profile_library/bosch/Smart Home Controller 1 Gen/model.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
],
66
"author": "Justin Hahn <justin.hahn@live.com>",
77
"calculation_strategy": "fixed",
8-
"created_at": "2025-04-10T00:41:25+01:00",
8+
"created_at": "2025-04-09T23:41:25Z",
99
"description": "The measured Bosch Smart Home Controller had the following devices connected: four Bosch Smart Home Radiator Thermostat II (TRV_GEN2), two Bosch Smart Home Radiator Thermostat I (TRV), and two Bosch Smart Home Door/Window Contact II (SWD2).During the 120-second measurement period, the temperature was adjusted both directly on the device itself and via the Smart Home Controller on one TRV thermostat and on one TRV_GEN2 thermostat. In addition, both window sensors were triggered twice each by opening and closing the windows.",
1010
"device_type": "generic_iot",
1111
"discovery_by": "device",

profile_library/dreo/DR-HAF001S/model.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"author": "miggi92 <miggi92@users.noreply.github.com>",
33
"calculation_strategy": "linear",
4-
"created_at": "2025-07-14T09:52:08+02:00",
4+
"created_at": "2025-07-14T07:52:08Z",
55
"device_type": "fan",
66
"linear_config": {
77
"attribute": "percentage",

profile_library/dreo/DR-HTF001S/model.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"author": "miggi92 <miggi92@users.noreply.github.com>",
33
"calculation_strategy": "linear",
4-
"created_at": "2025-07-14T10:15:08+02:00",
4+
"created_at": "2025-07-14T08:15:08Z",
55
"device_type": "fan",
66
"linear_config": {
77
"attribute": "percentage",

profile_library/dreo/DR-HTF002S/model.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"author": "miggi92 <miggi92@users.noreply.github.com>",
33
"calculation_strategy": "linear",
4-
"created_at": "2025-07-14T10:10:08+02:00",
4+
"created_at": "2025-07-14T08:10:08Z",
55
"device_type": "fan",
66
"linear_config": {
77
"attribute": "percentage",

profile_library/shelly/Shelly 1 Gen3/model.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"calculation_strategy": "fixed",
1717
"only_self_usage": false,
1818
"config_flow_sub_profile_remarks": "Select a profile depending on your Shelly device configuration.",
19-
"created_at": "2026-01-15T11:15:00+01:00",
19+
"created_at": "2026-01-15T10:15:00Z",
2020
"author": "Michal Bartak <maxym.srpl@gmail.com>",
2121
"author_info": {
2222
"name": "Michal Bartak",

profile_library/shelly/Shelly 1/model.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
],
55
"author": "Michal Bartak <maxym.srpl@gmail.com>",
66
"calculation_strategy": "fixed",
7-
"created_at": "2024-01-05T13:55:00+01:00",
7+
"created_at": "2024-01-05T12:55:00Z",
88
"device_type": "smart_switch",
99
"discovery_by": "entity",
1010
"measure_description": "The measured device fw: 1.14.1-rc1, Eco Mode enabled, Wifi Client enabled. The result represents the average value of measurements collected from the measurement device API for the following scenarios: dumb device/baseline consumption (~4.9W), the the relay turned off, and the relay turned on.",

profile_library/shelly/Shelly 1L Gen3/model.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"author": "Victor Burlacu-Zane",
66
"calculation_strategy": "fixed",
77
"config_flow_sub_profile_remarks": "You need to select a profile depending on your settings.\nThe ECO setting only changes the power consumption in the listed configurations. Activating any other settings not listed in the profile name will change the power draw.\n\"WLAN + BT + ECO\": All three turned on, repeater turned off.\n\"WLAN + ECO\": Both turned on, repeater turned off.\n\"WLAN + BT\": Both turned on, repeater turned on, ECO turned off.\n\"WLAN\": Only WLAN turned on, all others off.\n\"Other combinations\": For all other combinations. Maximum device power draw.",
8-
"created_at": "2026-01-05T20:06:00+01:00",
8+
"created_at": "2026-01-05T19:06:00Z",
99
"device_type": "smart_switch",
1010
"discovery_by": "entity",
1111
"measure_description": "Measured with disconnected load, for about 90 minutes and calculated average from values stored by Home Assistant. Multiple combinations of settings were tested. Firmware version 1.7.1 for the tested Shelly 1L Gen3 device. The power values are long-term averages measured while the device periodically wakes to maintain connectivity. Instantaneous power is higher during wakeups when the relay is off, but the average energy consumption is accurately reflected.",

0 commit comments

Comments
 (0)