So after a lot of reading I´m back here again.
This is the code right now.
esphome:
name: esp-garagentor
friendly_name: ESP-Garagentor
esp8266:
board: esp01_1m
mqtt:
broker: 192.165.64.64
username: mqtt_sender
password: !secret mqtt_password
# Enable logging
logger:
# Enable Home Assistant API
api:
encryption:
key: "tada"
ota:
password: "tada"
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Esp-Garagentor Fallback Hotspot"
password: "tada"
captive_portal:
sensor:
- platform: rotary_encoder
name: "Torantrieb"
pin_a: GPIO4
pin_b: GPIO5
on_clockwise:
then:
- mqtt.publish:
topic: Torfahrt
payload: "Tor hoch"
on_anticlockwise:
then:
- mqtt.publish:
topic: Torfahrt
payload: "Tor zu"
- platform: rotary_encoder
name: "Torantrieb"
pin_a: GPIO4
pin_b: GPIO5
on_clockwise:
- logger.log: "Torhoch"
on_anticlockwise:
- logger.log: "Torzu"
The Code is uploaded, and the ESP is OK connected to Homeassistant, but the rotary function shows no result.
But at the moment i disconnect the ground wire from the Rot.Enc. an MQTT Meassage is published, showing the counter +1 or -1 steps.
For my demands i wouldn`t need a counter function, just the info via MQTT if the turning is CW or CCW.
Any ideas what to change ?
Thank you… 