Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- substitutions:
- devicename: chickendoorsmartl298n
- upper_devicename: ChickenDoorSmartL298N
- deviceIP: 192.168.178.38
- deviceGatew: 192.168.178.1
- deviceSub: 255.255.255.0
- deviceSSID1: 7390_iot
- deviceSSID2: 7390AP
- esphome:
- name: ${devicename}
- comment: ${upper_devicename}
- on_boot:
- priority: -100
- then:
- - delay: 1s
- - lambda: id(lsw1).publish_state(true);
- - delay: 1s
- - lambda: id(lsw1).publish_state(false);
- - delay: 1s
- - lambda: id(lsw2).publish_state(true);
- - delay: 1s
- - lambda: id(lsw2).publish_state(false);
- esp8266:
- board: d1_mini
- # Disable logging over UART (required)
- logger:
- baud_rate: 0
- # Enable Home Assistant API
- api:
- encryption:
- key: "NEL+xxx+J28sctHwGNhgyEA="
- ota:
- - platform: esphome
- password: "xxx"
- wifi:
- networks:
- - ssid: ${deviceSSID1}
- password: !secret wifi_password
- manual_ip:
- # Set this to the IP of the ESP
- static_ip: ${deviceIP}
- # Set this to the IP address of the router. Often ends with .1
- gateway: ${deviceGatew}
- # The subnet of the network. 255.255.255.0 works for most home networks.
- subnet: ${deviceSub}
- - ssid: ${deviceSSID2}
- password: !secret wifi_password
- manual_ip:
- # Set this to the IP of the ESP
- static_ip: ${deviceIP}
- # Set this to the IP address of the router. Often ends with .1
- gateway: ${deviceGatew}
- # The subnet of the network. 255.255.255.0 works for most home networks.
- subnet: ${deviceSub}
- # Enable fallback hotspot (captive portal) in case wifi connection fails
- ap:
- ssid: "${upper_devicename} Fallback"
- password: "xxx"
- captive_portal:
- # Enable Web server.
- web_server:
- port: 80
- time:
- - platform: homeassistant
- id: homeassistant_time
- # Text sensors with general information.
- text_sensor:
- # Expose ESPHome version as sensor.
- - platform: version
- name: ESPHome Version
- # Expose WiFi information as sensors.
- - platform: wifi_info
- ip_address:
- name: ${upper_devicename} IP
- mac_address:
- name: ${upper_devicename} MAC
- ssid:
- name: ${upper_devicename} SSID
- # Expose Sun rise/set information as sensors.
- - platform: sun
- name: Next Sunrise
- type: sunrise
- - platform: sun
- name: Next Sunset
- type: sunset
- # Expose Door opening/closing time information as sensors.
- - platform: sun
- name: Next Opening
- type: sunrise
- elevation: 0.8
- - platform: sun
- name: Next Closing
- type: sunset
- elevation: -6
- # Sensors with general information.
- sensor:
- # Uptime sensor.
- - platform: uptime
- name: ${upper_devicename} Uptime
- filters:
- - lambda: return x / 60.0;
- unit_of_measurement: minutes
- # WiFi Signal sensor.
- - platform: wifi_signal
- name: ${upper_devicename} WiFi Signal
- update_interval: 60s
- # Expose Sun elevation information as sensors.
- - platform: sun
- name: Sun Elevation
- type: elevation
- # Expose Sun location information as sensors.
- - platform: sun
- name: Sun Azimuth
- type: azimuth
- binary_sensor: #D5 soldered in for future button use
- - platform: gpio
- pin:
- number: GPIO13
- mode:
- input: true
- pullup: true
- id: lsw1
- name: "Chicken Coop open"
- publish_initial_state: true
- filters:
- - delayed_on: 10ms
- - delayed_off: 10ms
- on_press:
- then:
- - button.press: button_stop
- - platform: gpio
- pin:
- number: GPIO12
- mode:
- input: true
- pullup: true
- id: lsw2
- name: "Chicken Coop closed"
- publish_initial_state: true
- filters:
- - delayed_on: 10ms
- - delayed_off: 10ms
- on_press:
- then:
- - button.press: button_stop
- switch:
- - platform: template
- id: disable_open_on_sunrise
- name: "Disable open on sunrise"
- optimistic: true
- button:
- - platform: template
- id: button_on_sunset
- name: Close Door
- on_press:
- if:
- condition:
- binary_sensor.is_off: lsw2
- then:
- - fan.turn_on:
- id: chickendoormotor
- speed: 20
- direction: REVERSE
- - wait_until:
- condition:
- binary_sensor.is_on: lsw2
- - fan.turn_off: chickendoormotor
- - platform: template
- id: button_on_sunrise
- name: Open Door
- on_press:
- if:
- condition:
- binary_sensor.is_off: lsw1
- then:
- - fan.turn_on:
- id: chickendoormotor
- speed: 27
- direction: FORWARD
- - wait_until:
- condition:
- binary_sensor.is_on: lsw1
- - fan.turn_off: chickendoormotor
- - platform: template
- id: button_stop
- name: Stop Door
- on_press:
- - fan.turn_off: chickendoormotor
- ## START Test for logic in esphome
- ##########################################################################################
- # Motor Control
- ##########################################################################################
- # Set home location information as sensors.
- sun:
- latitude: 21.0931
- longitude: -24.8054
- on_sunrise:
- - elevation: 0.8°
- then:
- if:
- condition:
- switch.is_off: disable_open_on_sunrise
- then:
- - button.press: button_on_sunrise
- on_sunset:
- - elevation: -6°
- then:
- - button.press: button_on_sunset
- ##########################################################################################
- # End Stop
- ##########################################################################################
- output:
- - platform: esp8266_pwm
- id: motor_forward_pin
- pin: GPIO4
- - platform: esp8266_pwm
- id: motor_reverse_pin
- pin: GPIO5
- fan:
- - platform: hbridge
- id: chickendoormotor
- name: "Chicken Door Motor"
- pin_a: motor_forward_pin
- pin_b: motor_reverse_pin
- decay_mode: fast # slow decay mode (coasting) or fast decay (braking).
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement