Advertisement
DeanoX

ESPHome Alarm (inc ADS1115/Neopixel) YAML

Dec 27th, 2019
1,508
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 21.53 KB | None | 0 0
  1. # D1 Mini - Alarm Panel
  2. # 2 x ADS1115 for 8 x Alarm zones (GPIO4/5)
  3. # 1 x DHT11 (GPIO14)
  4. # 1 x LED String (8 zone Indicators) (GPIO15)
  5. # 1 x Switch (LEDs Enable/Disable) (GPIO13)
  6. esphome:
  7.   name: esp_alarm
  8.   comment: D1 Mini - Loft - Alarm Panel
  9.   platform: ESP8266
  10.   board: esp01_1m
  11. #  board: d1_mini
  12.  
  13. wifi:
  14.   ssid: 'xxxx'
  15.   password: 'xxxx'
  16.   manual_ip:
  17.     static_ip: 192.168.1.52
  18.     gateway: 192.168.1.254
  19.     subnet: 255.255.255.0
  20.  
  21. # Enable logging
  22. logger:
  23.   level: DEBUG
  24.   baud_rate: 0
  25.   logs:
  26.     ads1115: ERROR
  27. #  level: INFO
  28. # Enable Home Assistant API
  29. api:
  30. ota:
  31. # web_server:
  32.  
  33. substitutions:
  34. # Common ADS1115 Sensor Setting
  35.   ads_gain: "6.144"
  36.   ads_update_interval: "500ms"
  37.   ads_delta: "0.2"
  38.   ads_heartbeat: "120s"
  39.  
  40. # Common Text Sensor Setting
  41.   zone_icon: "mdi:lock-alert"
  42.  
  43. # Common Zone (Int) Sensor Setting
  44.   sensor_icon: "mdi:shield-lock"
  45.  
  46. # Neopixel Brigtness
  47.   led_bright: "50%"
  48.  
  49. # Transition Voltages between States
  50. #  0 -> (State1) -> V1 -> (State2) -> V2 -> (State3) -> V3 -> (State4)
  51.   v1: "1"
  52.   v2: "2.5"
  53.   v3: "3.5"
  54. # Text Sensor strings for each state
  55.   alarm_state1: "Short"
  56.   alarm_state2: "OK"
  57.   alarm_state3: "Alarm"
  58.   alarm_state4: "Tamper"
  59. # Led Effect
  60.   led_effect1: "RED_BLINK_FAST"
  61.   led_effect2: "GREEN"
  62.   led_effect3: "RED"
  63.   led_effect4: "RED_BLINK_FAST"
  64.  
  65. # I2C Settings for 2 x ADS1115
  66. i2c:
  67.   sda: GPIO4
  68.   scl: GPIO5
  69.   scan: False
  70.  
  71. ads1115:
  72. # 1st ADS1115 (ADDR -> Grnd)
  73.   - address: 0x48
  74.     id: ads1115_1
  75. # 2nd ADS1115 (ADDR -> VDD)
  76.   - address: 0x49
  77.     id: ads1115_2
  78.  
  79. # NEOPixel Leds. 1 String with 1 LED / Zone via partition
  80. light:
  81.  # Define Parent String
  82.   - platform: fastled_clockless
  83.     chipset: WS2812B
  84.     internal: true
  85.     rgb_order: GRB
  86.     default_transition_length: 0s
  87.     pin: GPIO15
  88.     color_correct :
  89.       - ${led_bright}
  90.       - ${led_bright}
  91.       - ${led_bright}
  92.     num_leds: 12
  93.     name: "LED_Status_String"
  94.     id: led_string
  95.  
  96.     # 1 Partition (Indicator LED) per Zone
  97.     # Zone 1
  98.   - platform: partition
  99.     id: led_01
  100.     internal: true
  101.     name: "Zone 1 LED"
  102.     default_transition_length: 0s
  103.     segments:
  104.       - id: led_string
  105.         from: 0
  106.         to: 0
  107.     # Include Common Effects - RED/GREEN/BLINK_RED_SLOW/BLINK_RED_FAST
  108.     effects: !include include/esp_include_alarm_led_effect.yaml
  109.     # Zone 2
  110.   - platform: partition
  111.     id: led_02
  112.     internal: true
  113.     name: "Zone 2 LED"
  114.     default_transition_length: 0s
  115.     segments:
  116.       - id: led_string
  117.         from: 1
  118.         to: 1
  119.     # Include Common Effects - RED/GREEN/BLINK_RED_SLOW/BLINK_RED_FAST
  120.     effects: !include include/esp_include_alarm_led_effect.yaml
  121.     # Zone 3
  122.   - platform: partition
  123.     id: led_03
  124.     internal: true
  125.     name: "Zone 3 LED"
  126.     default_transition_length: 0s
  127.     segments:
  128.       - id: led_string
  129.         from: 2
  130.         to: 2
  131.     # Include Common Effects - RED/GREEN/BLINK_RED_SLOW/BLINK_RED_FAST
  132.     effects: !include include/esp_include_alarm_led_effect.yaml
  133.     # Zone 4
  134.   - platform: partition
  135.     id: led_04
  136.     internal: true
  137.     name: "Zone 4 LED"
  138.     default_transition_length: 0s
  139.     segments:
  140.       - id: led_string
  141.         from: 3
  142.         to: 3
  143.     # Include Common Effects - RED/GREEN/BLINK_RED_SLOW/BLINK_RED_FAST
  144.     effects: !include include/esp_include_alarm_led_effect.yaml
  145.   - platform: partition
  146.     id: led_05
  147.     internal: true
  148.     name: "Zone 5 LED"
  149.     default_transition_length: 0s
  150.     segments:
  151.       - id: led_string
  152.         from: 4
  153.         to: 4
  154.     # Include Common Effects - RED/GREEN/BLINK_RED_SLOW/BLINK_RED_FAST
  155.     effects: !include include/esp_include_alarm_led_effect.yaml
  156.   - platform: partition
  157.     id: led_06
  158.     internal: true
  159.     name: "Zone 6 LED"
  160.     default_transition_length: 0s
  161.     segments:
  162.       - id: led_string
  163.         from: 5
  164.         to: 5
  165.     # Include Common Effects - RED/GREEN/BLINK_RED_SLOW/BLINK_RED_FAST
  166.     effects: !include include/esp_include_alarm_led_effect.yaml
  167.   - platform: partition
  168.     id: led_07
  169.     internal: true
  170.     name: "Zone 7 LED"
  171.     default_transition_length: 0s
  172.     segments:
  173.       - id: led_string
  174.         from: 6
  175.         to: 6
  176.     # Include Common Effects - RED/GREEN/BLINK_RED_SLOW/BLINK_RED_FAST
  177.     effects: !include include/esp_include_alarm_led_effect.yaml
  178.   - platform: partition
  179.     id: led_08
  180.     internal: true
  181.     name: "Zone 8 LED"
  182.     default_transition_length: 0s
  183.     segments:
  184.       - id: led_string
  185.         from: 7
  186.         to: 7
  187.     # Include Common Effects - RED/GREEN/BLINK_RED_SLOW/BLINK_RED_FAST
  188.     effects: !include include/esp_include_alarm_led_effect.yaml
  189.   - platform: partition
  190.     id: led_09
  191.     internal: true
  192.     name: "Flow 1 LED"
  193.     default_transition_length: 0s
  194.     segments:
  195.       - id: led_string
  196.         from: 8
  197.         to: 8
  198.     # Include Common Effects - RED/GREEN/BLINK_RED_SLOW/BLINK_RED_FAST
  199.     effects: !include include/esp_include_alarm_led_effect.yaml
  200.   - platform: partition
  201.     id: led_10
  202.     internal: true
  203.     name: "Flow 2 LED"
  204.     default_transition_length: 0s
  205.     segments:
  206.       - id: led_string
  207.         from: 9
  208.         to: 9
  209.     # Include Common Effects - RED/GREEN/BLINK_RED_SLOW/BLINK_RED_FAST
  210.     effects: !include include/esp_include_alarm_led_effect.yaml
  211.  
  212. sensor:
  213.   - platform: uptime
  214.     name: Uptime Sensor
  215.   # DHT11 Temp/Humidity Sensor
  216.   - platform: dht
  217.     model: dht11
  218.     pin: GPIO14
  219.     temperature:
  220.       name: "Alarm Temperature"
  221.       id: alarm_temperature
  222.     humidity:
  223.       name: "Alarm Humidity"
  224.       id: alarm_humidity
  225.     update_interval: 60s
  226.    
  227.     # Integer State Sensors, Controls Zone Text Sensor and Zone Indicator LED Effect
  228.   - platform: template
  229.     name: "Zone01 Sensor"
  230.     id: zone_01_int
  231.     icon: "${sensor_icon}"
  232.     on_value:
  233.      # When Zone state (1-4) changes, set effect if Lights enabled, Set Text State
  234.       - lambda: |-
  235.           std::string out_effect[] = {"Unset","${led_effect1}","${led_effect2}","${led_effect3}","${led_effect4}" };
  236.           std::string out_state[] = {"Unset","${alarm_state1}","${alarm_state2}","${alarm_state3}","${alarm_state4}" };
  237.           int y = (int) x;
  238.           if (id(sw_lights_enable).state) {
  239.             auto call = id(led_01).turn_on();
  240.             call.set_effect(out_effect[y]);
  241.             call.perform();
  242.           }
  243.           id(zone_01_str).publish_state(out_state[y]);
  244.   - platform: template
  245.     name: "Zone02 Sensor"
  246.     id: zone_02_int
  247.     icon: "${sensor_icon}"
  248.     on_value:
  249.      # When Zone state (1-4) changes, set effect if Lights enabled, Set Text State
  250.       - lambda: |-
  251.           std::string out_effect[] = {"Unset","${led_effect1}","${led_effect2}","${led_effect3}","${led_effect4}" };
  252.           std::string out_state[] = {"Unset","${alarm_state1}","${alarm_state2}","${alarm_state3}","${alarm_state4}" };
  253.           int y = (int) x;
  254.           if (id(sw_lights_enable).state) {
  255.             auto call = id(led_02).turn_on();
  256.             call.set_effect(out_effect[y]);
  257.             call.perform();
  258.           }
  259.           id(zone_02_str).publish_state(out_state[y]);
  260.   - platform: template
  261.     name: "Zone03 Sensor"
  262.     id: zone_03_int
  263.     icon: "${sensor_icon}"
  264.     on_value:
  265.      # When Zone state (1-4) changes, set effect if Lights enabled, Set Text State
  266.       - lambda: |-
  267.           std::string out_effect[] = {"Unset","${led_effect1}","${led_effect2}","${led_effect3}","${led_effect4}" };
  268.           std::string out_state[] = {"Unset","${alarm_state1}","${alarm_state2}","${alarm_state3}","${alarm_state4}" };
  269.           int y = (int) x;
  270.           if (id(sw_lights_enable).state) {
  271.             auto call = id(led_03).turn_on();
  272.             call.set_effect(out_effect[y]);
  273.             call.perform();
  274.           }
  275.           id(zone_03_str).publish_state(out_state[y]);
  276.   - platform: template
  277.     name: "Zone04 Sensor"
  278.     id: zone_04_int
  279.     icon: "${sensor_icon}"
  280.     on_value:
  281.      # When Zone state (1-4) changes, set effect if Lights enabled, Set Text State
  282.       - lambda: |-
  283.           std::string out_effect[] = {"Unset","${led_effect1}","${led_effect2}","${led_effect3}","${led_effect4}" };
  284.           std::string out_state[] = {"Unset","${alarm_state1}","${alarm_state2}","${alarm_state3}","${alarm_state4}" };
  285.           int y = (int) x;
  286.           if (id(sw_lights_enable).state) {
  287.             auto call = id(led_04).turn_on();
  288.             call.set_effect(out_effect[y]);
  289.             call.perform();
  290.           }
  291.           id(zone_04_str).publish_state(out_state[y]);
  292.   - platform: template
  293.     name: "Zone05 Sensor"
  294.     id: zone_05_int
  295.     icon: "${sensor_icon}"
  296.     on_value:
  297.      # When Zone state (1-4) changes, set effect if Lights enabled, Set Text State
  298.       - lambda: |-
  299.           std::string out_effect[] = {"Unset","${led_effect1}","${led_effect2}","${led_effect3}","${led_effect4}" };
  300.           std::string out_state[] = {"Unset","${alarm_state1}","${alarm_state2}","${alarm_state3}","${alarm_state4}" };
  301.           int y = (int) x;
  302.           if (id(sw_lights_enable).state) {
  303.             auto call = id(led_05).turn_on();
  304.             call.set_effect(out_effect[y]);
  305.             call.perform();
  306.           }
  307.           id(zone_05_str).publish_state(out_state[y]);
  308.   - platform: template
  309.     name: "Zone06 Sensor"
  310.     id: zone_06_int
  311.     icon: "${sensor_icon}"
  312.     on_value:
  313.      # When Zone state (1-4) changes, set effect if Lights enabled, Set Text State
  314.       - lambda: |-
  315.           std::string out_effect[] = {"Unset","${led_effect1}","${led_effect2}","${led_effect3}","${led_effect4}" };
  316.           std::string out_state[] = {"Unset","${alarm_state1}","${alarm_state2}","${alarm_state3}","${alarm_state4}" };
  317.           int y = (int) x;
  318.           if (id(sw_lights_enable).state) {
  319.             auto call = id(led_06).turn_on();
  320.             call.set_effect(out_effect[y]);
  321.             call.perform();
  322.           }
  323.           id(zone_06_str).publish_state(out_state[y]);
  324.   - platform: template
  325.     name: "Zone07 Sensor"
  326.     id: zone_07_int
  327.     icon: "${sensor_icon}"
  328.     on_value:
  329.      # When Zone state (1-4) changes, set effect if Lights enabled, Set Text State
  330.       - lambda: |-
  331.           std::string out_effect[] = {"Unset","${led_effect1}","${led_effect2}","${led_effect3}","${led_effect4}" };
  332.           std::string out_state[] = {"Unset","${alarm_state1}","${alarm_state2}","${alarm_state3}","${alarm_state4}" };
  333.           int y = (int) x;
  334.           if (id(sw_lights_enable).state) {
  335.             auto call = id(led_07).turn_on();
  336.             call.set_effect(out_effect[y]);
  337.             call.perform();
  338.           }
  339.           id(zone_07_str).publish_state(out_state[y]);
  340.   - platform: template
  341.     name: "Zone08 Sensor"
  342.     id: zone_08_int
  343.     icon: "${sensor_icon}"
  344.     on_value:
  345.      # When Zone state (1-4) changes, set effect if Lights enabled, Set Text State
  346.       - lambda: |-
  347.           std::string out_effect[] = {"Unset","${led_effect1}","${led_effect2}","${led_effect3}","${led_effect4}" };
  348.           std::string out_state[] = {"Unset","${alarm_state1}","${alarm_state2}","${alarm_state3}","${alarm_state4}" };
  349.           int y = (int) x;
  350.           if (id(sw_lights_enable).state) {
  351.             auto call = id(led_08).turn_on();
  352.             call.set_effect(out_effect[y]);
  353.             call.perform();
  354.           }
  355.           id(zone_08_str).publish_state(out_state[y]);
  356.  
  357.   # ADS1115 Voltage Sensors (1 per Zone)  
  358.   - platform: ads1115
  359.     ads1115_id: ads1115_1
  360.     multiplexer: 'A0_GND'
  361.     gain: ${ads_gain}
  362.     name: "ADS1115-1-A0"
  363.     id: ads1115_1_a0
  364.     update_interval: ${ads_update_interval}
  365.     internal: true
  366.     filters:
  367.       - or:
  368.         - delta: ${ads_delta}
  369.         - heartbeat: ${ads_heartbeat}
  370.     on_value:
  371.       then:
  372.        # Compare Reading to Ref voltages and set zone state (Int) if changed.
  373.         - lambda: |-
  374.             int y = 0;
  375.             if (x > ${v2} ) { y = 3; }  // # State 3 = Alarm = Red
  376.             else if (x <= ${v2}) { y = 2; }  // # State 2 = OK = Green
  377.             if (id(zone_01_int).state != y) {
  378.               id(zone_01_int).publish_state(y);
  379.             }
  380.   - platform: ads1115
  381.     ads1115_id: ads1115_1
  382.     multiplexer: 'A1_GND'
  383.     gain: ${ads_gain}
  384.     name: "ADS1115-1-A1"
  385.     id: ads1115_1_a1
  386.     update_interval: ${ads_update_interval}
  387.     internal: true
  388.     filters:
  389.       - or:
  390.         - delta: ${ads_delta}
  391.         - heartbeat: ${ads_heartbeat}
  392.     on_value:
  393.       then:
  394.        # Compare Reading to Ref voltages and set zone state (Int) if changed.
  395.         - lambda: |-
  396.             int y = 0;
  397.             if (x > ${v3}) { y = 4; }                     // # State 4 = Tamper/Short = Red_Blink
  398.             else if (x > ${v2} && x <= ${v3}) { y = 3; }  // # State 3 = Alarm = Red
  399.             else if (x > ${v1} && x <= ${v2}) { y = 2; }  // # State 2 = OK = Green
  400.             else if (x <= ${v1}) { y = 1; }               // # State 1 = Short = Red Blink
  401.             if (id(zone_02_int).state != y) {
  402.               id(zone_02_int).publish_state(y);
  403.             }
  404.   - platform: ads1115
  405.     ads1115_id: ads1115_1
  406.     multiplexer: 'A2_GND'
  407.     gain: ${ads_gain}
  408.     name: "ADS1115-1-A2"
  409.     id: ads1115_1_a2
  410.     update_interval: ${ads_update_interval}
  411.     internal: true
  412.     filters:
  413.       - or:
  414.         - delta: ${ads_delta}
  415.         - heartbeat: ${ads_heartbeat}
  416.     on_value:
  417.       then:
  418.        # Compare Reading to Ref voltages and set zone state (Int) if changed.
  419.         - lambda: |-
  420.             int y = 0;
  421.             if (x > ${v3}) { y = 4; }                     // # State 4 = Tamper/Short = Red_Blink
  422.             else if (x > ${v2} && x <= ${v3}) { y = 3; }  // # State 3 = Alarm = Red
  423.             else if (x > ${v1} && x <= ${v2}) { y = 2; }  // # State 2 = OK = Green
  424.             else if (x <= ${v1}) { y = 1; }               // # State 1 = Short = Red Blink
  425.             if (id(zone_03_int).state != y) {
  426.               id(zone_03_int).publish_state(y);
  427.             }
  428.   - platform: ads1115
  429.     ads1115_id: ads1115_1
  430.     multiplexer: 'A3_GND'
  431.     gain: ${ads_gain}
  432.     name: "ADS1115-1-A3"
  433.     id: ads1115_1_a3
  434.     update_interval: ${ads_update_interval}
  435.     internal: true
  436.     filters:
  437.       - or:
  438.         - delta: ${ads_delta}
  439.         - heartbeat: ${ads_heartbeat}
  440.     on_value:
  441.       then:
  442.        # Compare Reading to Ref voltages and set zone state (Int) if changed.
  443.         - lambda: |-
  444.             int y = 0;
  445.             if (x > ${v3}) { y = 4; }                     // # State 4 = Tamper/Short = Red_Blink
  446.             else if (x > ${v2} && x <= ${v3}) { y = 3; }  // # State 3 = Alarm = Red
  447.             else if (x > ${v1} && x <= ${v2}) { y = 2; }  // # State 2 = OK = Green
  448.             else if (x <= ${v1}) { y = 1; }               // # State 1 = Short = Red Blink
  449.             if (id(zone_04_int).state != y) {
  450.               id(zone_04_int).publish_state(y);
  451.             }
  452.   - platform: ads1115
  453.     ads1115_id: ads1115_2
  454.     multiplexer: 'A0_GND'
  455.     gain: ${ads_gain}
  456.     name: "ADS1115-2-A0"
  457.     id: ads1115_2_a0
  458.     update_interval: ${ads_update_interval}
  459.     internal: true
  460.     filters:
  461.       - or:
  462.         - delta: ${ads_delta}
  463.         - heartbeat: ${ads_heartbeat}
  464.     on_value:
  465.       then:
  466.        # Compare Reading to Ref voltages and set zone state (Int) if changed.
  467.         - lambda: |-
  468.             int y = 0;
  469.             if (x > ${v3}) { y = 4; }                     // # State 4 = Tamper/Short = Red_Blink
  470.             else if (x > ${v2} && x <= ${v3}) { y = 3; }  // # State 3 = Alarm = Red
  471.             else if (x > ${v1} && x <= ${v2}) { y = 2; }  // # State 2 = OK = Green
  472.             else if (x <= ${v1}) { y = 1; }               // # State 1 = Short = Red Blink
  473.             if (id(zone_05_int).state != y) {
  474.               id(zone_05_int).publish_state(y);
  475.             }
  476.   - platform: ads1115
  477.     ads1115_id: ads1115_2
  478.     multiplexer: 'A1_GND'
  479.     gain: ${ads_gain}
  480.     name: "ADS1115-2-A1"
  481.     id: ads1115_2_a1
  482.     update_interval: ${ads_update_interval}
  483.     internal: true
  484.     filters:
  485.       - or:
  486.         - delta: ${ads_delta}
  487.         - heartbeat: ${ads_heartbeat}
  488.     on_value:
  489.       then:
  490.        # Compare Reading to Ref voltages and set zone state (Int) if changed.
  491.         - lambda: |-
  492.             int y = 0;
  493.             if (x > ${v3}) { y = 4; }                     // # State 4 = Tamper/Short = Red_Blink
  494.             else if (x > ${v2} && x <= ${v3}) { y = 3; }  // # State 3 = Alarm = Red
  495.             else if (x > ${v1} && x <= ${v2}) { y = 2; }  // # State 2 = OK = Green
  496.             else if (x <= ${v1}) { y = 1; }               // # State 1 = Short = Red Blink
  497.             if (id(zone_06_int).state != y) {
  498.               id(zone_06_int).publish_state(y);
  499.             }
  500.   - platform: ads1115
  501.     ads1115_id: ads1115_2
  502.     multiplexer: 'A2_GND'
  503.     gain: ${ads_gain}
  504.     name: "ADS1115-2-A2"
  505.     id: ads1115_2_a2
  506.     update_interval: ${ads_update_interval}
  507.     internal: true
  508.     filters:
  509.       - or:
  510.         - delta: ${ads_delta}
  511.         - heartbeat: ${ads_heartbeat}
  512.     on_value:
  513.       then:
  514.        # Compare Reading to Ref voltages and set zone state (Int) if changed.
  515.         - lambda: |-
  516.             int y = 0;
  517.             if (x > ${v3}) { y = 4; }                     // # State 4 = Tamper/Short = Red_Blink
  518.             else if (x > ${v2} && x <= ${v3}) { y = 3; }  // # State 3 = Alarm = Red
  519.             else if (x > ${v1} && x <= ${v2}) { y = 2; }  // # State 2 = OK = Green
  520.             else if (x <= ${v1}) { y = 1; }               // # State 1 = Short = Red Blink
  521.             if (id(zone_07_int).state != y) {
  522.               id(zone_07_int).publish_state(y);
  523.             }
  524.   - platform: ads1115
  525.     ads1115_id: ads1115_2
  526.     multiplexer: 'A3_GND'
  527.     gain: ${ads_gain}
  528.     name: "ADS1115-2-A3"
  529.     id: ads1115_2_a3
  530.     update_interval: ${ads_update_interval}
  531.     internal: true
  532.     filters:
  533.       - or:
  534.         - delta: ${ads_delta}
  535.         - heartbeat: ${ads_heartbeat}
  536.     on_value:
  537.       then:
  538.        # Compare Reading to Ref voltages and set zone state (Int) if changed.
  539.         - lambda: |-
  540.             int y = 0;
  541.             if (x > ${v3}) { y = 4; }                     // # State 4 = Tamper/Short = Red_Blink
  542.             else if (x > ${v2} && x <= ${v3}) { y = 3; }  // # State 3 = Alarm = Red
  543.             else if (x > ${v1} && x <= ${v2}) { y = 2; }  // # State 2 = OK = Green
  544.             else if (x <= ${v1}) { y = 1; }               // # State 1 = Short = Red Blink
  545.             if (id(zone_08_int).state != y) {
  546.               id(zone_08_int).publish_state(y);
  547.             }
  548.  
  549. # Text Sensors visible to HA, 1 per Zone
  550. text_sensor:
  551.   - platform: template
  552.     name: "Zone01 State"
  553.     icon: "${zone_icon}"
  554.     id: zone_01_str
  555.   - platform: template
  556.     name: "Zone02 State"
  557.     icon: "${zone_icon}"
  558.     id: zone_02_str
  559.   - platform: template
  560.     name: "Zone03 State"
  561.     icon: "${zone_icon}"
  562.     id: zone_03_str
  563.   - platform: template
  564.     name: "Zone04 State"
  565.     icon: "${zone_icon}"
  566.     id: zone_04_str
  567.   - platform: template
  568.     name: "Zone05 State"
  569.     icon: "${zone_icon}"
  570.     id: zone_05_str
  571.   - platform: template
  572.     name: "Zone06 State"
  573.     icon: "${zone_icon}"
  574.     id: zone_06_str
  575.   - platform: template
  576.     name: "Zone07 State"
  577.     icon: "${zone_icon}"
  578.     id: zone_07_str
  579.   - platform: template
  580.     name: "Zone08 State"
  581.     icon: "${zone_icon}"
  582.     id: zone_08_str
  583.  
  584.  
  585. binary_sensor:
  586.   - platform: gpio
  587.     id: sw_lights_enable
  588.     name: Lights Enable
  589.     pin:
  590.       number: GPIO13
  591.     internal: true
  592.     on_state:
  593.       if:
  594.         condition:
  595.           binary_sensor.is_on: sw_lights_enable
  596.         then:
  597.          # Publish Current Zone States to force up date of effect
  598.           - lambda: |-
  599.               id(zone_01_int).publish_state(id(zone_01_int).state);
  600.               id(zone_02_int).publish_state(id(zone_02_int).state);
  601.               id(zone_03_int).publish_state(id(zone_03_int).state);
  602.               id(zone_04_int).publish_state(id(zone_04_int).state);
  603.               id(zone_05_int).publish_state(id(zone_05_int).state);
  604.               id(zone_06_int).publish_state(id(zone_06_int).state);
  605.               id(zone_07_int).publish_state(id(zone_07_int).state);
  606.               id(zone_08_int).publish_state(id(zone_08_int).state);
  607.               id(flow_switch_01).publish_state(id(flow_switch_01).state);
  608.               id(flow_switch_02).publish_state(id(flow_switch_02).state);
  609.         else:
  610.           - light.turn_off: led_01
  611.           - light.turn_off: led_02
  612.           - light.turn_off: led_03
  613.           - light.turn_off: led_04
  614.           - light.turn_off: led_05
  615.           - light.turn_off: led_06
  616.           - light.turn_off: led_07
  617.           - light.turn_off: led_08
  618.           - light.turn_off: led_09
  619.           - light.turn_off: led_10
  620.   - platform: gpio
  621.     id: flow_switch_01
  622.     name: Flow Switch 1
  623.     filters:
  624.      invert
  625.     pin:
  626.       number: GPIO16
  627.     on_press:
  628.       if:
  629.         condition:
  630.           binary_sensor.is_on: sw_lights_enable
  631.         then:
  632.           - lambda: |-
  633.               auto call = id(led_09).turn_on();
  634.               call.set_effect("${led_effect2}");
  635.               call.perform();
  636.     on_release:
  637.       - light.turn_off: led_09
  638.    
  639.   - platform: gpio
  640.     id: flow_switch_02
  641.     name: Flow Switch 2
  642.     filters:
  643.      invert
  644.     pin:
  645.       number: GPIO12
  646.     on_press:
  647.       if:
  648.         condition:
  649.           binary_sensor.is_on: sw_lights_enable
  650.         then:
  651.           - lambda: |-
  652.               auto call = id(led_10).turn_on();
  653.               call.set_effect("${led_effect2}");
  654.               call.perform();
  655.     on_release:
  656.       - light.turn_off: led_10
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement