Skip to content

Commit

Permalink
WIP for gitlab workflows + linting
Browse files Browse the repository at this point in the history
  • Loading branch information
stefancrain committed Jul 26, 2022
1 parent 0c7d324 commit ccf0efb
Show file tree
Hide file tree
Showing 34 changed files with 235 additions and 233 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ jobs:
- name: yaml-lint
uses: karancode/yamllint-github-action@master
with:
yamllint_config_filepath: .github/lint/.yamllint.yml
yamllint_config_filepath: .github/lint/.yamllint.yaml
env:
GITHUB_ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2 changes: 1 addition & 1 deletion .github/workflows/release-drafter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ jobs:
steps:
- uses: release-drafter/release-drafter@v5
with:
config-name: release-drafter.yml
config-name: release-drafter.yaml
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
7 changes: 3 additions & 4 deletions climate-indoor/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ substitutions:
pin_i2c: GPIO18
pin_uart_rx: GPIO17
pin_uart_tx: GPIO16
board: "nodemcu-32s"
platform: "ESP32"
board: 'nodemcu-32s'
platform: 'ESP32'
log_level: VERY_VERBOSE

packages:
Expand Down Expand Up @@ -45,6 +45,5 @@ sensor:
- <<: !include ../common/sensor/PMS5003.yaml
# - <<: !include ../common/sensor/as3935.yaml
# - <<: !include ../common/sensor/aqi.yaml

# script:
# - <<: !include ../common/script/aqi.yml
# - <<: !include ../common/script/aqi.yaml
7 changes: 3 additions & 4 deletions climate-outdoor/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ substitutions:
pin_i2c: GPIO18
pin_uart_rx: GPIO17
pin_uart_tx: GPIO16
board: "nodemcu-32s"
platform: "ESP32"
board: 'nodemcu-32s'
platform: 'ESP32'

packages:
device_base: !include ../common/device_base.yaml
Expand Down Expand Up @@ -44,6 +44,5 @@ sensor:
- <<: !include ../common/sensor/PMS5003.yaml
- <<: !include ../common/sensor/as3935.yaml
# - <<: !include ../common/sensor/aqi.yaml

# script:
# - <<: !include ../common/script/aqi.yml
# - <<: !include ../common/script/aqi.yaml
2 changes: 1 addition & 1 deletion common/binary_sensor/as3935.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
---
- platform: as3935
name: "${mac} Storm Alert"
name: '${mac} Storm Alert'
2 changes: 1 addition & 1 deletion common/binary_sensor/connectivity.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
---
- platform: status
name: "${mac} Connectivity"
name: '${mac} Connectivity'
entity_category: diagnostic
5 changes: 5 additions & 0 deletions common/binary_sensor/deep_sleep.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
- platform: homeassistant
id: prevent_deep_sleep
name: $friendly_name Prevent Deep Sleep
entity_id: input_boolean.prevent_deep_sleep
29 changes: 14 additions & 15 deletions common/device_base.yaml
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
---
substitutions:
node_name: base
mac: "C0FFEE"
mac: 'C0FFEE'
release_id: 99999999

pin_led_status: GPIO25
pin_i2c: GPIO18
pin_uart_rx: GPIO17
pin_uart_tx: GPIO16
board: "esp32dev"
platform: "ESP32"
board: 'esp32dev'
platform: 'ESP32'
flash_write_interval: 5min
log_level: INFO

# BMXX80
bosch_sample_rate: lp # ulp
bme680_temperature_offset: "0"
bme680_temperature_offset: '0'

# deep sleep
run_duration: 60s
Expand All @@ -25,24 +25,23 @@ esphome:
name: ${node_name}
name_add_mac_suffix: true
project:
name: "stefancrain.${node_name}"
name: 'stefancrain.${node_name}'
version: ${release_id}
board: ${board}
platform: ${platform}
on_boot:
then:
- deep_sleep.prevent: deep_sleep_control
# on_shutdown:
# then:
# - lambda: |-
# id(ts_saved) = id(homeassistant_time).now().timestamp;

on_shutdown:
then:
- lambda: |-
id(ts_saved) = id(homeassistant_time).now().timestamp;
preferences:
flash_write_interval: "${flash_write_interval}"
flash_write_interval: '${flash_write_interval}'

logger:
level: "${log_level}"
level: '${log_level}'
logs:
switch: INFO
light: WARN
Expand All @@ -55,8 +54,8 @@ api:

light:
- platform: status_led
name: "${mac} Status LED"
pin: "${pin_led_status}"
name: '${mac} Status LED'
pin: '${pin_led_status}'
restore_mode: ALWAYS_OFF

web_server:
Expand Down
6 changes: 3 additions & 3 deletions common/font/google-roboto-mono.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
---
- file: "gfonts://Roboto+Mono"
- file: 'gfonts://Roboto+Mono'
id: roboto_mono_regular_20
size: 20
- file: "gfonts://Roboto+Mono"
- file: 'gfonts://Roboto+Mono'
id: roboto_mono_regular_16
size: 16
- file: "gfonts://Roboto+Mono"
- file: 'gfonts://Roboto+Mono'
id: roboto_mono_regular_12
size: 12
6 changes: 3 additions & 3 deletions common/font/google-roboto.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
---
- file: "gfonts://Roboto"
- file: 'gfonts://Roboto'
id: roboto_regular_20
size: 20
- file: "gfonts://Roboto"
- file: 'gfonts://Roboto'
id: roboto_regular_16
size: 16
- file: "gfonts://Roboto"
- file: 'gfonts://Roboto'
id: roboto_regular_12
size: 12
1 change: 1 addition & 0 deletions common/packages/deep_sleep.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
deep_sleep:
run_duration: ${run_duration}
sleep_duration: ${sleep_duration}
Expand Down
13 changes: 7 additions & 6 deletions common/packages/globals.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
---
globals:
- id: first_time_boot
type: bool
initial_value: "true"
restore_value: yes
initial_value: true
restore_value: true
- id: wifi_signal_sent
type: bool
initial_value: "false"
restore_value: no
initial_value: false
restore_value: false
- id: uptime_sent
type: bool
initial_value: "false"
restore_value: no
initial_value: false
restore_value: false
2 changes: 1 addition & 1 deletion common/packages/network.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ wifi:

# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "${node_name} - ${mac} AP"
ssid: '${node_name} - ${mac} AP'
password: !secret fallback_hotspot_password

captive_portal:
3 changes: 3 additions & 0 deletions common/packages/secrets.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
# Trick to include secrets in imports
<<: !include ../../secrets.yaml
38 changes: 38 additions & 0 deletions common/script/aqi.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
- id: aqi
mode: restart
then:
# Bad if at least one of the sensor values is bad
- if:
condition:
or:
- sensor.in_range:
id: pm2_5_avg_24h
above: 25
- sensor.in_range:
id: pm10_avg_24h
above: 50
then:
- text_sensor.template.publish:
id: aqi
state: Bad
else:
# Acceptable if at least one of the sensor values is acceptable
- if:
condition:
or:
- sensor.in_range:
id: pm2_5_avg_24h
above: 12
- sensor.in_range:
id: pm10_avg_24h
above: 25
then:
- text_sensor.template.publish:
id: aqi
state: Acceptable
else:
# Otherwise good (all of the sensor values are good)
- text_sensor.template.publish:
id: aqi
state: Good
41 changes: 0 additions & 41 deletions common/script/aqi.yml

This file was deleted.

6 changes: 3 additions & 3 deletions common/script/deep_sleep.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
- id: consider_deep_sleep
mode: queued
then:
- logger.log: "Considering Deep Sleep"
- logger.log: 'Considering Deep Sleep'
- delay: 5s
- if:
condition:
Expand All @@ -20,8 +20,8 @@
}
return false;
then:
- logger.log: "Entering in Deep Sleep"
- logger.log: 'Entering in Deep Sleep'
- deep_sleep.enter: deep_sleep_control
else:
- logger.log: "Skipping Deep Sleep"
- logger.log: 'Skipping Deep Sleep'
- delay: 1s
3 changes: 3 additions & 0 deletions common/script/secrets.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
# Trick to include secrets in imports
<<: !include ../../secrets.yaml
12 changes: 6 additions & 6 deletions common/sensor/PMS5003.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,32 @@
type: PMSX003

pm_1_0:
name: "${mac} PM1"
name: '${mac} PM1'
id: pm1
icon: mdi:circle-small
device_class: "pm1"
device_class: 'pm1'
filters:
- sliding_window_moving_average:
window_size: 30
send_every: 30
accuracy_decimals: 5

pm_2_5:
name: "${mac} PM2.5"
name: '${mac} PM2.5'
id: pm2_5
icon: mdi:circle-medium
device_class: "pm25"
device_class: 'pm25'
filters:
- sliding_window_moving_average:
window_size: 30
send_every: 30
accuracy_decimals: 5

pm_10_0:
name: "${mac} PM10"
name: '${mac} PM10'
id: pm10
icon: mdi:circle
device_class: "pm10"
device_class: 'pm10'
filters:
- sliding_window_moving_average:
window_size: 30
Expand Down
10 changes: 4 additions & 6 deletions common/sensor/aqi.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
---

# https://aqs.epa.gov/aqsweb/documents/codetables/aqi_breakpoints.html
- platform: template
name: "${mac} US Air Quality Index"
name: '${mac} US Air Quality Index'
id: us_aqi
value_template: >
{% set vv = states('sensor.pm2_5_avg_24h')|float %}
Expand All @@ -23,7 +22,7 @@
{% endif %}
- platform: template
name: "${mac} CN Air Quality Index"
name: '${mac} CN Air Quality Index'
id: cn_aqi
value_template: >
{% set vv = states('sensor.pm2_5_avg_24h')|float %}
Expand All @@ -45,7 +44,7 @@
# # The WHO guidelines work with 24-hour averages of the PM2.5 and PM10 sensors
- platform: template
name: "${mac} Particulate Matter <1µm 24h average"
name: '${mac} Particulate Matter <1µm 24h average'
id: pm1_avg_24h
icon: mdi:air-purifier
unit_of_measurement: µg/m³
Expand All @@ -54,12 +53,11 @@
update_interval: 60s
filters:
- sliding_window_moving_average:
window_size: 1440 # = 24 hours x 60 minutes
window_size: 1440 # = 24 hours x 60 minutes
send_every: 1
on_value:
then:
- script.execute: aqi

# - platform: template
# name: "${mac} Particulate Matter <2.5µm 24h average"
# id: pm2_5_avg_24h
Expand Down
Loading

0 comments on commit ccf0efb

Please sign in to comment.