Advertisement
Minecz

ESPHOME-Thermostat

May 27th, 2023
10
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.87 KB | None | 0 0
  1. esphome:
  2. name: chalupa-thermostat
  3. friendly_name: Chalupa_Thermostat
  4.  
  5. esp8266:
  6. board: esp07
  7.  
  8. # Enable logging
  9. logger:
  10. level: Verbose
  11. # Enable Home Assistant API
  12. api:
  13. encryption:
  14. key: "nanya"
  15.  
  16. ota:
  17. password: "busyness"
  18.  
  19. wifi:
  20. networks:
  21. - ssid: !secret wifi_home_out
  22. password: !secret wifi_home_pass
  23. priority: 2
  24. - ssid: !secret wifi_ssid
  25. password: !secret wifi_password
  26. priority: 5
  27. - ssid: !secret wifi_chalupa_cam
  28. password: !secret wifi_chalupa_pass
  29. priority: 4
  30. - ssid: !secret wifi_chalupa_main
  31. password: !secret wifi_chalupa_pass
  32. priority: 3
  33. - ssid: !secret wifi_home_main
  34. password: !secret wifi_home_pass
  35. priority: 1
  36.  
  37. i2c:
  38. sda: GPIO4
  39. scl: GPIO5
  40. frequency: 100kHz
  41.  
  42. font:
  43. - file: "fonts/Roboto-Regular.ttf"
  44. id: my_font20
  45. size: 20
  46. - file: "fonts/Roboto-Regular.ttf"
  47. id: my_font10
  48. size: 11
  49. - file: "fonts/Roboto-Regular.ttf"
  50. id: my_font5
  51. size: 5
  52. - file: "fonts/FreeSans-LrmZ.ttf"
  53. id: sans10
  54. size: 11
  55. # gfonts://family[@weight]
  56. - file: "gfonts://Roboto Mono"
  57. id: Google10
  58. size: 11
  59. - file: "fonts/FreeSansBold-Rdmo.ttf"
  60. id: sansB10
  61. size: 10
  62. - file: "fonts/eight-bit-dragon.ttf"
  63. id: eightbit10
  64. size: 10
  65.  
  66.  
  67. globals:
  68. - id: HATemp
  69. type: float
  70. restore_value: no
  71. initial_value: '10'
  72.  
  73. - id: DispTemp
  74. type: float
  75. restore_value: yes
  76. initial_value: '10'
  77.  
  78. sensor:
  79. - platform: wifi_signal # Reports the WiFi signal strength/RSSI in dB
  80. name: "WiFi Signal dB"
  81. id: wifi_signal_db
  82. update_interval: 10s
  83. entity_category: "diagnostic"
  84.  
  85. - platform: copy # Reports the WiFi signal strength in %
  86. source_id: wifi_signal_db
  87. name: "WiFi Signal Percent"
  88. filters:
  89. - lambda: return min(max(2 * (x + 100.0), 0.0), 100.0);
  90. unit_of_measurement: "Signal %"
  91. entity_category: "diagnostic"
  92.  
  93. - platform: homeassistant
  94. name: "RequestedTemp"
  95. id: ReqTemp
  96. entity_id: input_number.chalupa_temperature
  97. on_value:
  98. then:
  99. - lambda: |-
  100. id(HATemp) = id(ReqTemp).state;
  101. id(DispTemp) = id(ReqTemp).state;
  102.  
  103.  
  104. - platform: aht10
  105. temperature:
  106. name: "Chalupa Temperature"
  107. id: TempCurrent
  108. humidity:
  109. name: "Chalupa Humidity"
  110. id: HumCurrent
  111. update_interval: 10s
  112.  
  113. - platform: rotary_encoder
  114. name: "Rotary Encoder"
  115. pin_a: GPIO13
  116. pin_b: GPIO14
  117. restore_mode: ALWAYS_ZERO
  118. internal: True
  119. on_clockwise:
  120. then:
  121. - lambda: |-
  122. float newDispTemp = id(DispTemp) + 0.25;
  123. if (newDispTemp > 35) {
  124. newDispTemp = 35;
  125. }
  126. id(DispTemp) = newDispTemp;
  127. on_anticlockwise:
  128. then:
  129. - lambda: |-
  130. float newDispTemp = id(DispTemp) - 0.25;
  131. if (newDispTemp < 10) {
  132. newDispTemp = 10;
  133. }
  134. id(DispTemp) = newDispTemp;
  135.  
  136. - platform: adc
  137. pin: A0
  138. name: "Battery Voltage"
  139. id: VBat
  140. #internal: True
  141. accuracy_decimals: 4
  142. update_interval: 10s
  143. filters:
  144. - multiply: 5.75
  145.  
  146. - platform: template
  147. name: "Battery Percentage"
  148. id: BatPerc
  149. unit_of_measurement: "%"
  150. device_class: BATTERY
  151. update_interval: 5s
  152. lambda: |-
  153. float voltage = id(VBat).state;
  154. float batteryPercentage = 0.0;
  155.  
  156. if (voltage >= 4.2) {
  157. batteryPercentage = 100.0;
  158. } else if (voltage <= 3.21) {
  159. batteryPercentage = 0.0;
  160. } else {
  161. batteryPercentage = (voltage - 3.21) / (4.2 - 3.21) * 100.0;
  162. }
  163.  
  164. return batteryPercentage;
  165.  
  166.  
  167.  
  168.  
  169. text_sensor:
  170. - platform: wifi_info
  171. ip_address:
  172. name: ESP IP Address
  173. ssid:
  174. name: ESP Connected SSID
  175. bssid:
  176. name: ESP Connected BSSID
  177. mac_address:
  178. name: ESP Mac Wifi Address
  179. scan_results:
  180. name: ESP Latest Scan Results
  181.  
  182. binary_sensor:
  183. - platform: gpio
  184. pin:
  185. number: GPIO12
  186. mode: INPUT
  187. inverted: True
  188. id: buttonenc
  189. name: "ButtonEncoder"
  190. internal: True
  191. on_press:
  192. then:
  193. - homeassistant.service:
  194. service: input_number.set_value
  195. data:
  196. entity_id: input_number.chalupa_temperature
  197. value: id(DispTemp).state
  198.  
  199. - lambda: |-
  200. ESP_LOGI("ButtonEncoder", "Sending to HASS");
  201.  
  202. - platform: gpio
  203. pin:
  204. number: GPIO2
  205. mode: INPUT
  206. inverted: True
  207. id: buttonhome
  208. name: "ButtonHome"
  209. internal: True
  210. on_press:
  211. then:
  212.  
  213. - lambda: |-
  214. id(DispTemp) = id(HATemp);
  215. ESP_LOGI("ButtonHome", "Resetting value");
  216.  
  217.  
  218.  
  219.  
  220.  
  221. - platform: template
  222. id: ChStat
  223. name: "Charging Status"
  224. lambda: |-
  225. auto voltage = id(VBat).state;
  226. bool isCharging = (voltage > 4.35);
  227.  
  228. return isCharging;
  229.  
  230.  
  231.  
  232.  
  233. time:
  234. - platform: homeassistant
  235. id: esptime
  236.  
  237. display:
  238. - platform: ssd1306_i2c
  239. model: "SH1106 128x64"
  240. address: 0x3C
  241. lambda: |-
  242. it.strftime(0, 00, id(eightbit10), "%a %d.%m %H:%M:%S", id(esptime).now());
  243.  
  244. if (id(ChStat).state) {
  245. it.print(108, 0, id(eightbit10), "Chg");
  246. } else {
  247. it.printf(108, 0, id(eightbit10), "%.0f%%", id(BatPerc).state);
  248. }
  249.  
  250. it.line(0, 10, 127, 10);
  251.  
  252. it.print(0, 12, id(eightbit10), "Aktualni:");
  253.  
  254. if (id(TempCurrent).has_state()) {
  255. it.printf(0, 20, id(my_font20),"%.1f°C %.1f%%", id(TempCurrent).state, id(HumCurrent).state);
  256. }
  257.  
  258. if (id(DispTemp) != id(HATemp)) {
  259. it.printf(0, 40, id(my_font20), "Set: %.2f°C E", id(DispTemp));
  260. } else {
  261. it.printf(0, 40, id(my_font20), "Set: %.2f°C", id(DispTemp));
  262. }
  263.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement