Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
GrowSmart - ESPHome
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jan Grewe
GrowSmart - ESPHome
Commits
476c5f16
Commit
476c5f16
authored
2 years ago
by
Jan Grewe
Browse files
Options
Downloads
Patches
Plain Diff
fix fan control logic
parent
65a13fe1
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
packages/fan.yaml
+28
-10
28 additions, 10 deletions
packages/fan.yaml
with
28 additions
and
10 deletions
packages/fan.yaml
+
28
−
10
View file @
476c5f16
...
...
@@ -55,21 +55,21 @@ select:
-
platform
:
template
id
:
temperature_hysteresis
name
:
"
Fan:
Temperature
Hysteresis"
options
:
[
"
1"
,
"
2"
,
"
3"
,
"
4"
,
"
5"
]
options
:
[
"
1"
,
"
2"
,
"
3"
,
"
4"
,
"
5"
,
"
6"
,
"
7"
,
"
8"
,
"
9"
,
"
10"
]
initial_option
:
"
1"
optimistic
:
true
restore_value
:
true
-
platform
:
template
id
:
temperature_min
name
:
"
Fan:
Temperature
Off"
options
:
[
"
19"
,
"
20"
,
"
21"
,
"
22"
,
"
23"
,
"
24"
,
"
25"
]
options
:
[
"
15"
,
"
16"
,
"
17"
,
"
18"
,
"
19"
,
"
20"
,
"
21"
,
"
22"
,
"
23"
,
"
24"
,
"
25"
]
initial_option
:
"
21"
optimistic
:
true
restore_value
:
true
-
platform
:
template
id
:
humidity_max
name
:
"
Fan:
Humidity
On"
options
:
[
"
40"
,
"
45"
,
"
50"
,
"
55"
,
"
60"
,
"
65"
,
"
70"
,
"
75"
,
"
80"
]
options
:
[
"
40"
,
"
45"
,
"
50"
,
"
55"
,
"
60"
,
"
65"
,
"
70"
,
"
75"
,
"
80"
,
"
85"
,
"
90"
]
initial_option
:
"
70"
optimistic
:
true
restore_value
:
true
...
...
@@ -83,7 +83,7 @@ select:
-
platform
:
template
id
:
humidity_min
name
:
"
Fan:
Humidity
Off"
options
:
[
"
20"
,
"
25"
,
"
30"
,
"
35"
,
"
40"
,
"
45"
,
"
50"
,
"
55"
,
"
60"
]
options
:
[
"
25"
,
"
30"
,
"
35"
,
"
40"
,
"
45"
,
"
50"
,
"
55"
,
"
60"
,
"
65"
,
"
70"
,
"
80"
]
initial_option
:
"
40"
optimistic
:
true
restore_value
:
true
...
...
@@ -107,20 +107,38 @@ script:
-
id
:
fan_control
then
:
-
lambda
:
|-
// switch fan on when temperature/humidity is above max, unless humidity/temperature is below min
// Normal On:
// switch fan on when either temperature or humidity is above "max", unless humidity/temperature is below "min"
if (
!id(propbox_fan).state &&
((id(bme280_temperature).state >= atoi(id(temperature_max).state.c_str()) && id(bme280_humidity).state >= atoi(id(humidity_min).state.c_str())) ||
( id(bme280_humidity).state >= atoi(id(humidity_max).state.c_str()) && id(bme280_temperature).state >= atoi(id(temperature_min).state.c_str())))
(
(id(bme280_temperature).state >= atoi(id(temperature_max).state.c_str()) && id(bme280_humidity).state >= atoi(id(humidity_min).state.c_str())) ||
(id(bme280_humidity).state >= atoi(id(humidity_max).state.c_str()) && id(bme280_temperature).state >= atoi(id(temperature_min).state.c_str()))
)
) {
id(propbox_fan).turn_on();
}
// switch fan off when temperature and humidity are below max minus hysteresis
// Forced Off, ignoring Hysteresis:
// switch fan off when either temperature or humidity are below "min", unless humidity/temperature is above "max"
else if (
id(propbox_fan).state &&
(
(id(bme280_temperature).state <= atoi(id(temperature_min).state.c_str()) && id(bme280_humidity).state <= atoi(id(humidity_max).state.c_str())) ||
(id(bme280_humidity).state <= atoi(id(humidity_min).state.c_str()) && id(bme280_temperature).state <= atoi(id(temperature_max).state.c_str()))
)
) {
id(propbox_fan).turn_off();
}
// Normal Off, respecting Hysteresis:
// switch fan off when both temperature and humidity are below "max minus hysteresis"
else if (
id(propbox_fan).state &&
(
id(bme280_temperature).state <= atoi(id(temperature_max).state.c_str()) - atoi(id(temperature_hysteresis).state.c_str()) &&
id(bme280_humidity).state <= atoi(id(humidity_max).state.c_str()) - atoi(id(humidity_hysteresis).state.c_str())
)
) {
id(propbox_fan).turn_off();
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment