This is the sucessful config that I using for binary sensors in D1 and D2. I havent added any external resistors for this setup.
- platform: gpio
pin:
number: D2
mode: INPUT_PULLUP
inverted: True
name: "br1"
id: br1
- platform: gpio
pin:
number: D1
mode: INPUT_PULLUP
inverted: True
name: "br2"
id: br2
Also the pullup resistor details for esp devices can be seen in the below table.
i believe you might have seen the list of best pins to use in case of esp8266. If not please check the below image

