Advertisement
Guest User

Untitled

a guest
May 24th, 2025
259
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.85 KB | None | 0 0
  1. substitutions:
  2. devicename: chickendoorsmartl298n
  3. upper_devicename: ChickenDoorSmartL298N
  4. deviceIP: 192.168.178.38
  5. deviceGatew: 192.168.178.1
  6. deviceSub: 255.255.255.0
  7. deviceSSID1: 7390_iot
  8. deviceSSID2: 7390AP
  9.  
  10. esphome:
  11. name: ${devicename}
  12. comment: ${upper_devicename}
  13.  
  14. esp8266:
  15. board: d1_mini
  16.  
  17. # Disable logging over UART (required)
  18. logger:
  19. baud_rate: 0
  20.  
  21. # Enable Home Assistant API
  22. api:
  23. encryption:
  24. key: "NEL+xxx+J28sctHwGNhgyEA="
  25.  
  26. ota:
  27. - platform: esphome
  28. password: "xxx"
  29.  
  30. wifi:
  31. networks:
  32. - ssid: ${deviceSSID1}
  33. password: !secret wifi_password
  34. manual_ip:
  35. # Set this to the IP of the ESP
  36. static_ip: ${deviceIP}
  37. # Set this to the IP address of the router. Often ends with .1
  38. gateway: ${deviceGatew}
  39. # The subnet of the network. 255.255.255.0 works for most home networks.
  40. subnet: ${deviceSub}
  41. - ssid: ${deviceSSID2}
  42. password: !secret wifi_password
  43. manual_ip:
  44. # Set this to the IP of the ESP
  45. static_ip: ${deviceIP}
  46. # Set this to the IP address of the router. Often ends with .1
  47. gateway: ${deviceGatew}
  48. # The subnet of the network. 255.255.255.0 works for most home networks.
  49. subnet: ${deviceSub}
  50.  
  51. # Enable fallback hotspot (captive portal) in case wifi connection fails
  52. ap:
  53. ssid: "${upper_devicename} Fallback"
  54. password: "xxx"
  55.  
  56. captive_portal:
  57.  
  58. # Enable Web server.
  59. web_server:
  60. port: 80
  61.  
  62. time:
  63. - platform: homeassistant
  64. id: homeassistant_time
  65.  
  66. # Text sensors with general information.
  67. text_sensor:
  68. # Expose ESPHome version as sensor.
  69. - platform: version
  70. name: ESPHome Version
  71. # Expose WiFi information as sensors.
  72. - platform: wifi_info
  73. ip_address:
  74. name: ${upper_devicename} IP
  75. mac_address:
  76. name: ${upper_devicename} MAC
  77. ssid:
  78. name: ${upper_devicename} SSID
  79. # Expose Sun rise/set information as sensors.
  80. - platform: sun
  81. name: Next Sunrise
  82. type: sunrise
  83. - platform: sun
  84. name: Next Sunset
  85. type: sunset
  86. # Expose Door opening/closing time information as sensors.
  87. - platform: sun
  88. name: Next Opening
  89. type: sunrise
  90. elevation: 0.8
  91. - platform: sun
  92. name: Next Closing
  93. type: sunset
  94. elevation: -6
  95.  
  96. # Sensors with general information.
  97. sensor:
  98. # Uptime sensor.
  99. - platform: uptime
  100. name: ${upper_devicename} Uptime
  101. filters:
  102. - lambda: return x / 60.0;
  103. unit_of_measurement: minutes
  104.  
  105. # WiFi Signal sensor.
  106. - platform: wifi_signal
  107. name: ${upper_devicename} WiFi Signal
  108. update_interval: 60s
  109.  
  110. # Expose Sun elevation information as sensors.
  111. - platform: sun
  112. name: Sun Elevation
  113. type: elevation
  114.  
  115. # Expose Sun location information as sensors.
  116. - platform: sun
  117. name: Sun Azimuth
  118. type: azimuth
  119.  
  120. binary_sensor: #D5 soldered in for future button use
  121. - platform: gpio
  122. pin:
  123. number: GPIO13
  124. mode:
  125. input: true
  126. pullup: true
  127. id: lsw1
  128. name: "Chicken Coop open"
  129. filters:
  130. - delayed_on: 10ms
  131. on_press:
  132. then:
  133. - button.press: button_stop
  134.  
  135. - platform: gpio
  136. pin:
  137. number: GPIO12
  138. mode:
  139. input: true
  140. pullup: true
  141. id: lsw2
  142. name: "Chicken Coop closed"
  143. filters:
  144. - delayed_on: 10ms
  145. on_press:
  146. then:
  147. - button.press: button_stop
  148.  
  149. switch:
  150. - platform: template
  151. id: disable_open_on_sunrise
  152. name: "Disable open on sunrise"
  153. optimistic: true
  154.  
  155. button:
  156. - platform: template
  157. id: button_on_sunset
  158. name: Close Door
  159. on_press:
  160. if:
  161. condition:
  162. binary_sensor.is_off: lsw2
  163. then:
  164. - fan.turn_on:
  165. id: chickendoormotor
  166. direction: REVERSE
  167. - delay: 20s
  168. - fan.turn_off: chickendoormotor
  169.  
  170. - platform: template
  171. id: button_on_sunrise
  172. name: Open Door
  173. on_press:
  174. if:
  175. condition:
  176. binary_sensor.is_off: lsw1
  177. then:
  178. - fan.turn_on:
  179. id: chickendoormotor
  180. direction: FORWARD
  181. - delay: 20s
  182. - fan.turn_off: chickendoormotor
  183.  
  184. - platform: template
  185. id: button_stop
  186. name: Stop Door
  187. on_press:
  188. - fan.turn_off: chickendoormotor
  189.  
  190. ## START Test for logic in esphome
  191. ##########################################################################################
  192. # Motor Control
  193. ##########################################################################################
  194. # Set home location information as sensors.
  195. sun:
  196. latitude: 21.0931
  197. longitude: -24.8054
  198.  
  199. on_sunrise:
  200. - elevation: 0.8°
  201. then:
  202. if:
  203. condition:
  204. switch.is_off: disable_open_on_sunrise
  205. then:
  206. - button.press: button_on_sunrise
  207. - delay: 2s
  208. - button.press: button_on_sunrise
  209. - delay: 2s
  210. - button.press: button_on_sunrise
  211.  
  212. on_sunset:
  213. - elevation: -6°
  214. then:
  215. - button.press: button_on_sunset
  216. - delay: 2s
  217. - button.press: button_on_sunset
  218. - delay: 2s
  219. - button.press: button_on_sunset
  220.  
  221. ##########################################################################################
  222. # End Stop
  223. ##########################################################################################
  224.  
  225. output:
  226. - platform: esp8266_pwm
  227. id: motor_forward_pin
  228. pin: GPIO4
  229. - platform: esp8266_pwm
  230. id: motor_reverse_pin
  231. pin: GPIO5
  232.  
  233. fan:
  234. - platform: hbridge
  235. id: chickendoormotor
  236. name: "Chicken Door Motor"
  237. pin_a: motor_forward_pin
  238. pin_b: motor_reverse_pin
  239. decay_mode: fast # slow decay mode (coasting) or fast decay (braking).
  240.  
  241.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement