From the kitchen drawer

YAML snippet maker

Pick an ingredient, give it a name and a pin, and add it to the card. The maker writes a starting snippet you can paste into a device configuration, grouped under sensor:, binary_sensor:, switch: and i2c:. It only arranges what you type into fixed templates: it does not know your board, and it does not check whether a pin exists, is free or is safe to use.

1. Choose an ingredient
2. Fill in the details

Shown in Home Assistant. For a DHT sensor the maker adds “Temperature” and “Humidity”.

Letters, digits and underscores, as your board's pin name is written (for example GPIO4 or D2).

Whole seconds from 1 to 86,400. The starting value is ESPHome’s 60-second DHT default.

Editor limits: 20 ingredients on the card, names up to 60 characters, pin labels up to 24 characters.

Your recipe card

No ingredients yet. Add one in the form and the draft YAML appears here.

    Draft YAML

    How the snippet is written

    Each ingredient becomes one of these fixed templates. Words in capitals are replaced with what you typed. Indents are two spaces per level.

    DHT sensor
    sensor:
      - platform: dht
        pin: PIN
        temperature:
          name: "NAME Temperature"
        humidity:
          name: "NAME Humidity"
        update_interval: SECONDSs
    GPIO binary sensor
    binary_sensor:
      - platform: gpio
        pin: PIN
        name: "NAME"
    GPIO switch
    switch:
      - platform: gpio
        pin: PIN
        name: "NAME"
    I²C bus
    i2c:
      sda: SDA_PIN
      scl: SCL_PIN

    What the maker assumes

    • Several ingredients of the same kind are listed under one key: sensor:, binary_sensor: or switch: hold a list. If your file already has that key, paste the list items under it rather than adding the key a second time.
    • The i2c: block holds a single bus as a mapping, not a list. If your configuration already has an i2c: block, edit it instead of pasting a second one. When you configure more than one bus, the I²C page uses a list of entries with unique id values, and a sensor on a particular bus sets i2c_id; see “Multiple I²C Buses” on that page.
    • The DHT template leaves out model:, so ESPHome uses its default model detection. The DHT page lists the models you can set if detection fails.
    • Names are written in double quotes, with any quote or backslash you type escaped.
    • The update interval is whole seconds from 1 to 86,400, written as for example 60s. The starting value of 60 is ESPHome’s default for the DHT sensor. The upper limit is this maker’s own choice, not an ESPHome rule.
    • Pins are copied exactly as you type them. A warning appears when the same pin number is used twice on the card, so 16 and GPIO16 count as the same pin and the same SDA and SCL pin is refused. The maker cannot resolve board-specific names such as D2, so it does not catch those, and it does not check whether a pin exists, is free or is safe.
    • Editor limits, which are this maker’s own and not ESPHome rules: 20 ingredients on the card, names up to 60 characters and pin labels up to 24 characters.
    • The snippet is a draft, not a checked configuration. Add this draft to an ESPHome configuration for your board, and configure networking and integration for your setup: ESPHome documents Wi-Fi, Ethernet, the native API and MQTT as options. Check every setting against the official component page before you install it.

    Sources

    1. DHT Temperature+Humidity Sensor, ESPHome documentation (esphome.io)
    2. GPIO Binary Sensor, ESPHome documentation (esphome.io)
    3. GPIO Switch, ESPHome documentation (esphome.io)
    4. I²C Bus, ESPHome documentation (esphome.io)
    5. Ethernet Component, ESPHome documentation (esphome.io)
    6. MQTT Client Component, ESPHome documentation (esphome.io)