Skip to content

Commit

Permalink
Introduce yaml linting (#144)
Browse files Browse the repository at this point in the history
  • Loading branch information
jesserockz authored Feb 22, 2024
1 parent 996dd20 commit 93ffdcc
Show file tree
Hide file tree
Showing 18 changed files with 101 additions and 56 deletions.
1 change: 1 addition & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
name: Build

# yamllint disable-line rule:truthy
on:
push:
branches:
Expand Down
25 changes: 25 additions & 0 deletions .github/workflows/yaml-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: YAML lint

# yamllint disable-line rule:truthy
on:
push:
branches: [main]
paths:
- "**.yaml"
- "**.yml"
pull_request:
paths:
- "**.yaml"
- "**.yml"

jobs:
yamllint:
name: yamllint
runs-on: ubuntu-latest
steps:
- name: Check out code from GitHub
uses: actions/[email protected]
- name: Run yamllint
uses: frenck/[email protected]
with:
strict: true
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
secrets.yaml
*/.gitignore
!/.gitignore
venv/
19 changes: 19 additions & 0 deletions .yamllint
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---

extends: default

ignore-from-file: .gitignore

rules:
document-start: disable
empty-lines:
level: error
max: 1
max-start: 0
max-end: 1
indentation:
level: error
spaces: 2
indent-sequences: true
check-multi-line-strings: false
line-length: disable
6 changes: 3 additions & 3 deletions bluetooth-proxy/m5stack-atom-lite.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,6 @@ bluetooth_proxy:
active: true

button:
- platform: safe_mode
name: Safe Mode Boot
entity_category: diagnostic
- platform: safe_mode
name: Safe Mode Boot
entity_category: diagnostic
6 changes: 3 additions & 3 deletions bluetooth-proxy/wt32-eth01.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,6 @@ bluetooth_proxy:
active: true

button:
- platform: safe_mode
name: Safe Mode Boot
entity_category: diagnostic
- platform: safe_mode
name: Safe Mode Boot
entity_category: diagnostic
35 changes: 17 additions & 18 deletions media-player/onju-voice.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ media_player:
mode: mono
mute_pin:
number: GPIO21
inverted: True
inverted: true

microphone:
- platform: i2s_audio
Expand Down Expand Up @@ -164,11 +164,11 @@ voice_assistant:

esp32_touch:
setup_mode: false
sleep_duration: 2ms
sleep_duration: 2ms
measurement_duration: 800us
low_voltage_reference: 0.8V
high_voltage_reference: 2.4V

filter_mode: IIR_16
debounce_count: 2
noise_threshold: 0
Expand All @@ -182,8 +182,8 @@ binary_sensor:
- platform: esp32_touch
id: volume_down
pin: GPIO4
threshold: 539000 # will automatically be tuned at runtime
on_press:
threshold: 539000 # will automatically be tuned at runtime
on_press:
then:
- light.turn_on: left_led
- script.execute:
Expand All @@ -198,15 +198,15 @@ binary_sensor:
id: set_volume
volume: -0.05
- delay: 150ms
on_release:
on_release:
then:
- light.turn_off: left_led

- platform: esp32_touch
id: volume_up
pin: GPIO2
threshold: 580000 # will automatically be tuned at runtime
on_press:
threshold: 580000 # will automatically be tuned at runtime
on_press:
then:
- light.turn_on: right_led
- script.execute:
Expand All @@ -221,14 +221,14 @@ binary_sensor:
id: set_volume
volume: 0.05
- delay: 150ms
on_release:
on_release:
then:
- light.turn_off: right_led

- platform: esp32_touch
id: action
pin: GPIO3
threshold: 751000 # will automatically be tuned at runtime
threshold: 751000 # will automatically be tuned at runtime
on_click:
- if:
condition:
Expand All @@ -249,7 +249,7 @@ binary_sensor:
- script.execute: reset_led
- script.wait: reset_led
- voice_assistant.start_continuous:

- platform: gpio
id: mute_switch
pin:
Expand Down Expand Up @@ -294,7 +294,7 @@ light:
name: slow_pulse
transition_length: 1s
update_interval: 2s
- addressable_lambda:
- addressable_lambda:
name: show_volume
update_interval: 50ms
lambda: |-
Expand Down Expand Up @@ -422,21 +422,20 @@ script:
//ESP_LOGD("touch_calibration", "[%d] qsize %d, sum %d, thresh_index %d, consecutive_anomalies %d", button, qsizes[button], sums[button], thresh_indices[button], consecutive_anomalies_per_button[button]);
//ESP_LOGD("touch_calibration", "[%d] New value is %d", button, newval);
if(qsizes[button] == 5) {
float avg = float(sums[button])/float(qsizes[button]);
if((fabs(float(newval)-avg)/avg) > id(thresh_percent)) {
consecutive_anomalies_per_button[button]++;
//ESP_LOGD("touch_calibration", "[%d] %d anomalies detected.", button, consecutive_anomalies_per_button[button]);
if(consecutive_anomalies_per_button[button] < 10)
return;
}
}
}
//ESP_LOGD("touch_calibration", "[%d] Resetting consecutive anomalies counter.", button);
consecutive_anomalies_per_button[button] = 0;
if(qsizes[button] == 5) {
//ESP_LOGD("touch_calibration", "[%d] Queue full, removing %d.", button, id(touch_calibration_values)[thresh_indices[button]]);
sums[button] -= (uint32_t) *(calibration_values+thresh_indices[button]);// id(touch_calibration_values)[thresh_indices[button]];
Expand All @@ -450,7 +449,7 @@ script:
//ESP_LOGD("touch_calibration", "[%d] Average value is %d", button, sums[button]/qsizes[button]);
uint32_t newthresh = uint32_t((sums[button]/qsizes[button]) * (1.0 + id(thresh_percent)));
//ESP_LOGD("touch_calibration", "[%d] Setting threshold %d", button, newthresh);
switch(button) {
case 0:
id(volume_down).set_threshold(newthresh);
Expand Down
4 changes: 2 additions & 2 deletions media-player/raspiaudio-muse-luxe.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ captive_portal:
improv_serial:

external_components:
- source: github://pr#3552 # DAC support https://github.com/esphome/esphome/pull/3552
- source: github://pr#3552 # DAC support https://github.com/esphome/esphome/pull/3552
components: [es8388]
refresh: 0s

Expand Down Expand Up @@ -113,7 +113,7 @@ sensor:
attenuation: 11db
raw: true
filters:
- multiply: 0.00173913 # 2300 -> 4, for attenuation 11db, based on Olivier's code
- multiply: 0.00173913 # 2300 -> 4, for attenuation 11db, based on Olivier's code
- exponential_moving_average:
alpha: 0.2
send_every: 2
Expand Down
6 changes: 3 additions & 3 deletions voice-assistant/esp32-s3-box-3.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ wifi:
ap:
on_connect:
- script.execute: draw_display
- delay: 5s # Gives time for improv results to be transmitted
- delay: 5s # Gives time for improv results to be transmitted
- ble.disable:
on_disconnect:
- script.execute: draw_display
Expand Down Expand Up @@ -295,11 +295,11 @@ switch:
globals:
- id: init_in_progress
type: bool
restore_value: no
restore_value: false
initial_value: "true"
- id: voice_assistant_phase
type: int
restore_value: no
restore_value: false
initial_value: ${voice_assist_not_ready_phase_id}

image:
Expand Down
6 changes: 3 additions & 3 deletions voice-assistant/esp32-s3-box-lite.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ wifi:
ap:
on_connect:
- script.execute: draw_display
- delay: 5s # Gives time for improv results to be transmitted
- delay: 5s # Gives time for improv results to be transmitted
- ble.disable:
on_disconnect:
- script.execute: draw_display
Expand Down Expand Up @@ -342,11 +342,11 @@ switch:
globals:
- id: init_in_progress
type: bool
restore_value: no
restore_value: false
initial_value: "true"
- id: voice_assistant_phase
type: int
restore_value: no
restore_value: false
initial_value: ${voice_assist_not_ready_phase_id}

image:
Expand Down
6 changes: 3 additions & 3 deletions voice-assistant/esp32-s3-box.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ wifi:
ap:
on_connect:
- script.execute: draw_display
- delay: 5s # Gives time for improv results to be transmitted
- delay: 5s # Gives time for improv results to be transmitted
- ble.disable:
on_disconnect:
- script.execute: draw_display
Expand Down Expand Up @@ -288,11 +288,11 @@ switch:
globals:
- id: init_in_progress
type: bool
restore_value: no
restore_value: false
initial_value: "true"
- id: voice_assistant_phase
type: int
restore_value: no
restore_value: false
initial_value: ${voice_assist_not_ready_phase_id}

image:
Expand Down
2 changes: 1 addition & 1 deletion voice-assistant/m5stack-atom-echo.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ dashboard_import:

wifi:
on_connect:
- delay: 5s # Gives time for improv results to be transmitted
- delay: 5s # Gives time for improv results to be transmitted
- ble.disable:
on_disconnect:
- ble.enable:
Expand Down
2 changes: 1 addition & 1 deletion voice-assistant/quinled-dig2go.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ binary_sensor:
pin:
number: GPIO0
mode: INPUT_PULLUP
inverted: True
inverted: true
on_click:
- if:
condition:
Expand Down
6 changes: 3 additions & 3 deletions voice-assistant/raspiaudio-muse-luxe.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ dashboard_import:

wifi:
on_connect:
- delay: 5s # Gives time for improv results to be transmitted
- delay: 5s # Gives time for improv results to be transmitted
- ble.disable:
on_disconnect:
- ble.enable:
Expand All @@ -43,7 +43,7 @@ button:
name: Factory reset

external_components:
- source: github://pr#3552 # DAC support https://github.com/esphome/esphome/pull/3552
- source: github://pr#3552 # DAC support https://github.com/esphome/esphome/pull/3552
components: [es8388]
refresh: 0s
- source: github://pr#5230
Expand Down Expand Up @@ -149,7 +149,7 @@ sensor:
attenuation: 11db
raw: true
filters:
- multiply: 0.00173913 # 2300 -> 4, for attenuation 11db, based on Olivier's code
- multiply: 0.00173913 # 2300 -> 4, for attenuation 11db, based on Olivier's code
- exponential_moving_average:
alpha: 0.2
send_every: 2
Expand Down
2 changes: 1 addition & 1 deletion voice-assistant/raspiaudio-muse-proto.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ dashboard_import:

wifi:
on_connect:
- delay: 5s # Gives time for improv results to be transmitted
- delay: 5s # Gives time for improv results to be transmitted
- ble.disable:
on_disconnect:
- ble.enable:
Expand Down
10 changes: 5 additions & 5 deletions wake-word-voice-assistant/esp32-s3-box-3.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ wifi:
ap:
on_connect:
- script.execute: draw_display
- delay: 5s # Gives time for improv results to be transmitted
- delay: 5s # Gives time for improv results to be transmitted
- ble.disable:
on_disconnect:
- script.execute: draw_display
Expand Down Expand Up @@ -346,8 +346,8 @@ select:
entity_category: config
name: Wake word engine location
id: wake_word_engine_location
optimistic: True
restore_value: True
optimistic: true
restore_value: true
options:
- In Home Assistant
- On device
Expand Down Expand Up @@ -379,11 +379,11 @@ select:
globals:
- id: init_in_progress
type: bool
restore_value: no
restore_value: false
initial_value: "true"
- id: voice_assistant_phase
type: int
restore_value: no
restore_value: false
initial_value: ${voice_assist_not_ready_phase_id}

image:
Expand Down
Loading

0 comments on commit 93ffdcc

Please sign in to comment.