MQTT and API at the same time - it's possible?

It’s possible, by somehow, to have both MQTT and API enabled?

Let me explain: I don’t want to use HA + ESPHome using MQTT, I’m already using API and it’s perfect.
The reason for using MQTT is because I need to read some sensor running ESPHome into my weather station (that subscribe to some MQTT topics)…so I need to publish just some sensor from ESPHome into my weather station using MQTT.
Is that possible??

I’m using mqtt: key…but this creates 2 devices in my HA and only one works…also, everything get’s duplicated and device (ESPHome) keeps rebooting, which is the correct behavior:

If you enable MQTT and you do not use the “native API” for Home Assistant, you must remove the api: line from your ESPHome configuration, otherwise the ESP will reboot every 15 minutes because no client connected to the native API.

Any ideas here?

Add discovery: false to the mqtt definition. Then your device isn’t discovered automatically by HA.

See: MQTT Component

Before flashing the new firmware you should call esphome clean-mqtt your.yaml to cleanup the MQTT discovery topics.

Ok about discovery, but I think I still can’t usw both because of reset thing :confused:

You can overwrite the default reboot_timeout (in the api & mqtt component) with :zero: to disable it. So it will not reboot if api/mqtt is not connected.

If I understand correct you are using HA API for this node. And need MQTT for your weather station.
As long as there is a API connection to the node, nothing will happen. The reboot will only occur, if no HA API connection is available.

Tks Guy’s, its woring with both options, API and MQTT (discovery disabled).