# Show/add new ESPhome device in Node-red

**URL:** <https://discourse.nodered.org/t/show-add-new-esphome-device-in-node-red/78012>\
**Category:** General\
**Tags:** docker, home-assistant\
**Created:** [28 April 2023 14:14 UTC](https://discourse.nodered.org/t/show-add-new-esphome-device-in-node-red/78012 "2023-04-28T14:14:04Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![selfmade](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/selfmade/32/79581_2.png) [@selfmade](https://discourse.nodered.org/u/selfmade)\
**Post date:** [28 April 2023 14:14 UTC](https://discourse.nodered.org/t/show-add-new-esphome-device-in-node-red/78012/1 "2023-04-28T14:14:04Z")

</div>

Hello,  
i try to show/add a new ESPhome Device in Node-Red.

what i do already:

1. i create a New ESphome Device (D1-Mini with DHT22 sensor), the Devoce work, ican see is online, the log show me all is ok and in HomeAssistant i see the Device too)

But in the settings I can't select the hardware. It doesn't exist there.  
I guess I forgot some little thing.  
I have already restarted Node-Red on the command line. I use all the software on a Raspberry Pi 4 Docker system

best regards  
Achim

---

<div class="post-metadata">

**Author:** ![marcus-j-davies](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/marcus-j-davies/32/103435_2.png) [@marcus-j-davies](https://discourse.nodered.org/u/marcus-j-davies)\
**Post date:** [28 April 2023 14:26 UTC](https://discourse.nodered.org/t/show-add-new-esphome-device-in-node-red/78012/2 "2023-04-28T14:26:24Z")

</div>

Welcome to the forums @selfmade.

How exactly are you "adding" the device in Node RED.  
some node like `node-red-contrib-esphome`

or some Home Assistant node.

If the latter, you will need to ask in the HA forums, as very little here use Home Assistant

---

<div class="post-metadata">

**Author:** ![selfmade](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/selfmade/32/79581_2.png) [@selfmade](https://discourse.nodered.org/u/selfmade)\
**Post date:** [28 April 2023 15:36 UTC](https://discourse.nodered.org/t/show-add-new-esphome-device-in-node-red/78012/3 "2023-04-28T15:36:22Z")

</div>

Hello,  
i think now i take a big understanding misstake, because i configure my ESPhome device only to cominicate over wifi ... mean i get temp or humidy values only over wifi and can show it in the log-file.

Maybe i have to configure the ESPhome-device first to comunicate over Mqtt.  
node-red-contrib-esphome i installed already and yes i used this because i think ... i add only node-red-esphome-device and then i get also the values from that device... but i think this way is wrong.

maybe i have to configure first the esp-home device to communicate over mqtt...  
thats right?  
is there any howtow step by step where i can show what i have to do...?

Thats my esphome-device Programming-code

```auto
esphome:
  name: grobot-anzucht-d1mini
  friendly_name: grobot_anzucht_D1Mini

esp8266:
  board: d1_mini

# Enable logging
logger:

# Enable Home Assistant API
api:
  encryption:
    key: "9EowYIpEmzeO8cMYFgAefpsvYs0osg37JgdCClE6OYI="

ota:
  password: "77b42abb7619f38e3ad9697c5cfbd292"

wifi:
  manual_ip:
    # Set this to the IP of the ESP
    static_ip: 192.168.2.24 # Set this to the IP address of the router. Often ends with .1
    gateway: 192.168.2.1
    # The subnet of the network. 255.255.255.0 works for most home networks.
    subnet: 255.255.255.0
  ssid: !secret wifi_ssid
  password: !secret wifi_password

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Grobot-Anzucht-D1Mini"
    password: "YhC00Ywz0CAh"

captive_portal:

  # Example configuration entry DHT22 Sensor
sensor:
  - platform: dht
    pin: D0
    temperature:
      name: "Temperatur Anzucht-Box"
    humidity:
      name: "Luftfeuchtigkeit Anzucht-Box"
    update_interval: 10s

```

best regards  
Achim

---

<div class="post-metadata">

**Author:** ![marcus-j-davies](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/marcus-j-davies/32/103435_2.png) [@marcus-j-davies](https://discourse.nodered.org/u/marcus-j-davies)\
**Post date:** [28 April 2023 16:24 UTC](https://discourse.nodered.org/t/show-add-new-esphome-device-in-node-red/78012/4 "2023-04-28T16:24:19Z")

</div>

I know nothing about ESPHome (some here who will of course)  
But if you use MQTT - Node RED will be all over it without a fuss

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [28 April 2023 21:48 UTC](https://discourse.nodered.org/t/show-add-new-esphome-device-in-node-red/78012/5 "2023-04-28T21:48:53Z")

</div>

> [@selfmade](#):
>
> Maybe i have to configure the ESPhome-device first to comunicate over Mqtt.

That is by far the best way to work with ESPhome. I use that for all my home-grown sensor platforms.

> [@selfmade](#):
>
> node-red-contrib-esphome i installed already and yes i used this because i think

You really won't need that if you use MQTT. Just decide on a pattern for your MQTT to/from ESPhome devices. Then you can auto-discover them.

---

<div class="post-metadata">

**Author:** ![meccip](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/meccip/32/49594_2.png) [@meccip](https://discourse.nodered.org/u/meccip)\
**Post date:** [28 April 2023 22:15 UTC](https://discourse.nodered.org/t/show-add-new-esphome-device-in-node-red/78012/6 "2023-04-28T22:15:53Z")

</div>

hello,  
add to yaml file

mqtt:  
broker: !secret mqtt\_host  
discovery: false

if you dont use with home assist, remove api from yaml file

open mqtt explorer and see the publish for dht sensor the use it in nodered

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [28 April 2023 23:20 UTC](https://discourse.nodered.org/t/show-add-new-esphome-device-in-node-red/78012/7 "2023-04-28T23:20:52Z")

</div>

I use a set of standard include files so that all of the standard bits are exactly that and only the platform specific things and the name/ip address change.

---

<div class="post-metadata">

**Author:** ![selfmade](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/selfmade/32/79581_2.png) [@selfmade](https://discourse.nodered.org/u/selfmade)\
**Post date:** [28 April 2023 23:49 UTC](https://discourse.nodered.org/t/show-add-new-esphome-device-in-node-red/78012/8 "2023-04-28T23:49:08Z")

</div>

> [@TotallyInformation](#):
>
> You really won't need that if you use MQTT. Just decide on a pattern for your MQTT to/from ESPhome devices. Then you can auto-discover them.

Yes, thanks, I'm slowly getting the hang of it.  
I think I first have to create a mqtt entry for the ESP (server, user and password), I think then a sensor entry.... right? and then when the ESP is finished, then I only have to select and configure the mqtt-node in node-red? something like that, right?  
I think that I have to enter in the ESP what it sends... for example... temperature and humidity... he mqtt has to get this data somehow

---

<div class="post-metadata">

**Author:** ![selfmade](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/selfmade/32/79581_2.png) [@selfmade](https://discourse.nodered.org/u/selfmade)\
**Post date:** [29 April 2023 00:09 UTC](https://discourse.nodered.org/t/show-add-new-esphome-device-in-node-red/78012/9 "2023-04-29T00:09:20Z")

</div>

> [@meccip](#):
>
> mqtt:  
> broker: !secret mqtt\_host  
> discovery: false
> 
> if you dont use with home assist, remove api from yaml file
> 
> open mqtt explorer and see the publish for dht sensor the use it in nodered

my esp D1 Mini have this code for mqtt

```auto
esphome:
  name: grobot-d1mini
  friendly_name: ESP-D1Mini-Sensors

esp8266:
  board: d1_mini

# Enable logging
logger:

# Enable Home Assistant API
#api:
# encryption:
# key: "xxxxxxxxxxxxxxxxxxxxxxxxxxxx"
.
.
.
.

  # DHT22 Sensor
sensor:
  - platform: dht
    pin: D0
    temperature:
      name: "Temperatur"
    humidity:
      name: "Luftfeuchtigkeit"
    update_interval: 10s
mqtt:
  broker: !secret mqtt_host
  port: !secret mqtt_port
  username: !secret mqtt_username
  password: !secret mqtt_password

```

i'm not sure is the entry "sensor:" right... because that was only a sample to get the values from the espand his DHT22 on the serial.

yes i use home-assistant...

later I would like to control all data and controls via a home-assistant dashboard (I could then do this at home from a tablet or from the Internet) and/or via a mobile app from my mobile phone.  
i was not sure... i have to disable api: or not ☹

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [29 April 2023 00:25 UTC](https://discourse.nodered.org/t/show-add-new-esphome-device-in-node-red/78012/10 "2023-04-29T00:25:38Z")

</div>

> [@selfmade](#):
>
> I think I first have to create a mqtt entry for the ESP (server, user and password), I think then a sensor entry.... right? and then when the ESP is finished, then I only have to select and configure the mqtt-node in node-red? something like that, right?

Here is my MQTT include file

```auto
# Configuration for the MQTT Broker.
# NB: This configuration does not use Home Assistant (HA). It uses TotallyInformation's standard MQTT Schema for ESP devices.
#
# The configuration variables must be set in the master YAML file.

mqtt: # Home MQTT Broker

  broker: $mqtt_broker 
  username: $mqtt_username
  password: $mqtt_password
  topic_prefix: $mqtt_prefix
  id: mqtt_client

  log_topic: # no log to MQTT, it isn't needed and isn't that useful unless you subscribe something to it.

  birth_message:
    topic: $mqtt_prefix
    payload: Online
    retain: true

  will_message:
    topic: $mqtt_prefix
    payload: Offline
    retain: true

  shutdown_message:
    topic: $mqtt_prefix
    payload: Shutdown
    retain: true

  discovery: false # No HA discovery, we aren't using HA

#--- End of mqtt ---#

```

It is included in all of my ESPhome driven devices.

I don't use Home Assistant.

This is a typical platform configuration - for a d1 mini in this case:

```auto
# D1 Mini Configuration for D1M05 (D1 Mini)

# Pins (=GPIO)| Input? | Output? | Comments
  # D0 = 16 | Y | Y | High @ boot, Wake, I/P: No Interrupt, O/P: No PWM or I2C
  # D1 = 5 | Y | Y | I2C SCL
  # D2 = 4 | Y | Y | I2C SDA
  # D3 = 0 | Y | Y | 
  # D4 = 2 | Y | Y | Onboard LED
  # D5 = 14 | Y | Y | 
  # D6 = 12 | Y | Y | 
  # D7 = 13 | Y | Y | 
  # D8 = 15 | Y | Y | 
  # RX = 3 | Y | Y | 
  # TX = 1 | | Y | 
  # A0 = ADC0 | Y | | 

substitutions: # All have to be strings, the substitution process will convert them to the correct types
  devicename: d1m02
  upper_devicename: D1M02
  device_location: Rear Hall
  device_description: Rear Hall custom sensor platform using ESPhome firmware
  ipaddress: 192.168.1.152
  mqtt_prefix: ESP/D1M02 #$mqtt_root/$devicename # Argh! combined substitutions don't work!
  esp_board: d1_mini
  last_update: '"2022-12-12 10:47:12"'
  
  mqtt_root: ESP
  mqtt_broker: !secret mqtt_broker 
  mqtt_username: !secret mqtt_username
  mqtt_password: !secret mqtt_password
  
  wifi_power_save_mode: light # none (default for esp8266), light (default for esp32), high
  wifi_fast_connect: "true"
  wifi_ssid: !secret WiFi_SSID
  wifi_password: !secret WiFi_password
  wifi_domain: !secret WiFi_domain
  wifi_gateway: !secret WiFi_gateway
  wifi_subnet: !secret WiFi_subnet
  wifi_dns1: !secret WiFi_DNS1
  wifi_ap_password: !secret WiFi_AP_Password

  web_auth_username: !secret Web_Auth_Username
  web_auth_password: !secret Web_Auth_Password

  publish_interval: 50s
  log_level: info # none, error, warn, info, debug, verbose
  #esp_platform: ESP8266
  
  sun_latitude: !secret sun_latitude
  sun_longitude: !secret sun_longitude 
# --- End of substitutions: --- #  
  
<<: !include includes/mqtt.yaml # For some reason, the config checker doesn't like this as a package
packages: # These allow merging whereas global includes do not
  common: !include includes/common.yaml
  logger: !include includes/logger.yaml
  wifi: !include includes/wifi.yaml
  common_sensors: !include includes/common-sensors.yaml # Includes number, text and binary
  common_switches: !include includes/common-switches.yaml
  common_intervals: !include includes/common-intervals.yaml
# --- End of packages: --- #

# Basic configuration for ESP8266 based boards. https://esphome.io/components/esp8266.html
# Board names: https://registry.platformio.org/platforms/platformio/espressif8266/boards
esp8266:
  board: $esp_board

status_led:
  pin: 
    number: D4 # GPIO-2
    inverted: true

i2c: # https://esphome.io/components/i2c.html#i2c
  frequency: 400000.0 # default 50000.0, can be up to 800k - try 400k on a d1 mini?

sensor: # NB: See also common_sensors

  # Temperature & Humidity
  #- <<: !include includes/sensors/th_dht.yaml
  # DHT based Temperature+Humidity Sensors - https://esphome.io/components/sensor/dht.html
  - platform: dht
    pin: D5
    model: AM2302
    temperature:
      name: "Temperature"
      id: temperature
      state_topic: $mqtt_prefix/DHT22/Temperature
    humidity:
      name: "Humidity"
      id: humidity
      state_topic: $mqtt_prefix/DHT22/Humidity
      accuracy_decimals: 1
      # filters:
      # - offset: 4.2
  
  # Ambient light intensity
  - <<: !include includes/sensors/light_bh1750.yaml

binary_sensor:
  - platform: gpio # 1-wire sound sensor
    pin: D3
    name: "Sound"
    id: sound
    state_topic: $mqtt_prefix/Sound/Sound

text_sensor:
  - platform: template # Template text sensor wifi channel
    id: wifi_channel
    lambda: |-
      // --- ESP8266 version ---
      std::string out;
      char buffer[64];
      sprintf(buffer, "%u", wifi_get_channel());
      out.append(buffer);
      return out;
      // --- ESP32 version ---
      //wifi_ap_record_t wifidata;
      //esp_wifi_sta_get_ap_info(&wifidata);
      //std::string out;
      //if (wifidata.primary != 0) {
        //char buffer[64];
        //sprintf(buffer, "%u", wifidata.primary);
        //out.append(buffer);
      //}
      //return out;
#EOF

```

---

<div class="post-metadata">

**Author:** ![meccip](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/meccip/32/49594_2.png) [@meccip](https://discourse.nodered.org/u/meccip)\
**Post date:** [29 April 2023 00:43 UTC](https://discourse.nodered.org/t/show-add-new-esphome-device-in-node-red/78012/11 "2023-04-29T00:43:42Z")

</div>

put mqtt after api  
sensor is last  
if you use home assist, you need api enabled.

you can type in cmd windows to see debug logs  
esphome logs filename.yaml

---

<div class="post-metadata">

**Author:** ![selfmade](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/selfmade/32/79581_2.png) [@selfmade](https://discourse.nodered.org/u/selfmade)\
**Post date:** [29 April 2023 08:50 UTC](https://discourse.nodered.org/t/show-add-new-esphome-device-in-node-red/78012/12 "2023-04-29T08:50:40Z")

</div>

> [@TotallyInformation](#):
>
> It is included in all of my ESPhome driven devices.  
> I don't use Home Assistant.  
> This is a typical platform configuration - for a d1 mini in this case:

Wow thank you very much. I see that I still lack a lot of knowledge. This is a very, very good example for me to look for all the commands and study them more closely. That helps me a lot... but now I have to sit down over the weekend and study it carefully in order to understand it.  
api:  
this is how I understand the API now....so if anyone is using IOBroker or Openhab then you don't need the API statement...

you write in code

```auto
<<: !include includes/mqtt.yaml # 

```

What mean "\<\<: " ?  
Do I then have to remove it again when uploading to the ESP?

---

<div class="post-metadata">

**Author:** ![selfmade](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/selfmade/32/79581_2.png) [@selfmade](https://discourse.nodered.org/u/selfmade)\
**Post date:** [29 April 2023 08:54 UTC](https://discourse.nodered.org/t/show-add-new-esphome-device-in-node-red/78012/13 "2023-04-29T08:54:13Z")

</div>

> [@meccip](#):
>
> you can type in cmd windows to see debug logs  
> esphome logs filename.yaml

is it possible to show a small example please?

---

<div class="post-metadata">

**Author:** ![meccip](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/meccip/32/49594_2.png) [@meccip](https://discourse.nodered.org/u/meccip)\
**Post date:** [29 April 2023 11:28 UTC](https://discourse.nodered.org/t/show-add-new-esphome-device-in-node-red/78012/14 "2023-04-29T11:28:05Z")

</div>

this example is for pzem004T.yaml (i dont have dht sensor, i have an energy meter)

open cmd in windows and to execute command you need to be in esp home directory. (is not working if you are not in that directory)

Microsoft Windows [Version 10.0.19045.2846]  
(c) Microsoft Corporation. All rights reserved.

C:\Users\pn\>cd C:\Users\pn\esphome-jk-bms

C:\Users\pn\esphome-jk-bms\>esphome logs pzem004T.yaml  
←[32mINFO Reading configuration pzem004T.yaml...←[0m  
←[32mINFO Starting log output from pzem004t/debug←[0m  
←[32mINFO Connected to MQTT broker!←[0m  
[14:23:42][D][pzemac:049]: PZEM AC: V=227.3 V, I=0.175 A, P=1.0 W, E=606588.0 Wh, F=50.0 Hz, PF=0.03  
[14:23:45][I][mqtt:216]: MQTT Connected!  
[14:23:46][D][pzemac:049]: PZEM AC: V=227.2 V, I=0.176 A, P=1.0 W, E=606588.0 Wh, F=50.0 Hz, PF=0.03  
[14:23:46][D][sensor:126]: 'Voltage': Sending state 227.20000 V with 1 decimals of accuracy  
[14:23:47][D][sensor:126]: 'Current': Sending state 0.17600 A with 3 decimals of accuracy  
[14:23:47][D][sensor:126]: 'Power': Sending state 1.00000 W with 2 decimals of accuracy  
[14:23:47][D][sensor:126]: 'Energy': Sending state 606588.00000 Wh with 0 decimals of accuracy  
[14:23:47][D][sensor:126]: 'Frequency': Sending state 50.00000 Hz with 1 decimals of accuracy  
[14:23:47][D][sensor:126]: 'Power Factor': Sending state 0.03000 with 2 decimals of accuracy  
[14:23:49][D][pzemac:049]: PZEM AC: V=227.2 V, I=0.175 A, P=1.0 W, E=606588.0 Wh, F=50.0 Hz, PF=0.03  
[14:23:49][D][sensor:126]: 'Voltage': Sending state 227.20000 V with 1 decimals of accuracy  
[14:23:49][D][sensor:126]: 'Current': Sending state 0.17500 A with 3 decimals of accuracy  
[14:23:49][D][sensor:126]: 'Power': Sending state 1.00000 W with 2 decimals of accuracy  
[14:23:49][D][sensor:126]: 'Energy': Sending state 606588.00000 Wh with 0 decimals of accuracy  
[14:23:49][D][sensor:126]: 'Frequency': Sending state 50.00000 Hz with 1 decimals of accuracy  
[14:23:49][D][sensor:126]: 'Power Factor': Sending state 0.03000 with 2 decimals of accuracy

C:\Users\pn\esphome-jk-bms\>

---

<div class="post-metadata">

**Author:** ![selfmade](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/selfmade/32/79581_2.png) [@selfmade](https://discourse.nodered.org/u/selfmade)\
**Post date:** [29 April 2023 11:58 UTC](https://discourse.nodered.org/t/show-add-new-esphome-device-in-node-red/78012/15 "2023-04-29T11:58:25Z")

</div>

> [@meccip](#):
>
> Microsoft Windows [Version 10.0.19045.2846]  
> (c) Microsoft Corporation. All rights reserved.

oooh... maybe i wrote it wrong... my HA-System and ESPhome is all running under Linux (Raspberry PI)

---

<div class="post-metadata">

**Author:** ![meccip](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/meccip/32/49594_2.png) [@meccip](https://discourse.nodered.org/u/meccip)\
**Post date:** [29 April 2023 12:48 UTC](https://discourse.nodered.org/t/show-add-new-esphome-device-in-node-red/78012/16 "2023-04-29T12:48:51Z")

</div>

how do you compile yaml file under raspberry ?

---

<div class="post-metadata">

**Author:** ![selfmade](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/selfmade/32/79581_2.png) [@selfmade](https://discourse.nodered.org/u/selfmade)\
**Post date:** [29 April 2023 13:16 UTC](https://discourse.nodered.org/t/show-add-new-esphome-device-in-node-red/78012/17 "2023-04-29T13:16:50Z")

</div>

> [@meccip](#):
>
> how do you compile yaml file under raspberry

yes... i used esphome (running on my raspberry-pi-HA-System)... compile the files and then the raspberry-pi esphome

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [29 April 2023 18:12 UTC](https://discourse.nodered.org/t/show-add-new-esphome-device-in-node-red/78012/18 "2023-04-29T18:12:00Z")

</div>

> [@selfmade](#):
>
> What mean "\<\<: " ?

It is the YAML insertion operator.

[Configuration Types — ESPHome](https://esphome.io/guides/configuration-types.html?highlight=include#yaml-insertion-operator)

> [@selfmade](#):
>
> Do I then have to remove it again when uploading to the ESP?

Nope, the compile includes the external YAML for you at that point.

> [@meccip](#):
>
> how do you compile yaml file under raspberry ?

ESPhome uses Python so it works the same on other platforms.

---

<div class="post-metadata">

**Author:** ![selfmade](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/selfmade/32/79581_2.png) [@selfmade](https://discourse.nodered.org/u/selfmade)\
**Post date:** [30 April 2023 15:07 UTC](https://discourse.nodered.org/t/show-add-new-esphome-device-in-node-red/78012/19 "2023-04-30T15:07:20Z")

</div>

> [@TotallyInformation](#):
>
> It is the YAML insertion operator.

Do you need this to insert other files?  
I had (so my weak memory) only seen it that way  
!include includes/mqtt.yaml

I am very interested in your ESPhome example above. It looks very structured.  
However, some instructions are not entirely clear to me.  
for example

mqtt\_root: ESP

I can't find that in any documentation  
Is that a special instruction?

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [30 April 2023 20:36 UTC](https://discourse.nodered.org/t/show-add-new-esphome-device-in-node-red/78012/20 "2023-04-30T20:36:59Z")

</div>

> [@selfmade](#):
>
> Do you need this to insert other files?

Been a while since I did it. Not sure if it is necessary. But it works. 🙂

> [@selfmade](#):
>
> mqtt\_root: ESP

That means that all my ESP based devices use `ESP/xxxxx` as the root MQTT topic. It comes in the `substitutions` section so that you can use `mqtt_root` as a variable elesewhere. But as you can see from the line a little above:

```auto
mqtt_prefix: ESP/D1M02 #$mqtt_root/$devicename # Argh! combined substitutions don't work!

```

Annoyingly, that's the only place you can't use it. However, a quick search of my code reveals that it doesn't look as though it gets used at all currently. 🥴

* * *

I currently have around 7 devices, all using a master YAML will various includes.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/7/879eed42f22cbe4e002b6af9c4ec566672b37d3f.png)

[Next page](https://discourse.nodered.org/t/show-add-new-esphome-device-in-node-red/78012.md?page=2)
