Skip to content

Commit

Permalink
Yaml lint
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewjswan committed Aug 24, 2024
1 parent 166af1b commit 27c6893
Show file tree
Hide file tree
Showing 119 changed files with 833 additions and 460 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
with:
yaml-file: ${{ matrix.config-file }}
version: latest

ci-status:
name: Status
runs-on: ubuntu-latest
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/workflow_size_labels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ on:
jobs:
add-labels:
name: Add labels

runs-on: ubuntu-latest

permissions:
contents: read
pull-requests: write
Expand Down
23 changes: 23 additions & 0 deletions .github/workflows/workflow_yaml_lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Workflow / YAML lint

on:
push:
branches: [main]
paths:
- "**.yaml"
- "**.yml"
pull_request:
paths:
- "**.yaml"
- "**.yml"
workflow_dispatch:

jobs:
yamllint:
name: 🧹 Yaml lint
runs-on: ubuntu-latest
steps:
- name: ⤵️ Check out configuration from GitHub
uses: actions/checkout@v4
- name: 🚀 Run yamllint
run: yamllint --strict .
21 changes: 21 additions & 0 deletions .yamllint
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
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
truthy: disable
new-lines: disable
comments-indentation: disable
2 changes: 1 addition & 1 deletion common/binary_sensor/air_fresh_awakened.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ lambda: |-
// ESP_LOGD("time", "Did not get the current time, skip it...");
return false;
}
if (std::string(id(sleep_heartbeat)) == "")
{
// ESP_LOGD("heartbeat", "Did not get the heartbeat time, skip it...");
Expand Down
10 changes: 5 additions & 5 deletions common/binary_sensor/air_fresh_need_spray.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ name: ${name} Air Fresh Action
id: need_spray
lambda: |-
#define NIGHT_SILENT
if (id(someone_home).state != "ON")
{
// ESP_LOGD("home", "There's no one at home, we're sleeping...");
Expand All @@ -29,10 +29,10 @@ lambda: |-
return false;
}
if ((id(on_flag).state) == 1)
if ((id(on_flag).state) == 1)
{
return true;
}
}
auto time = id(esp_time).now();
if (!time.is_valid())
Expand All @@ -42,7 +42,7 @@ lambda: |-
}
#ifdef NIGHT_SILENT
if (time.hour >= id(night_start) && time.hour < id(night_end))
{
// ESP_LOGD("time", "Night, skip it...");
Expand Down Expand Up @@ -70,7 +70,7 @@ lambda: |-
time_t startTime = mktime(&stime);
time_t currTime = mktime(&ctime);
time_t uptime = difftime(currTime, startTime);
int minutes = uptime / 60;
int step = (int)(id(air_fresh_interval).state);
Expand Down
10 changes: 5 additions & 5 deletions common/binary_sensor/night.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ entity_id: binary_sensor.night_mode
internal: true
filters:
- lambda: |-
if (!id(night).has_state())
if (!id(night).has_state())
{
auto time = id(esp_time).now();
if (!time.is_valid())
if (!time.is_valid())
{
return false;
}
return (time.hour <= 7 or time.hour == 23);
}
else
}
else
{
return x;
}
}
2 changes: 1 addition & 1 deletion common/binary_sensor/sonoff_mini_button.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ filters:
- delayed_off: 10ms
on_press:
- light.toggle:
id: light_id # toggle the main relay
id: light_id
internal: true
6 changes: 3 additions & 3 deletions common/binary_sensor/sonoff_mini_switch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ pin: GPIO04
id: gpio_light_id
on_press:
then:
- logger.log:
- logger.log:
format: "External switch On press..."
level: "DEBUG"
tag: "sonoff"
Expand All @@ -28,7 +28,7 @@ on_press:

on_release:
then:
- logger.log:
- logger.log:
format: "External switch On release..."
level: "DEBUG"
tag: "sonoff"
Expand All @@ -45,7 +45,7 @@ on_release:
- switch.is_on: turn_off_delay
then:
- script.execute: turn_off_with_delay
else:
else:
- light.turn_off:
id: light_id # turn off the main relay

Expand Down
12 changes: 6 additions & 6 deletions common/boot/air_fresh.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ on_boot:
lambda: 'return id(charge_time).state == "";'
then:
- script.execute: publish_charge_time
# - script.execute: air_fresh_awakened
# - script.execute: air_fresh_awakened
- if:
condition:
binary_sensor.is_on: need_spray
Expand All @@ -67,7 +67,7 @@ on_boot:
not:
time.has_time:
then:
- logger.log:
- logger.log:
format: "Time is not synchronized..."
level: "WARN"
tag: "time"
Expand All @@ -76,7 +76,7 @@ on_boot:
not:
mqtt.connected:
then:
- logger.log:
- logger.log:
format: "No connection to the MQTT broker..."
level: "WARN"
tag: "mqtt"
Expand All @@ -87,11 +87,11 @@ on_boot:
condition:
lambda: 'return id(vcc).state < ${vcc_critical};'
then:
- logger.log:
- logger.log:
format: "Low power (%.1f), shutdown..."
level: "WARN"
tag: "power"
args: [ 'id(vcc).state' ]
args: ['id(vcc).state']
- switch.turn_on: esp_shutdown

- if:
Expand All @@ -101,7 +101,7 @@ on_boot:
- script.execute: sleep_time
else:
- deep_sleep.prevent: deep_sleep_mode
- logger.log:
- logger.log:
format: "OTA Mode Enabled..."
level: "WARN"
tag: "ota"
Expand Down
1 change: 0 additions & 1 deletion common/boot/nous_a1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,3 @@ on_boot:
- switch.turn_off: button_switch
- switch.turn_off: relay
- output.turn_off: led_blue

1 change: 0 additions & 1 deletion common/boot/sonoff_mini.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,3 @@ on_boot:
else:
- light.turn_off:
id: light_id

2 changes: 1 addition & 1 deletion common/boot/window_illumination.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on_boot:
- light.turn_off:
id: neopixel_led
- delay: 5s
- logger.log:
- logger.log:
format: "${name} started, LED: ${type_leds}:${num_leds}:${pin_leds}, Reboot: ${reboot_timeout}"
level: INFO
tag: start
2 changes: 1 addition & 1 deletion common/button/senseair_s8_calibration.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
platform: template
name: ${name} Sensair S8 Calibrate
id : calibrate_s8
id: calibrate_s8
entity_category: diagnostic
on_press:
- logger.log:
Expand Down
2 changes: 1 addition & 1 deletion common/button/senseair_s8_calibration_result.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
platform: template
name: ${name} Sensair S8 Calibrate Result
id : calibrate_s8_result
id: calibrate_s8_result
entity_category: diagnostic
on_press:
- logger.log:
Expand Down
4 changes: 2 additions & 2 deletions common/common-deep-sleep.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<<: !include ota/deep-sleep.yaml
<<: !include mqtt.yaml
<<: !include time/sntp.yaml
#<<: !include logger/verbose.yaml
#<<: !include logger/debug.yaml
# <<: !include logger/verbose.yaml
# <<: !include logger/debug.yaml
<<: !include logger/info.yaml
<<: !include web/web_server.yaml
<<: !include deep-sleep.yaml
4 changes: 2 additions & 2 deletions common/common.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
<<: !include mdns.yaml
<<: !include api.yaml
<<: !include ota/online.yaml
#<<: !include web/web_server_debug.yaml
# <<: !include web/web_server_debug.yaml
<<: !include web/web_server.yaml
<<: !include time/home-assisatnt.yaml
#<<: !include logger/debug.yaml
# <<: !include logger/debug.yaml
<<: !include logger/info.yaml
2 changes: 1 addition & 1 deletion common/deep-sleep.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
run_duration: 30s
sleep_duration: ${sleep_interval}
id: deep_sleep_mode
# note that on the ESP8266 GPIO16 (D0) must be connected to the RST pin so that it will wake up again
# Note that on the ESP8266 GPIO16 (D0) must be connected to the RST pin so that it will wake up again
2 changes: 1 addition & 1 deletion common/esp/esp32_wrover.yaml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
esp32:
board: esp-wrover-kit
board: esp-wrover-kit
10 changes: 5 additions & 5 deletions common/interval/senseair-s8-neopixel.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ then:
static float coef_min = (0.5 - 0.0) / (${min_co2} - 0);
static float coef_med = (1.0 - 0.5) / (${med_co2} - ${min_co2});
bool alert_mode = ((strcasecmp(id(neopixel_led).get_effect_name().c_str(), "Strobe Blue") == 0) or
(strcasecmp(id(neopixel_led).get_effect_name().c_str(), "Strobe Purple") == 0) or
(strcasecmp(id(neopixel_led).get_effect_name().c_str(), "Strobe Green") == 0) or
(strcasecmp(id(neopixel_led).get_effect_name().c_str(), "Strobe Alarm") == 0) or
bool alert_mode = ((strcasecmp(id(neopixel_led).get_effect_name().c_str(), "Strobe Blue") == 0) or
(strcasecmp(id(neopixel_led).get_effect_name().c_str(), "Strobe Purple") == 0) or
(strcasecmp(id(neopixel_led).get_effect_name().c_str(), "Strobe Green") == 0) or
(strcasecmp(id(neopixel_led).get_effect_name().c_str(), "Strobe Alarm") == 0) or
(strcasecmp(id(neopixel_led).get_effect_name().c_str(), "Strobe Police") == 0));
if (id(automatic).state and !alert_mode)
Expand All @@ -39,7 +39,7 @@ then:
action = true;
first_run = false;
}
if (!id(neopixel_led).remote_values.is_on())
{
action = true;
Expand Down
20 changes: 10 additions & 10 deletions common/light/effects/ambilight.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ addressable_lambda:
const int line_width = 8;
const int led_width = it.size();
static bool run = false;
static Color line_colors[line_width];
static Color old_led_colors[${num_leds}];
static Color new_led_colors[${num_leds}];
Expand All @@ -17,13 +17,13 @@ addressable_lambda:
run = false;
it.all() = Color::BLACK;
}
if (run)
if (run)
{
return;
}
run = true;
HTTPClient http;
if (http.begin("http://${philips_tv}:1925/1/ambilight/processed"))
{
Expand All @@ -34,9 +34,9 @@ addressable_lambda:
{
DynamicJsonDocument root(1536);
DeserializationError error = deserializeJson(root, http.getStream());
if (!error)
if (!error)
{
if (root.containsKey("layer1"))
if (root.containsKey("layer1"))
{
for(int i = 0; i < 9; i++)
{
Expand All @@ -45,16 +45,16 @@ addressable_lambda:
int b = root["layer1"]["top"][String(i)]["b"];
line_colors[i] = Color(r, g, b).lighten(${ambilight_color_correct});
}
// Fill Led
for (int i = 0; i < led_width; i++)
{
int j = (i * (line_width - 1) + led_width / 2) / led_width;
new_led_colors[i] = line_colors[j];
old_led_colors[i] = it[i].get();
}
// Smooth fill
// Smooth fill
int step = 10;
for (int i = 1; i <= step; i++)
{
Expand All @@ -69,7 +69,7 @@ addressable_lambda:
}
delay(90 / step);
}
// Final fill
for (int i = 0; i < led_width; i++)
{
Expand Down
Loading

0 comments on commit 27c6893

Please sign in to comment.