That should work. Make sure you flash the ESP with the correct firmware to be able to connect it to openHAB: either with Tasmota or with ESPEasy. Connection to openHAB is done through MQTT.