TuXaMaT

vinderhruting

Feb 29th, 2024 (edited)
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.31 KB | None | 0 0
  1. esphome:
  2. name: vindriktning
  3. friendly_name: Vindriktning
  4. on_boot:
  5. priority: 600.0
  6. then:
  7. - light.turn_on:
  8. id: ikea_light
  9. effect: "Effect1"
  10. red: 0%
  11. green: 0%
  12. blue: 100%
  13.  
  14. esp32:
  15. board: esp32dev
  16. framework:
  17. type: arduino
  18.  
  19. logger:
  20. baud_rate: 0
  21. # Enable Home Assistant API
  22. api:
  23. encryption:
  24. key: "Rh+s/Wj6EN61vecPYib5qnFwb7qnBiYC6Z4Ru2kVuS0="
  25.  
  26. ota:
  27. password: "ee51b15d8570c640dfc67e6a00675e90"
  28.  
  29. wifi:
  30. ssid: !secret wifi_ssid
  31. password: !secret wifi_password
  32.  
  33. # Enable fallback hotspot (captive portal) in case wifi connection fails
  34. ap:
  35. ssid: "Vindriktning Fallback Hotspot"
  36. password: "MvF9FCTn6aI6"
  37. on_connect:
  38. - light.turn_off: ikea_light
  39. on_disconnect:
  40. - light.turn_on:
  41. id: ikea_light
  42. effect: "Effect1"
  43. red: 0%
  44. green: 0%
  45. blue: 100%
  46.  
  47. captive_portal:
  48. web_server:
  49. port: 80
  50. time: # Время берем из Home Assistant
  51. - platform: homeassistant
  52. id: homeassistant_time
  53.  
  54.  
  55. switch:
  56. - platform: restart # Переключатель перезагрузки устройства
  57. name: "Restart_Ikea"
  58.  
  59. i2c:
  60. sda: 21
  61. scl: 22
  62. scan: true
  63. id: bus_a
  64.  
  65. uart:
  66. rx_pin: GPIO26
  67. baud_rate: 9600
  68. # id: uart_rx
  69. # debug:
  70. # direction: RX
  71. # dummy_receiver: true
  72. # after:
  73. # delimiter: "\r\n"
  74. # sequence:
  75. # - lambda: |-
  76. # UARTDebug::log_string(direction, bytes); //Still log the data
  77. # uint8_t checksum = 0;
  78. # for (int i=0; i < bytes.size(); i++) {
  79. # checksum+= bytes[i];
  80. # }
  81. # if (checksum==0){
  82. # ESP_LOGD("UART","PM1006|PM1006k checksum validated, have %d", checksum);
  83. # if (bytes.size()==20 and (bytes[0]==22 and bytes[1]==17 and bytes[2]==11)) {
  84. # ESP_LOGD("UART", "Correct PM1006 response recieved. Updating sensors");
  85. # id(ikea_pm2).publish_state(bytes[5]*256+bytes[6]);
  86. # id(ikea_pm1).publish_state(bytes[9]*256+bytes[10]);
  87. # id(ikea_pm10).publish_state(bytes[13]*256+bytes[14]);
  88. # }
  89. # if (bytes.size()==16 and (bytes[0]==22 and bytes[1]==13 and bytes[2]==2)) {
  90. # ESP_LOGD("UART", "Correct PM1006K response recieved. Updating sensors");
  91. # id(ikea_pm2).publish_state(bytes[5]*256+bytes[6]);
  92. # id(ikea_pm1).publish_state(bytes[9]*256+bytes[10]);
  93. # id(ikea_pm10).publish_state(bytes[13]*256+bytes[14]);
  94. # }
  95. # }
  96. # else{
  97. # ESP_LOGW("UART","PM1006|PM1006k checksum is wrong: %02x, expected zero. Sensors will not be updated", checksum);
  98. # }
  99.  
  100. light:
  101. - platform: neopixelbus
  102. type: GRB
  103. variant: WS2812
  104. pin: GPIO14
  105. num_leds: 7
  106. name: "ikea_color"
  107. id: "ikea_light"
  108. internal: true
  109. effects:
  110. - pulse:
  111. name: "Effect1"
  112. transition_length: 0.5s
  113. update_interval: 0.5s
  114. min_brightness: 10%
  115. max_brightness: 60%
  116. - platform: partition
  117. name: "ikea_partition1"
  118. id: "ikea_light1"
  119. internal: true
  120. segments:
  121. # Use first 3 LEDs from the light with ID light1
  122. - id: ikea_light
  123. from: 0
  124. to: 2
  125. - platform: partition
  126. name: "ikea_partition2"
  127. id: "ikea_light2"
  128. internal: true
  129. segments:
  130. # Use LEDs 3-6 from the light with ID light1
  131. - id: ikea_light
  132. from: 3
  133. to: 6
  134. effects:
  135. - pulse:
  136. name: "Effect3"
  137. transition_length: 1s
  138. update_interval: 1s
  139. min_brightness: 20%
  140. max_brightness: 50%
  141.  
  142.  
  143. sensor:
  144. - platform: pm1006
  145. pm_2_5:
  146. name: "IKEA-BD 2.5µm Concentration"
  147. id: ikea_pm_2
  148.  
  149. # - platform: template
  150. # name: "Ikea PM25"
  151. # icon: "mdi:blur"
  152. # id: "ikea_pm2"
  153. # device_class: PM25
  154. # accuracy_decimals: 0
  155. # unit_of_measurement: µg/m³
  156.  
  157. # - platform: template
  158. # name: "Ikea PM10 "
  159. # icon: "mdi:blur"
  160. # id: "ikea_pm10"
  161. # device_class: PM10
  162. # accuracy_decimals: 0
  163. # unit_of_measurement: µg/m³
  164. - platform: uptime
  165. name: "Uptime_Ikea"
  166.  
  167. #### scd41 CO2
  168. - platform: scd4x
  169. automatic_self_calibration: false
  170. temperature_offset: 4
  171. id: "ikea_scd41"
  172. co2:
  173. name: "Ikea CO2"
  174. id: "ikea_co2"
  175. temperature:
  176. name: "Ikea CO2 Temperature"
  177. accuracy_decimals: 1
  178. humidity:
  179. name: "Ikea CO2 Humidity"
  180. accuracy_decimals: 0
  181.  
  182. #### bme280
  183. - platform: bme280_i2c
  184. temperature:
  185. name: "Ikea Temperature"
  186. oversampling: 16x
  187. pressure:
  188. name: "Ikea Pressure"
  189. humidity:
  190. name: "Ikea Humidity"
  191. address: 0x76
  192. update_interval: 60s
  193.  
  194. #### LD2410
  195. # ld2410:
  196. # uart_id: uart_0
  197.  
  198. binary_sensor:
  199. - platform: gpio
  200. pin: 5
  201. name: IKEA-BD Presence
  202. device_class: presence
  203. # - platform: ld2410
  204. # has_target:
  205. # name: "presence_IKEA"
  206. # has_moving_target:
  207. # name: "moving_target_IKEA"
  208. # has_still_target:
  209. # name: "still_target_IKEA"
  210. #number:
  211.  
  212. # - platform: ld2410
  213. # timeout:
  214. # name: timeout_IKEA
  215. # internal : false
  216. # light_threshold:
  217. # name: light_threshold_IKEA
  218. # internal : false
  219. # max_move_distance_gate:
  220. # name: max_move_distance_gate_IKEA
  221. # internal : false
  222. # max_still_distance_gate:
  223. # name: max_still_distance_gate_IKEA
  224. # internal : false
  225.  
  226. #select:
  227. # - platform: ld2410
  228. # distance_resolution:
  229. # name: "distance_resolution_IKEA"
  230. # internal : false
  231. # baud_rate:
  232. # name: "baud rate_IKEA"
  233. # internal : false
  234. # light_function:
  235. # name: light_function_IKEA
  236. # internal : false
  237. # out_pin_level:
  238. # name: out_pin_level_IKEA
  239. # internal : false
  240.  
  241. button:
  242. # - platform: ld2410
  243. # factory_reset:
  244. # name: "factory_reset_IKEA"
  245. # internal : false
  246. # restart:
  247. # name: "restart_IKEA"
  248. # internal : false
  249. # query_params:
  250. # name: query_params_IKEA
  251. # internal : false
  252. - platform: safe_mode
  253. name: "IKEA-BD (Safe Mode)"
  254. - platform: restart
  255. name: "IKEA-BD Restart"
  256.  
  257. interval:
  258. - interval: 60s
  259. then:
  260. - if:
  261. condition:
  262. sensor.in_range:
  263. id: ikea_co2
  264. above: 0
  265. below: 800
  266. then:
  267. - light.turn_on:
  268. id: ikea_light2
  269. red: 0%
  270. green: 100%
  271. blue: 0%
  272. brightness: 20%
  273. effect: None
  274. color_mode: RGB
  275. - if:
  276. condition:
  277. sensor.in_range:
  278. id: ikea_co2
  279. above: 800
  280. below: 1000
  281. then:
  282. - light.turn_on:
  283. id: ikea_light2
  284. red: 98%
  285. green: 78%
  286. blue: 47%
  287. brightness: 20%
  288. effect: None
  289. color_mode: RGB
  290. - if:
  291. condition:
  292. sensor.in_range:
  293. id: ikea_co2
  294. above: 1000
  295. below: 1500
  296. then:
  297. - light.turn_on:
  298. id: ikea_light2
  299. red: 100%
  300. green: 0%
  301. blue: 0%
  302. brightness: 20%
  303. effect: None
  304. color_mode: RGB
  305. - if:
  306. condition:
  307. sensor.in_range:
  308. id: ikea_co2
  309. above: 1500
  310. then:
  311. - light.turn_on:
  312. id: ikea_light2
  313. effect: "Effect3"
  314. red: 100%
  315. green: 0%
  316. blue: 0%
  317. - if:
  318. condition:
  319. sensor.in_range:
  320. id: ikea_pm_2
  321. above: 0
  322. below: 35
  323. then:
  324. - light.turn_on:
  325. id: ikea_light1
  326. red: 0%
  327. green: 100%
  328. blue: 0%
  329. brightness: 20%
  330. effect: None
  331. - if:
  332. condition:
  333. sensor.in_range:
  334. id: ikea_pm_2
  335. above: 0
  336. below: 35
  337. then:
  338. - light.turn_on:
  339. id: ikea_light1
  340. red: 0%
  341. green: 100%
  342. blue: 0%
  343. brightness: 20%
  344. effect: None
  345. - if:
  346. condition:
  347. sensor.in_range:
  348. id: ikea_pm_2
  349. above: 35
  350. below: 85
  351. then:
  352. - light.turn_on:
  353. id: ikea_light1
  354. red: 98%
  355. green: 78%
  356. blue: 47%
  357. brightness: 20%
  358. effect: None
  359. - if:
  360. condition:
  361. sensor.in_range:
  362. id: ikea_pm_2
  363. above: 85
  364. then:
  365. - light.turn_on:
  366. id: ikea_light1
  367. red: 100%
  368. green: 0%
  369. blue: 0%
  370. brightness: 20%
  371. effect: None
Advertisement
Add Comment
Please, Sign In to add comment