From cd17c0a382e8be55c3cb07888fba5a356a38ef22 Mon Sep 17 00:00:00 2001
From: Jan Grewe <jan@faked.org>
Date: Sat, 28 May 2022 13:31:39 +0200
Subject: [PATCH] remove unnecessary publish_state() calls

---
 propbox.yaml | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/propbox.yaml b/propbox.yaml
index db2c1da..1159af9 100644
--- a/propbox.yaml
+++ b/propbox.yaml
@@ -159,52 +159,46 @@ time:
           - lambda: |-
               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).state == "Grow") {
                 id(propbox_light).turn_off();
-                id(propbox_light).publish_state(false);
               }
       - cron: ${schedule_bloom_on}
         then:
           - lambda: |-
               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).state == "Bloom") {
                 id(propbox_light).turn_off();
-                id(propbox_light).publish_state(false);
               }
 
 script:
   - id: fan_control
     then:
       - lambda: |-
-          // switch fan on when temperature/humidity is above the limit, unless humidity/temperature is below the limit
+          // switch fan on when temperature/humidity is above max, unless humidity/temperature is below min 
           if (
             !id(propbox_fan).state &&
             (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);
           }
 
-          // switch fan off when temperature and humidity are below the limits minus hysteresis
+          // switch fan off when temperature and humidity are below max minus hysteresis
           else if (
             id(propbox_fan).state &&
             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);
           }
   - id: propbox_light_state
     then:
-- 
GitLab