Advertisement
Guest User

Untitled

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