Advertisement
steve2982

Untitled

Feb 19th, 2022
1,619
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 2.57 KB | None | 0 0
  1. esphome:
  2.   name: kitchen-basecabinet
  3.  
  4. esp8266:
  5.   board: d1_mini
  6. #  restore_from_flash: true
  7.  
  8. # Enable logging
  9. logger:
  10. # Enable Home Assistant API
  11. api:
  12. ota:
  13.   password: "ac7b48a1c0b458f134ade4d182f3a547"
  14.  
  15. wifi:
  16.   ssid: !secret wifi_ssid
  17.   password: !secret wifi_password
  18.  
  19. # Optional manual IP
  20.   manual_ip:
  21.     static_ip: 192.168.4.126
  22.     gateway: 192.168.4.1
  23.     subnet: 255.255.255.0
  24.  
  25. # Enable fallback hotspot (captive portal) in case wifi connection fails
  26.   ap:
  27.     ssid: "kitchen-basecabinet Hotspot"
  28.     password: "wZZT38xSvwCL"
  29.  
  30. mqtt:
  31.   broker: !secret mqtt_broker
  32.   username: !secret mqtt_user
  33.   password: !secret mqtt_password
  34.   discovery_prefix: discovery
  35.  
  36. captive_portal:
  37. globals:
  38.  - id: end_pulse_count
  39.    type: float
  40.    restore_value: no
  41. #   initial_value: '0'
  42.      
  43. # Text sensors with general information.
  44. text_sensor:
  45.   - platform: wifi_info
  46.     ip_address:
  47.       name: kitchen_basecabinet_ip
  48.  
  49. # Sensors with general information.
  50. sensor:
  51.   - platform: uptime
  52.     name: kitchen_basecabinet_uptime
  53.     update_interval: 60s
  54.     expire_after: 66s
  55.    
  56. #  - platform: template
  57. #    name: "Template Pulses Counted"
  58. #    id: template_pulses_counted
  59. #    lambda: return (id(pulses_counted).state);
  60.  
  61. # Example configuration entry
  62.  
  63.   - platform: pulse_counter
  64.     pin: D5
  65.     name: "Pulse Counter"
  66.     update_interval: 1s
  67.     total:
  68.       unit_of_measurement: 'pulses'
  69.       name: 'pulses counted'
  70.       id: "pulses_counted"
  71.       filters:
  72.         - multiply: 1  
  73.  
  74. switch:
  75.   - platform: gpio
  76.     name: "relay1"
  77.     id: "relay1"
  78.     pin:
  79.       number: D6
  80.       inverted: true
  81.      
  82. # Button      
  83. binary_sensor:
  84.   - platform: gpio
  85.     pin:
  86.       number: D7
  87.       mode: INPUT_PULLUP
  88.       inverted: True
  89.     name: "button1"
  90.     on_press:
  91.       then:
  92. #        - lambda: |-
  93. #            static int num_pulses = id(pulses_counted).state;
  94. #            ESP_LOGD("main", "Set starting pulses equals %d", num_pulses);
  95.         - globals.set:
  96.             id: end_pulse_count
  97.             value: (id(pulses_counted).state) + 50;
  98.         - switch.turn_on: relay1
  99. #        - wait_until:
  100. #            condition:
  101. #              lambda:  |-
  102. #                return id(pulses_counted).state > id(end_pulse_count).state;
  103. #              lambda: return id(pulses_counted).state == 50;
  104. #              lambda: return id(pulses_counted).state == (id(start_pulse_count).state + 50);
  105.         - lambda: |-
  106.             ESP_LOGD("main", "Stopping pulses equals %d", id(end_pulse_count).state);
  107.         - switch.turn_off: relay1
  108.  
  109.  
  110.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement