Hello colleques!
After reboot or power on esp the motor works short time-0.5-1 sec. How to prevent?
The code and wiring diagram
substitutions:
name: "windowcloser-esp32c3"
# Default friendly name
friendly_name: "windowcloser-esp32c3"
# Allows ESP device to be automatically linked to an 'Area' in Home Assistant. Typically used for areas such as 'Lounge Room', 'Kitchen' etc
room: ""
# Description as appears in ESPHome & top of webserver page
device_description: "windowcloser-esp32c3"
# Project Name
project_name: "windowcloser-esp32c3."
# Projection version denotes the release version of the yaml file, allowing checking of deployed vs latest version
project_version: "v1.0.0"
sensor_update_interval: 5s
# Define a domain for this device to use. i.e. iot.home.lan (so device will appear as athom-smart-plug-v2.iot.home.lan in DNS/DHCP logs)
dns_domain: ""
my_use_address: "windowcloser-esp32c3"
# Set timezone of the smart plug. Useful if the plug is in a location different to the HA server. Can be entered in unix Country/Area format (i.e. "Australia/Sydney")
timezone: "Europe/Moscow"
# Set the duration between the sntp service polling ntp.org servers for an update
sntp_update_interval: 6h
# Network time servers for your region, enter from lowest to highest priority. To use local servers update as per zones or countries at: https://www.ntppool.org/zone/@
sntp_server_1: "0.pool.ntp.org"
sntp_server_2: "1.pool.ntp.org"
sntp_server_3: "2.pool.ntp.org"
# Enables faster network connections, with last connected SSID being connected to and no full scan for SSID being undertaken
wifi_fast_connect: "false"
# Define logging level: NONE, ERROR, WARN, INFO, DEBUG (Default), VERBOSE, VERY_VERBOSE
log_level: "DEBUG"
# Enable or disable the use of IPv6 networking on the device
ipv6_enable: "false"
#
#device_name: dev-sensor
########################## End of Substitutions #########################
esphome:
name: "${name}"
friendly_name: "${friendly_name}"
comment: "${device_description}"
area: "${room}"
name_add_mac_suffix: true
platformio_options:
board_build.flash_mode: dio
# add from https://github.com/kippesikgithub/esp_motion_mmwave/blob/b715fa5e00c1f2eaca44f62939467ac227393097/esp-motion-toilet.yaml
#includes:
# - uart_read_line_sensor_ld2410v3.h
#on_boot:
# priority: -100
# then:
# - script.execute: get_config
project:
name: "${project_name}"
version: "${project_version}"
esp32:
board: esp32-c3-devkitm-1
variant: esp32c3
framework:
type: arduino
#type: esp-idf
#Can be dev, latest, recommended, or check https://github.com/espressif/esp-idf/releases
#version: "5.3.1"
#check platform_version @ https://github.com/platformio/platform-espressif32/releases/
#platform_version: 6.9.0
#sdkconfig_options:
# CONFIG_ESPTOOLPY_FLASHSIZE_4MB: y
preferences:
flash_write_interval: 5min
# Enable Home Assistant API
api:
encryption:
key: "V4naZuZ2RixE5qzduHQUd3gqQtPBpZ1kv6FU4nHmF9g="
ota:
- platform: esphome
password: "a4fd466a8326a6a43f3ef5da16a63aef"
logger:
level: ${log_level}
# logs:
# homeassistant.components.bluetooth: debug
mdns:
disabled: false
#
web_server:
port: 80
local: true
#js_include: "../esphome/dependencies/webserver/v2/www.js"
#js_url: ""
version: 3
include_internal: true
#ota: true
#auth:
# username: !secret web_server_user
# password: !secret web_server_password
network:
enable_ipv6: ${ipv6_enable}
wifi:
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Windowcloser-Esp32C3"
password: "HHxXCETf8qIS"
# Allow rapid re-connection to previously connect WiFi SSID, skipping scan of all SSID
fast_connect: "${wifi_fast_connect}"
# Define dns domain / suffix to add to hostname
domain: "${dns_domain}"
networks:
- ssid: !secret wifi_ssid
password: !secret wifi_password
- ssid: !secret iot_wifi_ssid
password: !secret iot_wifi_password
#
#use_address: esp32c3-66d334.local
use_address: 192.168.99.230
#use_address: "${my_use_address}"
manual_ip:
static_ip: 192.168.99.230
gateway: 192.168.99.1
subnet: 255.255.255.0
dns1: 192.168.99.1
dns2: 8.8.8.8
captive_portal:
esp32_improv:
authorizer: none
#
#!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
# deep_sleep:
# id: "deep_sleep_manual"
# run_duration: 60s
# sleep_duration: 60s
#############################################################################
switch:
- platform: gpio
pin: GPIO6 #INT1
id: switch1_open
name: switch1_open
inverted: true
internal: true
restore_mode: RESTORE_DEFAULT_OFF ##ALWAYS_OFF
- platform: gpio
pin: GPIO5 #INT2
id: switch1_close
name: switch1_close
inverted: true
internal: true
restore_mode: RESTORE_DEFAULT_OFF ##ALWAYS_OFF
- platform: gpio
pin: GPIO1 #INT3
id: switch2_open
name: switch2_open
inverted: true
internal: true
restore_mode: RESTORE_DEFAULT_OFF ##ALWAYS_OFF
- platform: gpio
pin: GPIO2 #INT4
id: switch2_close
name: switch2_close
inverted: true
internal: true
restore_mode: RESTORE_DEFAULT_OFF ##ALWAYS_OFF
##############
# output:
# - platform: gpio
# pin: GPIO6 #INT1
# id: switch1_open
# inverted: true
# - platform: gpio
# pin: GPIO5 #INT2
# id: switch1_close
# inverted: true
# - platform: gpio
# pin: GPIO1 #INT3
# id: switch2_open
# inverted: true
# - platform: gpio
# pin: GPIO2 #INT4
# id: switch2_close
# inverted: true
#
cover:
#- platform: endstop
# name: "Endstop Cover"
- platform: endstop
device_class: gate
name: "Gatefirst"
id: Gatefirst
#max_duration: 60s
#update_interval: 1s
#has_built_in_endstop: true
#has_built_in_endstop: true
#infer_endstop_from_movement: true
###################################3
# open_action:
# - if:
# condition:
# - binary_sensor.is_on: open_endstop_binary_sensor2 # or on
# #- cover.windowcloser_esp32c3_936f80_gatesecond #Cover is at opening or closing state
# then:
# - delay: 0.5s
# - switch.turn_on: switch1_open
###################################
# open_action:
# - if:
# condition:
# lambda: |-
# return id(global_last_operation) != CoverOperation::COVER_OPERATION_IDLE;
# then:
# - cover.stop: gate
# - if:
# condition:
# lambda: |-
# return id(global_last_direction) == CoverOperation::COVER_OPERATION_OPENING;
# then:
# - switch.turn_on: relay
# - delay: 400ms
# - switch.turn_on: relay
# - delay: 400ms
# - lambda: |-
# id(global_last_direction) = CoverOperation::COVER_OPERATION_CLOSING;
############################################################
open_action:
- switch.turn_on: switch1_open
open_duration: 45s
open_endstop: open_endstop_binary_sensor1
#open_sensor: open_movement_binary_sensor
close_action:
- switch.turn_on: switch1_close
close_duration: 45s
close_endstop: close_endstop_binary_sensor1
#close_sensor: close_movement_binary_sensor
stop_action:
- switch.turn_off: switch1_open
- switch.turn_off: switch1_close
on_open:
- logger.log: "Cover is Open!"
on_closed:
- logger.log: "Cover is Closed!"
# - platform: feedback
# device_class: gate
# name: "Gatesecond"
# id: Gatesecond
# #max_duration: 60s
# update_interval: 1s
# open_action:
# - switch.turn_on: switch2_open
# open_duration: 15s
# open_endstop: open_endstop_binary_sensor2
# #open_sensor: open_movement_binary_sensor
# close_action:
# - switch.turn_on: switch2_close
# close_duration: 15s
# close_endstop: close_endstop_binary_sensor2
# #close_sensor: close_movement_binary_sensor
# stop_action:
# - switch.turn_off: switch2_open
# - switch.turn_off: switch2_close
# Example configuration entry
- platform: endstop
name: "Gatesecond"
device_class: gate
id: Gatesecond
max_duration: 20s
#update_interval: 1s
open_action:
- switch.turn_on: switch2_open
open_duration: 15sec
open_endstop: open_endstop_binary_sensor2
close_action:
- switch.turn_on: switch2_close
close_duration: 15sec
close_endstop: close_endstop_binary_sensor2
stop_action:
- switch.turn_off: switch2_open
- switch.turn_off: switch2_close
#
#################################################################################
#
#
binary_sensor:
- platform: gpio
pin:
number: GPIO9
mode: INPUT_PULLUP
#inverted: true
id: open_endstop_binary_sensor1
name: open_endstop_binary_sensor1
filters:
- invert:
- delayed_on: 100ms
- delayed_off: 100ms
#on_press:
#- logger.log: "Sensor 1 Door closed"
- platform: gpio
pin:
number: GPIO10
mode: INPUT_PULLUP
#inverted: true
id: close_endstop_binary_sensor1
name: close_endstop_binary_sensor1
filters:
- invert:
- delayed_on: 100ms
- delayed_off: 100ms
#on_press:
#- logger.log: "Sensor 1 Door open"
#
- platform: gpio
pin:
number: GPIO20
mode: INPUT_PULLUP
#inverted: true
id: open_endstop_binary_sensor2
name: open_endstop_binary_sensor2
filters:
- invert:
- delayed_on: 100ms
- delayed_off: 100ms
#on_press:
#- logger.log: "Sensor 2 Door closed"
- platform: gpio
pin:
number: GPIO21
mode: INPUT_PULLUP
#inverted: true
id: close_endstop_binary_sensor2
name: close_endstop_binary_sensor2
filters:
- invert:
- delayed_on: 100ms
- delayed_off: 100ms
#on_press:
#- logger.log: "Sensor 2 Door open"
- platform: status
name: "Status $friendly_name"
#################################################################
# text_sensor:
# - platform: template
# id: gate_button
# name: Gate Button
# lambda: >-
# if (id(Gatefirst).position == COVER_OPEN) {
# // Cover is open
# } else if (id(Gatefirst).position == COVER_CLOSED) {
# // Cover is closed
# } else {
# // Cover is in-between open and closed
# }
# on_value:
# then:
# - logger.log: "On Click"
# #- cover.open: gate_control
# - delay: 30s
# #- cover.close: gate_control
#######################################################################
#Battery Voltage
sensor:
- platform: adc
id: battery_voltate
pin: GPIO0
attenuation: 12db
name: "Battery Voltage"
update_interval: 60s
accuracy_decimals: 2
icon: "mdi:flash-triangle"
device_class: voltage
filters:
# Map from voltage to Battery voltage
- multiply: 1.44 # 1.27 that is (100k + 27k)/(100k)=127k/100k=127/100=1.27 ##### 3.180 4.16
#use moving median to smooth spikes
#use moving median to smooth spikes
# - median:
# window_size: 10
# send_every: 10
# send_first_at: 10
# - delta: 0.1 #Only send values to HA if they change
# - throttle: 30s #Limit values sent to Ha
#Convert the Voltage to a battery level (%)
- platform: copy
source_id: battery_voltate
id: battery_level
icon: "mdi:battery"
name: "Battery Level"
unit_of_measurement: '%'
accuracy_decimals: 1
device_class: battery
state_class: measurement
filters:
- calibrate_linear:
# Map from voltage to Battery level
- 2.50 -> 0
- 4.2 -> 100
#Handle/cap boundaries
- lambda: |
if (x < 0) return 0;
else if (x > 100) return 100;
else return (x);
- delta: 0.5 #Only send values to HA if they change
- throttle: 30s #Limit values sent to Ha