Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- substitutions:
- hostname: "garagem"
- HumanDeviceName: "Garagem"
- servo_esq_level_open: "-50%"
- servo_dir_level_open: "45%"
- servo_esq_level_close: "75%"
- servo_dir_level_close: "-70%"
- esphome:
- name: $hostname
- on_boot:
- priority: 600
- then:
- - binary_sensor.template.publish:
- id: ${hostname}_state
- state: OFF
- esp32:
- board: esp32dev
- framework:
- type: arduino
- # Enable logging
- logger:
- # Enable webserver
- web_server:
- port: 80
- # Enable Home Assistant API
- api:
- ota:
- password: "78270fc069b449b155142f8ed7ddf54b"
- wifi:
- ssid: !secret wifi_ssid
- password: !secret wifi_password
- # Enable fallback hotspot (captive portal) in case wifi connection fails
- ap:
- ssid: "Garagem Fallback Hotspot"
- password: "Pbbwp3Boy73q"
- captive_portal:
- #### EFEITOS LUZ ####
- light:
- - platform: fastled_clockless
- chipset: WS2812B
- pin: 5
- num_leds: 16
- rgb_order: GRB
- name: "Luz da Garagem"
- id: garage_led
- effects:
- - addressable_lambda:
- name: "Red"
- update_interval: 150ms
- lambda: |-
- static int step = 0;
- static int direction = 1;
- if(initial_run){
- step = 0;
- it.all() = ESPColor(0,0,0);
- }
- it[step] = ESPColor(255,0,0);
- it[it.size() - step] = ESPColor(255,0,0);
- step = step + direction;
- if(step > it.size()/2){
- step = 0;
- it.all() = ESPColor(0,0,0);
- }
- - addressable_lambda:
- name: "Green"
- update_interval: 150ms
- lambda: |-
- static int step = it.size()/2;
- static int step1 = it.size()/2;
- static int direction = 1;
- if(initial_run){
- step = it.size()/2;
- step1 = it.size()/2;
- it.all() = ESPColor(0,0,0);
- }
- it[step] = ESPColor(0,255,0);
- it[step1] = ESPColor(0,255,0);
- step = step + direction;
- step1 = step1 - direction;
- if(step > it.size()){
- step = it.size()/2;
- step1 = it.size()/2;
- it.all() = ESPColor(0,0,0);
- }
- ###### SERVOS ######
- servo:
- ## Servo 1 ##
- - id: ${hostname}_servo_dir
- output: ${hostname}_servo_dir_output
- ###### Velocidade servo 1 ######
- transition_length: 1s
- ## SERVO 2 ##
- - id: ${hostname}_servo_esq
- output: ${hostname}_servo_esq_output
- ###### Velocidade SERVO 2 ######
- transition_length: 1s
- ###### OUTPUT ##########
- output:
- - platform: ledc
- id: ${hostname}_servo_dir_output
- pin: 4
- frequency: 50 Hz
- - platform: ledc
- id: ${hostname}_servo_esq_output
- pin: 18
- frequency: 50 Hz
- sensor:
- - platform: uptime
- name: "${HumanDeviceName} Uptime Sensor"
- id: ${hostname}_uptime_sensor
- update_interval: 60s
- on_raw_value:
- then:
- - text_sensor.template.publish:
- id: ${hostname}_uptime_human
- state: !lambda |-
- int seconds = round(id(${hostname}_uptime_sensor).raw_state);
- int days = seconds / (24 * 3600);
- seconds = seconds % (24 * 3600);
- int hours = seconds / 3600;
- seconds = seconds % 3600;
- int minutes = seconds / 60;
- seconds = seconds % 60;
- return (
- (days ? String(days) + "d " : "") +
- (hours ? String(hours) + "h " : "") +
- (minutes ? String(minutes) + "m " : "") +
- (String(seconds) + "s")
- ).c_str();
- - platform: wifi_signal
- name: "${HumanDeviceName} WiFi RSSI"
- id: ${hostname}_wifi_rssi
- update_interval: 60s
- binary_sensor:
- - platform: status
- id: ${hostname}_status
- name: "${HumanDeviceName} Status"
- device_class: connectivity
- - platform: template
- name: "${HumanDeviceName} State"
- id: ${hostname}_state
- device_class: garage_door
- icon: mdi:garage-variant
- button:
- - platform: restart
- id: ${hostname}_restart
- name: "${HumanDeviceName} Restart"
- icon: mdi:restart
- - platform: safe_mode
- name: "${HumanDeviceName} Restart in Safe Mode"
- id: ${hostname}_power_button
- icon: mdi:restart
- - platform: shutdown
- name: "${HumanDeviceName} Shutdown"
- id: ${hostname}_shutdown_button
- icon: mdi:restart
- - platform: template
- name: "${HumanDeviceName} Open"
- id: ${hostname}_open
- on_press:
- then:
- - script.execute: ${hostname}_script_open
- - platform: template
- name: "${HumanDeviceName} Close"
- id: ${hostname}_close
- on_press:
- then:
- - script.execute: ${hostname}_script_close
- - platform: template
- name: "${HumanDeviceName} Button"
- id: ${hostname}_button
- on_press:
- then:
- - if:
- condition:
- binary_sensor.is_on: ${hostname}_state
- then:
- - script.execute: ${hostname}_script_close
- else:
- - script.execute: ${hostname}_script_open
- text_sensor:
- - platform: template
- name: "${HumanDeviceName} Uptime"
- id: ${hostname}_uptime_human
- icon: mdi:clock-start
- - platform: version
- name: "${HumanDeviceName} ESPHome Version"
- id: ${hostname}_esphome_version
- hide_timestamp: true
- - platform: wifi_info
- ip_address:
- id: ${hostname}_IP
- name: "${HumanDeviceName} Endereço IP"
- icon: mdi:ip-network
- ssid:
- id: ${hostname}_SSID
- name: "${HumanDeviceName} Rede Wifi"
- icon: mdi:wifi
- time:
- - platform: homeassistant
- id: ${hostname}_esptime
- script:
- - id: ${hostname}_script_open
- then:
- - servo.write:
- id: ${hostname}_servo_esq
- level: $servo_esq_level_open
- - servo.write:
- id: ${hostname}_servo_dir
- level: $servo_dir_level_open
- - binary_sensor.template.publish:
- id: ${hostname}_state
- state: ON
- - id: ${hostname}_script_close
- then:
- - servo.write:
- id: ${hostname}_servo_esq
- level: $servo_esq_level_close
- - servo.write:
- id: ${hostname}_servo_dir
- level: $servo_dir_level_close
- - binary_sensor.template.publish:
- id: ${hostname}_state
- state: OFF
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement