I'd like to use this topic so other people can share their ESPHome projects.
Here's one of mine: a controller for my garagedoor. With this I am able to open/close the garage and read the state of the following sensors:
Here's one of mine: a controller for my garagedoor. With this I am able to open/close the garage and read the state of the following sensors:
- 2 reed contacts placed on the garagedoor, 1 in the fully opened position and 1 in the fully closed position
- Ultrasonic sensor to detect if my car is in the garage. I use this to determine if the garage needs to be opened whenever I get home. Or to determine if I should open the door whenever I'm about to leave.
Code:
esphome: name: garagedoorcontroller platform: ESP8266 board: d1_mini wifi: ssid: "xxxxxxxxx" password: "xxxxxxxxxxxxx" # Enable logging logger: mqtt: broker: xxx.xxx.xxx.xxx discovery: true username: xxx password: xxx ota: password: "xxxx" sensor: - platform: ultrasonic trigger_pin: D5 echo_pin: D0 timeout: 4m name: "Ultrasonic Sensor" id: ultrasonic_sensor_car binary_sensor: - platform: gpio pin: number: D7 mode: INPUT_PULLUP inverted: True name: "Fully open" id: sensor_open filters: - delayed_on: 250ms on_press: then: - cover.template.publish: id: cover_garage current_operation: !lambda 'return COVER_OPERATION_IDLE;' on_release: then: - cover.template.publish: id: cover_garage position: !lambda 'return 0.5;' current_operation: !lambda 'return COVER_OPERATION_CLOSING;' - platform: gpio pin: number: D6 mode: INPUT_PULLUP inverted: True name: "Closed" id: sensor_closed filters: - delayed_on: 250ms on_press: then: - cover.template.publish: id: cover_garage current_operation: !lambda 'return COVER_OPERATION_IDLE;' on_release: then: - cover.template.publish: id: cover_garage position: !lambda 'return 0.5;' current_operation: !lambda 'return COVER_OPERATION_OPENING;' - platform: template name: "Car in garage" lambda: |- if (id(ultrasonic_sensor_car).state <= 1.30) { return true; } else { return false; } switch: - platform: gpio pin: D1 name: relay id: relay cover: - platform: template name: "Garagedoor" id: cover_garage lambda: |- if (id(sensor_closed).state) { return COVER_CLOSED; } else { return COVER_OPEN; } open_action: - if: condition: binary_sensor.is_off: sensor_open then: - switch.turn_on: relay - delay: 1s - switch.turn_off: relay close_action: - if: condition: binary_sensor.is_off: sensor_closed then: - switch.turn_on: relay - delay: 1s - switch.turn_off: relay stop_action: - switch.turn_on: relay - delay: 1s - switch.turn_off: relay
Comment