Ver código fonte

more sane aquael drive

Patryk M. Gutowski 2 meses atrás
pai
commit
7b892f3a55
1 arquivos alterados com 53 adições e 23 exclusões
  1. 53 23
      ff-akwarium-plug-01.yaml

+ 53 - 23
ff-akwarium-plug-01.yaml

@@ -2,6 +2,8 @@ substitutions:
   devicename: ff-akwarium-plug-01
   low_devicename: ff_akwarium_plug_01
   friendly_devicename: FF Akwarium Light 01
+  memory_delay: 15s
+  relay_delay: 40ms
 
 esphome:
   name: $devicename
@@ -9,6 +11,11 @@ esphome:
   platformio_options:
     lib_ignore:
       - RPAsyncTCP
+  on_boot:
+    then:
+      - light.turn_on:
+          id: blue_led
+          effect: strobe
 
 bk72xx:
   board: generic-bk7231t-qfn32-tuya
@@ -41,10 +48,13 @@ binary_sensor:
         pullup: true
     name: "Power Button"
     on_press:
-      # - output.toggle: relay
-      - select.next:
-          id: light_mode
-          cycle: true
+      - switch.toggle: relay
+      - light.turn_on:
+          id: blue_led
+          effect: strobe
+      # - select.next:
+      #    id: light_mode
+      #    cycle: true
 
 light:
   - platform: binary
@@ -53,7 +63,15 @@ light:
     output: led_1
     internal: True
     restore_mode: ALWAYS_OFF   
-
+  - platform: binary
+    name: Red LED
+    id: blue_led
+    output: led_2
+    effects:
+       - strobe:      
+#           transition_length: 50ms
+#           update_interval: 50ms
+        
 output:
   - platform: gpio
     # RED
@@ -62,13 +80,13 @@ output:
       number: P6
       inverted: false
 
-#  - platform: gpio
-#    # BLUE
-#    id: led_2
-status_led:
-  pin:
-    number: P26
-    inverted: false
+  - platform: gpio
+    # BLUE
+    id: led_2
+    pin:
+      number: P26
+      inverted: false
+
 
 globals:
   - id: current_light
@@ -92,26 +110,34 @@ select:
               - lambda: |-
                   return(id(light_mode).state) == "Off";
             then:
+              - light.turn_off: red_led
+              - light.turn_off: blue_led
               - switch.turn_off: relay
         - if:
             condition:
               - lambda: |-
                   return(id(light_mode).state) == "Day";
             then:
+              - light.turn_off: blue_led
+              - light.turn_on: red_led
               - switch.turn_off: relay
-              - delay: 20s
+              - light.turn_on: red_led
+              - delay: $memory_delay
               - switch.turn_on: relay
         - if:
             condition:
               - lambda: |-
                   return(id(light_mode).state) == "Daybreak";
             then:
+              - light.turn_off: blue_led
+              - light.turn_on: red_led
               - switch.turn_off: relay    
-              - delay: 20s
+              - light.turn_on: red_led
+              - delay: $memory_delay
               - switch.turn_on: relay
-              - delay: 200ms
+              - delay: $relay_delay
               - switch.turn_off: relay
-              - delay: 200ms
+              - delay: $relay_delay
               - switch.turn_on: relay
           
         - if:
@@ -119,15 +145,19 @@ select:
               - lambda: |-
                   return(id(light_mode).state) == "Night";
             then:
+              - light.turn_off: blue_led
+              - light.turn_on: red_led
               - switch.turn_off: relay    
-              - delay: 20s
+              - light.turn_on: red_led
+              - delay: $memory_delay
               - switch.turn_on: relay
-              - delay: 200ms
+              - delay: $relay_delay
               - switch.turn_off: relay
-              - delay: 200ms
+              - delay: $relay_delay
               - switch.turn_on: relay
+              - delay: $relay_delay
               - switch.turn_off: relay
-              - delay: 200ms
+              - delay: $relay_delay
               - switch.turn_on: relay
         - lambda: |- 
             id(current_light) == id(light_mode).active_index();
@@ -141,11 +171,11 @@ switch:
     # Turn off red LED to show blue when turned on
     on_turn_on:
      - light.turn_on: red_led
-    #  - switch.turn_off: led_1
-    # Turns on the red LED once the plug is turned off
+#    #  - switch.turn_off: led_1
+#    # Turns on the red LED once the plug is turned off
     on_turn_off:
       - light.turn_off: red_led
-    #  - switch.turn_on: led_1
+#    #  - switch.turn_on: led_1
 #  - platform: template
 #    name: mode
 #    output: relay