From efa7991dee4733c9dd7fce0ac89438564845a958 Mon Sep 17 00:00:00 2001
From: Jan Grewe <jan@faked.org>
Date: Wed, 25 May 2022 22:10:19 +0200
Subject: [PATCH] fan control theoretically working through lambda

---
 propbox.yaml | 68 +++++++++++++++++++++++++++++-----------------------
 1 file changed, 38 insertions(+), 30 deletions(-)

diff --git a/propbox.yaml b/propbox.yaml
index af763d6..83f5ca0 100644
--- a/propbox.yaml
+++ b/propbox.yaml
@@ -59,49 +59,57 @@ sensor:
     battery_voltage:
       name: "Battery Voltage"
     temperature:
-      id: "temperature"
+      id: "ble_temperature"
       name: "Temperature"
       on_value_range:
         - above: ${temperature_fan_on}
           then:
-            - if:
-                condition:
-                  - sensor.in_range:
-                      id: "humidity"
-                      above: ${humidity_fan_off}
-                then:
-                  - switch.turn_on: propbox_fan
+            - switch.turn_on: propbox_fan
+          # then:
+          #   - if:
+          #       condition:
+          #         and:
+          #           - lambda: return (x > ${humidity_fan_off});
+          #           - switch.is_off: propbox_fan
+          #       then:
+          #         - switch.turn_on: propbox_fan
         - below: ${temperature_fan_off}
           then:
-            - if:
-                condition:
-                  - sensor.in_range:
-                      id: "humidity"
-                      below: ${humidity_fan_on}
-                then:
-                  - switch.turn_off: propbox_fan
+            - switch.turn_off: propbox_fan
+          # then:
+          #   - if:
+          #       condition:
+          #         and:
+          #           - lambda: return (x < ${humidity_fan_on});
+          #           - switch.is_on: propbox_fan
+          #       then:
+          #         - switch.turn_off: propbox_fan
     humidity:
-      id: "humidity"
+      id: "ble_humidity"
       name: "Humidity"
       on_value_range:
         - above: ${humidity_fan_on}
           then:
-            - if:
-                condition:
-                  - sensor.in_range:
-                      id: "temperature"
-                      above: ${temperature_fan_off}
-                then:
-                  - switch.turn_on: propbox_fan
+            - switch.turn_on: propbox_fan
+          # then:
+          #   - if:
+          #       condition:
+          #         and:
+          #           - lambda: return (x > ${temperature_fan_off});
+          #           - switch.is_off: propbox_fan
+          #       then:
+          #         - switch.turn_on: propbox_fan
         - below: ${humidity_fan_off}
           then:
-            - if:
-                condition:
-                  - sensor.in_range:
-                      id: "temperature"
-                      below: ${temperature_fan_on}
-                then:
-                  - switch.turn_off: propbox_fan
+            - switch.turn_off: propbox_fan
+          # then:
+          #   - if:
+          #       condition:
+          #         and:
+          #           - lambda: return (x < ${temperature_fan_on});
+          #           - switch.is_on: propbox_fan
+          #       then:
+          #         - switch.turn_off: propbox_fan
 
 text_sensor:
   !include include/text_sensors.yaml
-- 
GitLab