Skip to content
Snippets Groups Projects
Commit 925863f3 authored by Jan Grewe's avatar Jan Grewe
Browse files

add selects for max/min/hysteresis

remove globals, use only selects
parent dcaf0bd1
Branches
No related tags found
No related merge requests found
......@@ -19,13 +19,6 @@ substitutions:
schedule_bloom_on: "0 * * * * *"
schedule_bloom_off: "30 * * * * *"
temperature_max: "27"
temperature_min: "21"
temperature_hysteresis: "2"
humidity_max: "70"
humidity_min: "40"
humidity_hysteresis: "5"
<<: !include common.yaml
esp32:
......@@ -44,12 +37,6 @@ http_request:
useragent: esphome/${devicename}
timeout: 10s
globals:
- id: schedule
type: int
restore_value: true
initial_value: '0'
text_sensor:
!include include/text_sensors.yaml
......@@ -96,19 +83,54 @@ sensor:
select:
- platform: template
id: select_schedule
id: schedule
name: "Light Schedule"
options:
- "Disabled"
- "Grow"
- "Bloom"
options: ["Disabled", "Grow", "Bloom"]
initial_option: "Disabled"
optimistic: true
restore_value: true
- platform: template
id: temperature_max
name: "Temperature: Fan On"
options: ["21", "22", "23", "24", "25", "26", "27", "28", "29"]
initial_option: "27"
optimistic: true
restore_value: true
- platform: template
id: temperature_hysteresis
name: "Temperature: Fan Hysteresis"
options: ["1", "2", "3", "4", "5"]
initial_option: "2"
optimistic: true
restore_value: true
- platform: template
id: temperature_min
name: "Temperature: Fan Off"
options: ["19", "20", "21", "22", "23", "24", "25"]
initial_option: "21"
optimistic: true
restore_value: true
- platform: template
id: humidity_max
name: "Humidity: Fan On"
options: ["40", "45", "50", "55", "60", "65", "70", "75"]
initial_option: "70"
optimistic: true
restore_value: true
- platform: template
id: humidity_hysteresis
name: "Humidity: Fan Hysteresis"
options: ["5", "10", "15"]
initial_option: "5"
optimistic: true
restore_value: true
- platform: template
id: humidity_min
name: "Humidity: Fan Off"
options: ["20", "25", "30", "35", "40", "45", "50"]
initial_option: "40"
optimistic: true
restore_value: true
on_value:
then:
- lambda: |-
auto index = id(select_schedule).active_index();
id(schedule) = index.value();
switch:
- platform: restart
......@@ -151,28 +173,28 @@ time:
- cron: ${schedule_grow_on}
then:
- lambda: |-
if (id(schedule) == 1) {
if (id(schedule).state == "Grow") {
id(propbox_light).turn_on();
id(propbox_light).publish_state(true);
}
- cron: ${schedule_grow_off}
then:
- lambda: |-
if (id(schedule) == 1) {
if (id(schedule).state == "Grow") {
id(propbox_light).turn_off();
id(propbox_light).publish_state(false);
}
- cron: ${schedule_bloom_on}
then:
- lambda: |-
if (id(schedule) == 2) {
if (id(schedule).state == "Bloom") {
id(propbox_light).turn_on();
id(propbox_light).publish_state(true);
}
- cron: ${schedule_bloom_off}
then:
- lambda: |-
if (id(schedule) == 2) {
if (id(schedule).state == "Bloom") {
id(propbox_light).turn_off();
id(propbox_light).publish_state(false);
}
......@@ -184,8 +206,8 @@ script:
// switch fan on when temperature/humidity is above the limit, unless humidity/temperature is below the limit
if (
!id(propbox_fan).state &&
(id(temperature).state >= ${temperature_max} && id(humidity).state >= ${humidity_min}) ||
(id(humidity).state >= ${humidity_max} && id(temperature).state >= ${temperature_min})
(id(temperature).state >= atoi(id(temperature_max).state.c_str()) && id(humidity).state >= atoi(id(humidity_min).state.c_str())) ||
(id(humidity).state >= atoi(id(humidity_max).state.c_str()) && id(temperature).state >= atoi(id(temperature_min).state.c_str()))
) {
id(propbox_fan).turn_on();
id(propbox_fan).publish_state(true);
......@@ -194,8 +216,8 @@ script:
// switch fan off when temperature and humidity are below the limits minus hysteresis
else if (
id(propbox_fan).state &&
id(temperature).state <= ${temperature_max} - ${temperature_hysteresis} &&
id(humidity).state <= ${humidity_max} - ${humidity_hysteresis}
id(temperature).state <= atoi(id(temperature_max).state.c_str()) - atoi(id(temperature_hysteresis).state.c_str()) &&
id(humidity).state <= atoi(id(humidity_max).state.c_str()) - atoi(id(humidity_hysteresis).state.c_str())
) {
id(propbox_fan).turn_off();
id(propbox_fan).publish_state(false);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment