Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- esphome:
- name: kitchen-basecabinet
- esp8266:
- board: d1_mini
- # restore_from_flash: true
- # Enable logging
- logger:
- # Enable Home Assistant API
- api:
- ota:
- password: "ac7b48a1c0b458f134ade4d182f3a547"
- wifi:
- ssid: !secret wifi_ssid
- password: !secret wifi_password
- # Optional manual IP
- manual_ip:
- static_ip: 192.168.4.126
- gateway: 192.168.4.1
- subnet: 255.255.255.0
- # Enable fallback hotspot (captive portal) in case wifi connection fails
- ap:
- ssid: "kitchen-basecabinet Hotspot"
- password: "wZZT38xSvwCL"
- mqtt:
- broker: !secret mqtt_broker
- username: !secret mqtt_user
- password: !secret mqtt_password
- discovery_prefix: discovery
- captive_portal:
- globals:
- - id: end_pulse_count
- type: float
- restore_value: no
- # initial_value: '0'
- # Text sensors with general information.
- text_sensor:
- - platform: wifi_info
- ip_address:
- name: kitchen_basecabinet_ip
- # Sensors with general information.
- sensor:
- - platform: uptime
- name: kitchen_basecabinet_uptime
- update_interval: 60s
- expire_after: 66s
- # - platform: template
- # name: "Template Pulses Counted"
- # id: template_pulses_counted
- # lambda: return (id(pulses_counted).state);
- # Example configuration entry
- - platform: pulse_counter
- pin: D5
- name: "Pulse Counter"
- update_interval: 1s
- total:
- unit_of_measurement: 'pulses'
- name: 'pulses counted'
- id: "pulses_counted"
- filters:
- - multiply: 1
- switch:
- - platform: gpio
- name: "relay1"
- id: "relay1"
- pin:
- number: D6
- inverted: true
- # Button
- binary_sensor:
- - platform: gpio
- pin:
- number: D7
- mode: INPUT_PULLUP
- inverted: True
- name: "button1"
- on_press:
- then:
- # - lambda: |-
- # static int num_pulses = id(pulses_counted).state;
- # ESP_LOGD("main", "Set starting pulses equals %d", num_pulses);
- - globals.set:
- id: end_pulse_count
- value: (id(pulses_counted).state) + 50;
- - switch.turn_on: relay1
- # - wait_until:
- # condition:
- # lambda: |-
- # return id(pulses_counted).state > id(end_pulse_count).state;
- # lambda: return id(pulses_counted).state == 50;
- # lambda: return id(pulses_counted).state == (id(start_pulse_count).state + 50);
- - lambda: |-
- ESP_LOGD("main", "Stopping pulses equals %d", id(end_pulse_count).state);
- - switch.turn_off: relay1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement