ff-akwarium-plug-01.yaml 3.4 KB

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