From b38edd245eb0ce9bc92bc989237ed9138e76488e Mon Sep 17 00:00:00 2001 From: Jan Grewe <jan@faked.org> Date: Wed, 30 Nov 2022 08:35:05 +0100 Subject: [PATCH] tweak & CI jobs --- .gitlab-ci.yml | 25 +++++++++++++++++++++++++ growbox.yaml | 6 +++--- packages/base.yaml | 6 ++---- packages/bme280.yaml | 4 ++-- packages/fan_power.yaml | 7 +++++++ packages/fan_settings.yaml | 27 +++++++++++++++++++++++++++ packages/gp8403.yaml | 10 ++++++++++ packages/light_power.yaml | 7 +++++++ packages/light_settings.yaml | 3 ++- packages/time.yaml | 26 -------------------------- packages/time_schedule.yaml | 31 +++++++++++++++++++++++++++++++ packages/yyac3s.yaml | 4 ++-- propbox.yaml | 4 ++-- 13 files changed, 120 insertions(+), 40 deletions(-) create mode 100644 .gitlab-ci.yml create mode 100644 packages/time_schedule.yaml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..e789f23 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,25 @@ +stages: + - validate + - deploy + +image: + name: esphome/esphome:2022.11.3 + entrypoint: [""] + +validate_configs: + stage: validate + before_script: + - cat "${SECRETS_YAML}" > "packages/secrets.yaml" + script: + - for yml in *.yaml; do esphome config ${yml}; done + tags: + - docker + +deploy_configs: + stage: deploy + before_script: + - cat "${SECRETS_YAML}" > "packages/secrets.yaml" + script: + - cp -r *.yaml packages include /srv/esphome/groovy-industries + tags: + - shell diff --git a/growbox.yaml b/growbox.yaml index e490a5d..6748c88 100644 --- a/growbox.yaml +++ b/growbox.yaml @@ -1,18 +1,18 @@ substitutions: devicename: "growbox" - comment: "Grow Tent Monitor" + comment: "Grow Tent Controller" # Growbox Nodes hostname_light: "${devicename}-light.${domain}" hostname_fan: "${devicename}-fan.${domain}" # Overrides - bme280_script: "fan_control_power" + fan_script: "fan_control_power" packages: base: !include packages/base.yaml esp32: !include packages/esp32.yaml - time: !include packages/time.yaml + time: !include packages/time_schedule.yaml bme280: !include packages/bme280.yaml yieryi2178: !include packages/yieryi3178.yaml scd40: !include packages/scd40.yaml diff --git a/packages/base.yaml b/packages/base.yaml index 7f0d829..e10e0d1 100644 --- a/packages/base.yaml +++ b/packages/base.yaml @@ -9,16 +9,14 @@ esphome: then: - lambda: |- id(sntp_time).update(); - id(fan_power_state).execute(); - id(light_power_state).execute(); substitutions: domain: !secret domain timezone: !secret timezone - bme280_script: "dummy" + fan_script: "dummy" preferences: - flash_write_interval: 0s + flash_write_interval: 5s logger: # level: INFO diff --git a/packages/bme280.yaml b/packages/bme280.yaml index c51fc6a..853a969 100644 --- a/packages/bme280.yaml +++ b/packages/bme280.yaml @@ -10,7 +10,7 @@ sensor: on_value: then: - lambda: |- - id(${bme280_script}).execute(); + id(${fan_script}).execute(); humidity: id: bme280_humidity name: "Air: Humidity" @@ -19,7 +19,7 @@ sensor: on_value: then: - lambda: |- - id(${bme280_script}).execute(); + id(${fan_script}).execute(); pressure: id: bme280_pressure name: "Air: Pressure" diff --git a/packages/fan_power.yaml b/packages/fan_power.yaml index e1f6576..83d0d84 100644 --- a/packages/fan_power.yaml +++ b/packages/fan_power.yaml @@ -1,3 +1,10 @@ +esphome: + on_boot: + priority: -200 + then: + - lambda: |- + id(fan_power_state).execute(); + switch: - platform: template id: power_fan diff --git a/packages/fan_settings.yaml b/packages/fan_settings.yaml index dae1a66..052e11f 100644 --- a/packages/fan_settings.yaml +++ b/packages/fan_settings.yaml @@ -25,6 +25,13 @@ sensor: internal: true select: + - platform: template + id: fan_mode + name: "Fan: Mode" + options: ["Power", "Speed"] + initial_option: "Power" + optimistic: true + restore_value: true - platform: template id: temperature_max name: "Fan: Temperature On" @@ -67,3 +74,23 @@ select: initial_option: "40" optimistic: true restore_value: true + +number: + - platform: template + id: fan_speed_default + name: "Fan: Speed Default" + min_value: 0 + max_value: 100 + step: 1 + mode: slider + optimistic: true + restore_value: true + - platform: template + id: fan_speed_max + name: "Fan: Speed Fast" + min_value: 0 + max_value: 100 + step: 1 + mode: slider + optimistic: true + restore_value: true diff --git a/packages/gp8403.yaml b/packages/gp8403.yaml index d3fef0d..ba46c84 100644 --- a/packages/gp8403.yaml +++ b/packages/gp8403.yaml @@ -32,7 +32,17 @@ fan: light: - platform: monochromatic + id: light_level name: "Light: Level" output: gp8403_ch1 default_transition_length: 0s gamma_correct: 0 + +prometheus: + relabel: + fan_speed: + id: fan_speed + name: "Fan Speed" + light_level: + id: light_level + name: "Light Level" diff --git a/packages/light_power.yaml b/packages/light_power.yaml index a76da53..93066fa 100644 --- a/packages/light_power.yaml +++ b/packages/light_power.yaml @@ -1,3 +1,10 @@ +esphome: + on_boot: + priority: -200 + then: + - lambda: |- + id(light_power_state).execute(); + switch: - platform: template id: power_light diff --git a/packages/light_settings.yaml b/packages/light_settings.yaml index 80d593f..059dffb 100644 --- a/packages/light_settings.yaml +++ b/packages/light_settings.yaml @@ -7,7 +7,8 @@ substitutions: sensor: - platform: template - name: "schedule" + id: light_schedule + name: "Light Schedule" lambda: return id(schedule).active_index(); internal: true diff --git a/packages/time.yaml b/packages/time.yaml index 82d0a3d..a4f830e 100644 --- a/packages/time.yaml +++ b/packages/time.yaml @@ -3,29 +3,3 @@ time: id: sntp_time timezone: ${timezone} update_interval: 1h - on_time: - - cron: ${schedule_grow_on} - then: - - lambda: |- - if (id(schedule).state == "Grow") { - id(power_light).turn_on(); - } - - cron: ${schedule_grow_off} - then: - - lambda: |- - if (id(schedule).state == "Grow") { - id(power_light).turn_off(); - } - - cron: ${schedule_bloom_on} - then: - - lambda: |- - if (id(schedule).state == "Bloom") { - id(power_light).turn_on(); - } - - cron: ${schedule_bloom_off} - then: - - lambda: |- - if (id(schedule).state == "Bloom") { - id(power_light).turn_off(); - } - diff --git a/packages/time_schedule.yaml b/packages/time_schedule.yaml new file mode 100644 index 0000000..82d0a3d --- /dev/null +++ b/packages/time_schedule.yaml @@ -0,0 +1,31 @@ +time: + - platform: sntp + id: sntp_time + timezone: ${timezone} + update_interval: 1h + on_time: + - cron: ${schedule_grow_on} + then: + - lambda: |- + if (id(schedule).state == "Grow") { + id(power_light).turn_on(); + } + - cron: ${schedule_grow_off} + then: + - lambda: |- + if (id(schedule).state == "Grow") { + id(power_light).turn_off(); + } + - cron: ${schedule_bloom_on} + then: + - lambda: |- + if (id(schedule).state == "Bloom") { + id(power_light).turn_on(); + } + - cron: ${schedule_bloom_off} + then: + - lambda: |- + if (id(schedule).state == "Bloom") { + id(power_light).turn_off(); + } + diff --git a/packages/yyac3s.yaml b/packages/yyac3s.yaml index c9c1ab9..f2580d0 100644 --- a/packages/yyac3s.yaml +++ b/packages/yyac3s.yaml @@ -11,10 +11,10 @@ fan: - platform: speed output: fan_dimmer id: fan_speed - name: "Fan Speed" + name: "Fan: Speed" prometheus: relabel: fan_speed: id: fan_speed - name: Fan Speed + name: "Fan Speed" diff --git a/propbox.yaml b/propbox.yaml index a952ba6..23da35a 100644 --- a/propbox.yaml +++ b/propbox.yaml @@ -7,12 +7,12 @@ substitutions: hostname_fan: "${devicename}-fan.${domain}" # Overrides - bme280_script: "fan_control_power" + fan_script: "fan_control_power" packages: base: !include packages/base.yaml esp32: !include packages/esp32.yaml - time: !include packages/time.yaml + time: !include packages/time_schedule.yaml bme280: !include packages/bme280.yaml ds18b20: !include packages/ds18b20.yaml yyac32: !include packages/yyac3s.yaml -- GitLab