Hello everyone…
Now that i had so much help and inspiration from you guys, and everything is working as i want, i would like to share what i came up with.
I have a small ammo box from Harbour fraudas a housing…
A randomly found geared 12 volt DC motor
Self turned line spool made from wood,
A double relay esp01 board
a pwm speed controller
a 12 to 5 volt step down converter
2 small micro
switches with NC and NO contacts
Some wood and plastic for door and frame guide
Hope it helps or inspires someone
My Yaml code is this:
substitutions:
devicename: chickendoorcontroll
upper_devicename: Chickendoorcontroll
deviceIP: 192.168.178.xx
deviceGatew: 192.168.178.xx
deviceSub: 255.255.255.0
deviceSSID1: ssid
deviceSSID2: ssid-2.4G
esphome:
name: ${devicename}
comment: ${upper_devicename}
esp8266:
board: esp01_1m
# Disable logging over UART (required)
logger:
baud_rate: 0
# Enable Home Assistant API
api:
encryption:
key: "something"
ota:
password: "something"
platform: esphome
wifi:
networks:
- 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}
- 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}
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "${upper_devicename}"
password: "something"
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: -4
# 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
- platform: sun
name: Sun Elevation
type: elevation
# Expose Sun location information as sensors.
- platform: sun
name: Sun Azimuth
type: azimuth
## START Test for logic in esphome
##########################################################################################
# Motor Control
##########################################################################################
# Set home location information as sensors.
sun:
latitude: 46.0931
longitude: -72.8054
on_sunrise:
- elevation: 0.8°
then:
- button.press: button_on_sunrise
on_sunset:
- elevation: -4°
then:
- button.press: button_on_sunset
button:
- platform: template
id: button_on_sunset
name: Close Door
on_press:
- switch.turn_on:
id: relay2
- delay: 20s
- switch.turn_off:
id: relay2
- platform: template
id: button_on_sunrise
name: Open Door
on_press:
- switch.turn_on:
id: relay1
- delay: 20s
- switch.turn_off:
id: relay1
##########################################################################################
# End Stop
##########################################################################################
##
switch:
- platform: gpio
id: relay1
name: 'Relay 1'
pin: GPIO0
- platform: gpio
id: relay2
name: 'Relay 2'
pin: GPIO2