Advertisement
jazzmonger

Untitled

May 14th, 2023
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.37 KB | None | 0 0
  1. substitutions:
  2. friendly_name: "Solar Batt Heat Controller"
  3.  
  4. esphome:
  5. name: "solar-battery-heat-controller"
  6. platformio_options:
  7. #upload_speed: 115200
  8. # #REQUIRED FOR UART TO WORK
  9. board_build.extra_flags:
  10. - "-DARDUINO_USB_CDC_ON_BOOT=0" # Override, defaults to '-DARDUINO_USB_CDC_ON_BOOT=1'
  11.  
  12. # external_components:
  13. # - source: github://ssieb/esphome@dallas
  14. # components: [ dallas ]
  15. # refresh: 1min
  16.  
  17. external_components:
  18. - source: github://nrandell/dallasng
  19.  
  20. esp32:
  21. board: featheresp32-s2
  22.  
  23. # pid climate log update is noisy, dial it back to warn
  24. logger:
  25. hardware_uart: uart0
  26. level: DEBUG
  27. logs:
  28. climate: ERROR
  29. dht: WARN
  30.  
  31.  
  32. uart:
  33. - id: debug_uart
  34. rx_pin: 3
  35. tx_pin: 1
  36. baud_rate: 115200
  37.  
  38. debug:
  39. update_interval: 10s
  40. text_sensor:
  41. - platform: debug
  42. device:
  43. name: "Device Info"
  44. reset_reason:
  45. name: "Reset Reason"
  46.  
  47. api:
  48.  
  49. ota:
  50.  
  51. # dallas:
  52. # - pin: 9
  53. # update_interval: 1s
  54. dallasng:
  55. - pin: GPIO9
  56. update_interval: 3s
  57.  
  58. output:
  59. - platform: ac_dimmer
  60. id: dimmer
  61. gate_pin: GPIO18
  62. zero_cross_pin:
  63. number: GPIO39
  64. mode: INPUT_PULLUP
  65. method: leading pulse
  66. init_with_half_cycle: true
  67. web_server:
  68. port: 80
  69.  
  70. wifi:
  71. #use_address: 192.168.1.111
  72. ssid: !secret wifi_ssid
  73. password: !secret wifi_password
  74.  
  75. # Enable fallback hotspot (captive portal) in case wifi connection fails
  76. ap:
  77. ssid: "$friendly_name"
  78. password: "wifipassword"
  79.  
  80. captive_portal:
  81.  
  82. button:
  83. - platform: restart #allows remote reset of tywe1s chip from home assistant or internally
  84. id: restart_esp
  85. name: "$friendly_name Restart"
  86. - platform: safe_mode # required to upload firmware if were low on memory. put chip in safe mode, reboot, then OTA upload new firmware.
  87. name: "$friendly_name SAFE Mode BUTTON"#
  88.  
  89. sensor:
  90. - platform: dallasng
  91. id: battery_probe
  92. name: "Solar-Batt Probe Temp"
  93. index: 0
  94. resolution: 12
  95. filters:
  96. - filter_out: NAN
  97.  
  98. - platform: uptime
  99. internal: false
  100. name: ${friendly_name} Uptime
  101. id: uptime_s
  102. update_interval: 10s
  103.  
  104. - platform: wifi_signal
  105. name: "$friendly_name WiFi Signal"
  106. update_interval: 10s
  107. id: wifi_signal_db
  108. - platform: copy # Reports the WiFi signal strength in %
  109. source_id: wifi_signal_db
  110. name: "$friendly_name WiFi Signal %"
  111. filters:
  112. - lambda: return min(max(2 * (x + 100.0), 0.0), 100.0);
  113. unit_of_measurement: "%"
  114. entity_category: "diagnostic"
  115. - platform: template
  116.  
  117. #Pick the batt temp thats availble, HA BMS first otherwise the batt probe here in the ESP32
  118. name: $friendly_name Valid Battery Temp
  119. id: valid_temp
  120. unit_of_measurement: "°C"
  121. lambda: |-
  122. if (global_api_server->is_connected())
  123. {
  124. return id(bms_battery_temperature).state;
  125. } else {
  126. return id(battery_probe).state;
  127. }
  128.  
  129. # GET TEMP FROM INVERTER in home assistant
  130. - platform: homeassistant
  131. entity_id: sensor.battery_temperature
  132. name: "BMS inverter temp "
  133. id: bms_battery_temperature
  134. # If you don't smooth the output readings
  135. # the PID controller over reacts to small changes.
  136. filters:
  137. #- lambda: return x * (9.0/5.0) + 32.0; # c to f
  138. - lambda: return (x - 32.0) * (5.0/9.0); //f to c, its coming in as F (x°F − 32) × 5/9
  139. # - exponential_moving_average:
  140. # alpha: 0.1
  141. # send_every: 1
  142.  
  143. # - platform: dallas
  144. # address: 0x0a01204e86cdca28
  145. # name: "Solar-Batt Probe Temp"
  146. # id: battery_probe
  147. # filters:
  148. # - exponential_moving_average:
  149. # alpha: 0.1
  150. # send_every: 1
  151. # - filter_out: nan
  152. # #get rid of the noise from the sensor
  153. # - sliding_window_moving_average:
  154. # window_size: 3
  155. # send_every: 1
  156.  
  157. - platform: template
  158. name: $friendly_name p term
  159. id: p_term
  160. unit_of_measurement: "%"
  161. accuracy_decimals: 2
  162.  
  163. - platform: template
  164. name: $friendly_name i term
  165. id: i_term
  166. unit_of_measurement: "%"
  167. accuracy_decimals: 2
  168.  
  169. - platform: template
  170. name: $friendly_name d term
  171. id: d_term
  172. unit_of_measurement: "%"
  173. accuracy_decimals: 2
  174.  
  175. - platform: template
  176. name: $friendly_name output value
  177. unit_of_measurement: "%"
  178. id: o_term
  179. accuracy_decimals: 2
  180.  
  181. - platform: template
  182. name: $friendly_name error value
  183. id: e_term
  184. accuracy_decimals: 2
  185.  
  186. - platform: pid
  187. name: "$friendly_name Heater level (PWM Voltage)"
  188. climate_id: console_thermostat
  189. type: HEAT
  190.  
  191. ########################################################
  192. # START THE HEATER CONTROLLER SETUP
  193. ########################################################
  194. number:
  195. ## RECEIVE kp,ki and kd parameters from input_text.kx helpers in
  196. # Home Assistant. See the PID controller below
  197. # These helper values will get saved to flash thus permanently over-riding
  198. # the initial values set in the PID below.
  199.  
  200. # KP
  201. - platform: template
  202. name: $friendly_name kp
  203. icon: mdi:chart-bell-curve
  204. restore_value: true
  205. min_value: 0
  206. max_value: 50
  207. step: 0.001
  208. set_action:
  209. lambda: |-
  210. // ESP_LOGI("main", "!!!!!! kp from boot %d", id("console_fan_kp") );
  211. // id(console_thermostat).set_kp( id("$friendly_name kp") );
  212. id(console_thermostat).set_kp( x );
  213. # KI
  214. - platform: template
  215. name: $friendly_name ki
  216. icon: mdi:chart-bell-curve
  217. restore_value: true
  218. min_value: 0
  219. max_value: 50
  220. step: 0.0001
  221. set_action:
  222. lambda: id(console_thermostat).set_ki( x );
  223.  
  224. # KD
  225. - platform: template
  226. name: $friendly_name kd
  227. icon: mdi:chart-bell-curve
  228. restore_value: true
  229. min_value: -50
  230. max_value: 50
  231. step: 0.001
  232. set_action:
  233. lambda: id(console_thermostat).set_kd( x );
  234.  
  235.  
  236. # Expose a PID-controlled Thermostat
  237. # Manual: https://esphome.io/components/climate/pid.html
  238. climate:
  239. - platform: pid
  240. name: "$friendly_name Thermostat"
  241. id: console_thermostat
  242. #sensor: battery_probe
  243. sensor: valid_temp #Pick the one thats availble
  244. # LiFePo4 optimal temp
  245. default_target_temperature: 18.3C
  246. heat_output: dimmer
  247. deadband_parameters:
  248. threshold_high: 1.0°C
  249. threshold_low: -1.5°C
  250. visual:
  251. min_temperature: 10 °C
  252. max_temperature: 40 °C
  253. on_state:
  254. - sensor.template.publish:
  255. id: p_term
  256. state: !lambda 'return -id(console_thermostat).get_proportional_term() * 100.0;'
  257. - sensor.template.publish:
  258. id: i_term
  259. state: !lambda 'return -id(console_thermostat).get_integral_term()* 100.0;'
  260. - sensor.template.publish:
  261. id: d_term
  262. state: !lambda 'return -id(console_thermostat).get_derivative_term()* 100.0;'
  263. - sensor.template.publish:
  264. id: o_term
  265. state: !lambda 'return -id(console_thermostat).get_output_value()* 100.0;'
  266. - sensor.template.publish:
  267. id: e_term
  268. state: !lambda 'return -id(console_thermostat).get_error_value();'
  269.  
  270. # See the README for setting up these parameters.
  271. # These are over ridden by the number templates above.
  272. control_parameters:
  273. kp: 0.32
  274. ki: 0.0009
  275. kd: 0.0
  276. max_integral: 0.0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement