ff-akwarium-plug-01.yaml 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. substitutions:
  2. devicename: ff-akwarium-plug-01
  3. low_devicename: ff_akwarium_plug_01
  4. friendly_devicename: FF Akwarium Light 01
  5. memory_delay: 15s
  6. relay_delay: 40ms
  7. esphome:
  8. name: $devicename
  9. friendly_name: $friendly_devicename
  10. platformio_options:
  11. lib_ignore:
  12. - RPAsyncTCP
  13. on_boot:
  14. then:
  15. - light.turn_on:
  16. id: blue_led
  17. effect: strobe
  18. bk72xx:
  19. board: generic-bk7231t-qfn32-tuya
  20. #framework:
  21. # version: dev
  22. packages:
  23. # Enable Home Assistant API
  24. esphome: !include common/keys.yaml
  25. diag: !include common/diag.yaml
  26. # Enable logging
  27. logger:
  28. web_server:
  29. port: 80
  30. wifi:
  31. ssid: !secret iot_ssid
  32. password: !secret iot_password
  33. domain: .int.mmax.cloud
  34. binary_sensor:
  35. - platform: gpio
  36. pin:
  37. number: P7
  38. inverted: true
  39. mode:
  40. input: true
  41. pullup: true
  42. name: "Power Button"
  43. on_press:
  44. - switch.toggle: relay
  45. - light.turn_on:
  46. id: blue_led
  47. effect: strobe
  48. # - select.next:
  49. # id: light_mode
  50. # cycle: true
  51. light:
  52. - platform: binary
  53. name: Red LED
  54. id: red_led
  55. output: led_1
  56. internal: True
  57. restore_mode: ALWAYS_OFF
  58. - platform: binary
  59. name: Red LED
  60. id: blue_led
  61. output: led_2
  62. effects:
  63. - strobe:
  64. # transition_length: 50ms
  65. # update_interval: 50ms
  66. output:
  67. - platform: gpio
  68. # RED
  69. id: led_1
  70. pin:
  71. number: P6
  72. inverted: false
  73. - platform: gpio
  74. # BLUE
  75. id: led_2
  76. pin:
  77. number: P26
  78. inverted: false
  79. globals:
  80. - id: current_light
  81. type: int
  82. initial_value: "0"
  83. select:
  84. - platform: template
  85. name: "Light Mode"
  86. id: light_mode
  87. options:
  88. - "Off"
  89. - "Day"
  90. - "Daybreak"
  91. - "Night"
  92. optimistic: true
  93. on_value:
  94. then:
  95. - if:
  96. condition:
  97. - lambda: |-
  98. return(id(light_mode).state) == "Off";
  99. then:
  100. - light.turn_off: red_led
  101. - light.turn_off: blue_led
  102. - switch.turn_off: relay
  103. - if:
  104. condition:
  105. - lambda: |-
  106. return(id(light_mode).state) == "Day";
  107. then:
  108. - light.turn_off: blue_led
  109. - light.turn_on: red_led
  110. - switch.turn_off: relay
  111. - light.turn_on: red_led
  112. - delay: $memory_delay
  113. - switch.turn_on: relay
  114. - if:
  115. condition:
  116. - lambda: |-
  117. return(id(light_mode).state) == "Daybreak";
  118. then:
  119. - light.turn_off: blue_led
  120. - light.turn_on: red_led
  121. - switch.turn_off: relay
  122. - light.turn_on: red_led
  123. - delay: $memory_delay
  124. - switch.turn_on: relay
  125. - delay: $relay_delay
  126. - switch.turn_off: relay
  127. - delay: $relay_delay
  128. - switch.turn_on: relay
  129. - if:
  130. condition:
  131. - lambda: |-
  132. return(id(light_mode).state) == "Night";
  133. then:
  134. - light.turn_off: blue_led
  135. - light.turn_on: red_led
  136. - switch.turn_off: relay
  137. - light.turn_on: red_led
  138. - delay: $memory_delay
  139. - switch.turn_on: relay
  140. - delay: $relay_delay
  141. - switch.turn_off: relay
  142. - delay: $relay_delay
  143. - switch.turn_on: relay
  144. - delay: $relay_delay
  145. - switch.turn_off: relay
  146. - delay: $relay_delay
  147. - switch.turn_on: relay
  148. - lambda: |-
  149. id(current_light) == id(light_mode).active_index();
  150. switch:
  151. - platform: gpio
  152. pin: P8
  153. id: relay
  154. internal: true
  155. restore_mode: ALWAYS_OFF
  156. # Turn off red LED to show blue when turned on
  157. on_turn_on:
  158. - light.turn_on: red_led
  159. # # - switch.turn_off: led_1
  160. # # Turns on the red LED once the plug is turned off
  161. on_turn_off:
  162. - light.turn_off: red_led
  163. # # - switch.turn_on: led_1
  164. # - platform: template
  165. # name: mode
  166. # output: relay
  167. # internal: True
  168. # effects:
  169. # - lambda:
  170. # name: Day
  171. # - lambda:
  172. # name: Daybreak
  173. # - lambda:
  174. # name: Night