Advertisement
jdobry

Untitled

Jul 7th, 2022
1,865
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 6.55 KB | None | 0 0
  1. substitutions:
  2.   device_name: air-quality
  3.  
  4. esphome:
  5.   name: ${device_name}
  6.   comment: IKEA LaskaKit ESP-VINDRIKTNING ESP-32 I2C
  7.   on_boot:
  8.       - light.turn_on:
  9.           id: status
  10.           brightness: 0%
  11.  
  12. esp32:
  13.   board: nodemcu-32s
  14.   framework:
  15.     type: arduino
  16.  
  17. wifi:
  18.   ssid: ${wifi_ssid}
  19.   password: ${wifi_password}
  20.   fast_connect: on
  21.  
  22.   manual_ip: #docasny workaround pro https://github.com/esphome/issues/issues/3003
  23.     static_ip: 192.168.62.19
  24.     gateway: 192.168.62.1
  25.     subnet: 255.255.255.0
  26. #  use_address: 192.168.62.181
  27.  
  28. api:
  29.   password: ${api_password}
  30.  
  31. ota:
  32.   password: ${ota_password}
  33.  
  34. logger:
  35. uart:
  36.   rx_pin: 16
  37.   tx_pin: 17
  38.   baud_rate: 9600
  39.   id: uart2
  40.  
  41. sensor:
  42.   - platform: pm1006
  43.     pm_2_5:
  44.       name: "Particulate Matter 2.5ยตm Concentration ${device_name}"
  45.       id: pm
  46.       accuracy_decimals: 1
  47.       on_value:
  48.         then:
  49.         - if:
  50.             condition:
  51.               lambda: 'return x < 30;'
  52.             then:
  53.               - light.addressable_set:
  54.                   id: status
  55.                   range_from: 0
  56.                   range_to: 0
  57.                   red: 0.0
  58.                   green: 1.0
  59.                   blue: 0.0
  60.                   color_brightness: !lambda |-
  61.                     return id(sun_elevation).state > 0 ? 1.0 : 0.5;
  62.             else:
  63.             - if:
  64.                 condition:
  65.                   lambda: 'return x > 90;'
  66.                 then:
  67.                 - light.addressable_set:
  68.                     id: status
  69.                     range_from: 0
  70.                     range_to: 0
  71.                     red: 1.0
  72.                     green: 0.0
  73.                     blue: 0.0
  74.                     color_brightness: !lambda |-
  75.                       return id(sun_elevation).state > 0 ? 1.0 : 0.5;
  76.                 else:
  77.                 - light.addressable_set:
  78.                     id: status
  79.                     range_from: 0
  80.                     range_to: 0
  81.                     red: 1.0
  82.                     green: 0.72
  83.                     blue: 0.0
  84.                     color_brightness: !lambda |-
  85.                       return id(sun_elevation).state > 0 ? 1.0 : 0.5;
  86.         - switch.turn_on: fan_delay
  87.     uart_id: uart2
  88.     update_interval: 60s # koukni na fan_delay
  89.  
  90.   - platform: scd4x
  91.     co2:
  92.       name: "CO2 ${device_name}"
  93.       id: co2
  94.       on_value:
  95.         then:
  96.         - if:
  97.             condition:
  98.               lambda: 'return x < 1000;'
  99.             then:
  100.               - light.addressable_set:
  101.                   id: status
  102.                   range_from: 1
  103.                   range_to: 1
  104.                   red: 0.0
  105.                   green: 1.0
  106.                   blue: 0.0
  107.                   color_brightness: !lambda |-
  108.                     return id(sun_elevation).state > 0 ? 1.0 : 0.5;
  109.             else:
  110.             - if:
  111.                 condition:
  112.                   lambda: 'return x > 1500;'
  113.                 then:
  114.                 - light.addressable_set:
  115.                     id: status
  116.                     range_from: 1
  117.                     range_to: 1
  118.                     red: 1.0
  119.                     green: 0.0
  120.                     blue: 0.0
  121.                     color_brightness: !lambda |-
  122.                       return id(sun_elevation).state > 0 ? 1.0 : 0.5;
  123.                 else:
  124.                 - light.addressable_set:
  125.                     id: status
  126.                     range_from: 1
  127.                     range_to: 1
  128.                     red: 1.0
  129.                     green: 0.72
  130.                     blue: 0.0
  131.                     color_brightness: !lambda |-
  132.                       return id(sun_elevation).state > 0 ? 1.0 : 0.5;
  133.        
  134.     humidity:
  135.       name: "Humidity ${device_name}"    
  136.       id: humidity
  137.       on_value:
  138.         then:
  139.         - if:
  140.             condition:
  141.               lambda: 'return x < 30;'
  142.             then:
  143.               - light.addressable_set:
  144.                   id: status
  145.                   range_from: 2
  146.                   range_to: 2
  147.                   red: 1.0
  148.                   green: 0.0
  149.                   blue: 0.0
  150.                   color_brightness: !lambda |-
  151.                     return id(sun_elevation).state > 0 ? 1.0 : 0.5;
  152.             else:
  153.             - if:
  154.                 condition:
  155.                   lambda: 'return x > 60;'
  156.                 then:
  157.                 - light.addressable_set:
  158.                     id: status
  159.                     range_from: 2
  160.                     range_to: 2
  161.                     red: 0.0
  162.                     green: 0.0
  163.                     blue: 1.0
  164.                     color_brightness: !lambda |-
  165.                       return id(sun_elevation).state > 0 ? 1.0 : 0.5;
  166.                 else:
  167.                 - light.addressable_set:
  168.                     id: status
  169.                     range_from: 2
  170.                     range_to: 2
  171.                     red: 0.0
  172.                     green: 1.0
  173.                     blue: 0.0
  174.                     color_brightness: !lambda |-
  175.                       return id(sun_elevation).state > 0 ? 1.0 : 0.5;
  176.   - platform: homeassistant
  177.     id: sun_elevation
  178.     entity_id: sun.sun
  179.     attribute: elevation
  180.   - platform: wifi_signal
  181.     name: "RSSI ${device_name}"
  182.     entity_category: diagnostic
  183.     disabled_by_default: true
  184.     update_interval: 60s
  185.  
  186. switch:
  187.   - platform: gpio
  188.     pin: 12
  189.     id: fan
  190.     restore_mode: ALWAYS_ON
  191.     disabled_by_default: true
  192.     entity_category: diagnostic
  193.    
  194.   - platform: template
  195.     entity_category: diagnostic
  196.     disabled_by_default: true
  197.     id: fan_delay
  198.     turn_on_action:
  199.       - switch.turn_off: fan
  200.       - delay: 50s # cas o 10 sekund kratsi, nez je update_interval senzoru pm1006
  201.       - switch.turn_on: fan
  202.  
  203.  
  204. light:
  205.   - platform: neopixelbus
  206.     type: GRB
  207.     variant: WS2812
  208.     pin: GPIO25
  209.     num_leds: 3
  210.     id: status
  211.     restore_mode: ALWAYS_ON
  212.     method:
  213.       type: esp32_rmt
  214.       channel: 6
  215.  
  216. i2c:
  217.   sda: 21
  218.   scl: 22
  219.   scan: true
  220.   id: bus_a
  221.  
  222. button:
  223.   - platform: restart
  224.     name: "Restart ${device_name}"
  225.     disabled_by_default: true
  226.     entity_category: diagnostic
  227.  
  228. font:
  229.   - file: "gfonts://Roboto"
  230.     id: roboto
  231.     size: 14
  232.    
  233. display:
  234.   - platform: ssd1306_i2c
  235.     model: "SSD1306 128x32"
  236.     address: 0x3C
  237.  
  238.     lambda: |-
  239.       it.printf(10, 0, id(roboto), "PM2.5: %4.0f ppm", id(pm).state);
  240.       if (!isnan(id(co2).state))  {
  241.         it.printf(10, 16, id(roboto), "CO2: %4.0f ppm", id(co2).state);
  242.       } else {
  243.         it.printf(10, 16, id(roboto), "CO2: starting");
  244.      }
  245.      
  246.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement