Advertisement
pmfernandes

Garagem Aspirador

Oct 20th, 2022 (edited)
967
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 6.46 KB | None | 0 0
  1. substitutions:
  2.   hostname: "garagem"
  3.   HumanDeviceName: "Garagem"
  4.   servo_esq_level_open: "-50%"
  5.   servo_dir_level_open: "45%"
  6.   servo_esq_level_close: "75%"
  7.   servo_dir_level_close: "-70%"
  8.  
  9. esphome:
  10.   name: $hostname
  11.   on_boot:
  12.     priority: 600
  13.     then:
  14.       - binary_sensor.template.publish:
  15.           id: ${hostname}_state
  16.           state: OFF
  17.  
  18. esp32:
  19.   board: esp32dev
  20.   framework:
  21.     type: arduino
  22.  
  23. # Enable logging
  24. logger:
  25. # Enable webserver
  26. web_server:
  27.   port: 80
  28.  
  29. # Enable Home Assistant API
  30. api:
  31. ota:
  32.   password: "78270fc069b449b155142f8ed7ddf54b"
  33.  
  34. wifi:
  35.   ssid: !secret wifi_ssid
  36.   password: !secret wifi_password
  37.  
  38. # Enable fallback hotspot (captive portal) in case wifi connection fails
  39.   ap:
  40.     ssid: "Garagem Fallback Hotspot"
  41.     password: "Pbbwp3Boy73q"
  42.  
  43. captive_portal:
  44. #### EFEITOS LUZ ####
  45. light:
  46.   - platform: fastled_clockless
  47.     chipset: WS2812B
  48.     pin: 5
  49.     num_leds: 16
  50.     rgb_order: GRB
  51.     name: "Luz da Garagem"
  52.     id: garage_led
  53.     effects:
  54.       - addressable_lambda:
  55.           name: "Red"
  56.           update_interval: 150ms
  57.           lambda: |-
  58.             static int step = 0;
  59.             static int direction = 1;
  60.  
  61.             if(initial_run){
  62.                 step = 0;
  63.                 it.all() = ESPColor(0,0,0);
  64.             }
  65.  
  66.             it[step] = ESPColor(255,0,0);
  67.             it[it.size() - step] = ESPColor(255,0,0);
  68.  
  69.             step = step + direction;
  70.  
  71.             if(step > it.size()/2){
  72.                 step = 0;
  73.                 it.all() = ESPColor(0,0,0);
  74.             }
  75.       - addressable_lambda:
  76.           name: "Green"
  77.           update_interval: 150ms
  78.           lambda: |-
  79.             static int step = it.size()/2;
  80.             static int step1 = it.size()/2;
  81.             static int direction = 1;
  82.  
  83.             if(initial_run){
  84.                 step = it.size()/2;
  85.                 step1 = it.size()/2;
  86.                 it.all() = ESPColor(0,0,0);
  87.             }
  88.  
  89.             it[step] = ESPColor(0,255,0);
  90.             it[step1] = ESPColor(0,255,0);
  91.  
  92.             step = step + direction;
  93.             step1 = step1 - direction;
  94.  
  95.             if(step > it.size()){
  96.                 step = it.size()/2;
  97.                 step1 = it.size()/2;
  98.                 it.all() = ESPColor(0,0,0);
  99.             }
  100.  
  101. ###### SERVOS ######
  102. servo:
  103.    ## Servo 1 ##
  104.   - id: ${hostname}_servo_dir
  105.     output: ${hostname}_servo_dir_output
  106.     ###### Velocidade servo 1 ######    
  107.     transition_length: 1s
  108.  
  109.     ## SERVO 2 ##
  110.   - id: ${hostname}_servo_esq
  111.     output: ${hostname}_servo_esq_output
  112.     ###### Velocidade SERVO 2 ######
  113.     transition_length: 1s
  114.  
  115.  
  116. ###### OUTPUT ##########
  117. output:
  118.   - platform: ledc
  119.     id: ${hostname}_servo_dir_output
  120.     pin: 4
  121.     frequency: 50 Hz  
  122.    
  123.   - platform: ledc
  124.     id: ${hostname}_servo_esq_output
  125.     pin: 18
  126.     frequency: 50 Hz
  127.  
  128. sensor:
  129.   - platform: uptime
  130.     name: "${HumanDeviceName} Uptime Sensor"
  131.     id: ${hostname}_uptime_sensor
  132.     update_interval: 60s
  133.     on_raw_value:
  134.       then:
  135.         - text_sensor.template.publish:
  136.             id: ${hostname}_uptime_human
  137.             state: !lambda |-
  138.               int seconds = round(id(${hostname}_uptime_sensor).raw_state);
  139.               int days = seconds / (24 * 3600);
  140.               seconds = seconds % (24 * 3600);
  141.               int hours = seconds / 3600;
  142.               seconds = seconds % 3600;
  143.               int minutes = seconds /  60;
  144.               seconds = seconds % 60;
  145.               return (
  146.                 (days ? String(days) + "d " : "") +
  147.                 (hours ? String(hours) + "h " : "") +
  148.                 (minutes ? String(minutes) + "m " : "") +
  149.                 (String(seconds) + "s")
  150.               ).c_str();
  151.   - platform: wifi_signal
  152.     name: "${HumanDeviceName} WiFi RSSI"
  153.     id: ${hostname}_wifi_rssi
  154.     update_interval: 60s
  155.  
  156. binary_sensor:
  157.   - platform: status
  158.     id: ${hostname}_status
  159.     name: "${HumanDeviceName} Status"
  160.     device_class: connectivity
  161.  
  162.   - platform: template
  163.     name: "${HumanDeviceName} State"
  164.     id: ${hostname}_state
  165.     device_class: garage_door
  166.     icon: mdi:garage-variant    
  167.  
  168. button:
  169.   - platform: restart
  170.     id: ${hostname}_restart
  171.     name: "${HumanDeviceName} Restart"
  172.     icon: mdi:restart
  173.   - platform: safe_mode
  174.     name: "${HumanDeviceName} Restart in Safe Mode"
  175.     id: ${hostname}_power_button
  176.     icon: mdi:restart
  177.   - platform: shutdown
  178.     name: "${HumanDeviceName} Shutdown"
  179.     id: ${hostname}_shutdown_button
  180.     icon: mdi:restart
  181.   - platform: template
  182.     name: "${HumanDeviceName} Open"
  183.     id: ${hostname}_open
  184.     on_press:
  185.       then:
  186.         - script.execute: ${hostname}_script_open
  187.   - platform: template
  188.     name: "${HumanDeviceName} Close"
  189.     id: ${hostname}_close
  190.     on_press:
  191.       then:
  192.         - script.execute: ${hostname}_script_close
  193.   - platform: template
  194.     name: "${HumanDeviceName} Button"
  195.     id: ${hostname}_button
  196.     on_press:
  197.       then:
  198.         - if:
  199.             condition:
  200.                 binary_sensor.is_on: ${hostname}_state
  201.             then:
  202.               - script.execute: ${hostname}_script_close
  203.             else:
  204.               - script.execute: ${hostname}_script_open
  205.  
  206. text_sensor:
  207.   - platform: template
  208.     name: "${HumanDeviceName} Uptime"
  209.     id: ${hostname}_uptime_human
  210.     icon: mdi:clock-start
  211.  
  212.   - platform: version
  213.     name: "${HumanDeviceName} ESPHome Version"
  214.     id: ${hostname}_esphome_version
  215.     hide_timestamp: true
  216.  
  217.   - platform: wifi_info
  218.     ip_address:
  219.       id: ${hostname}_IP
  220.       name: "${HumanDeviceName} Endereço IP"
  221.       icon: mdi:ip-network
  222.     ssid:
  223.       id: ${hostname}_SSID
  224.       name: "${HumanDeviceName} Rede Wifi"
  225.       icon: mdi:wifi
  226.  
  227. time:
  228.   - platform: homeassistant
  229.     id: ${hostname}_esptime
  230.  
  231. script:
  232.   - id: ${hostname}_script_open
  233.     then:
  234.       - servo.write:
  235.           id: ${hostname}_servo_esq
  236.           level: $servo_esq_level_open
  237.       - servo.write:
  238.           id: ${hostname}_servo_dir
  239.           level: $servo_dir_level_open
  240.       - binary_sensor.template.publish:
  241.           id: ${hostname}_state
  242.           state: ON
  243.  
  244.   - id: ${hostname}_script_close
  245.     then:
  246.       - servo.write:
  247.           id: ${hostname}_servo_esq
  248.           level: $servo_esq_level_close
  249.       - servo.write:
  250.           id: ${hostname}_servo_dir
  251.           level: $servo_dir_level_close
  252.       - binary_sensor.template.publish:
  253.           id: ${hostname}_state
  254.           state: OFF
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement