Hi,
I’m new to Hass.io and ESPHome and am currently trying to transfer my Domoticz/ESPEasy weather station into Hass.io. …but really struggling with the MQTT configuration.
My setup is a Raspberyy Pi 3 b+ with Hass.io v2.12 installed. I’m using ESPHome on 2 x NodeMCU boards to support a BME280 (with Temp, pressure and Humidity) and to send the sensor data to the other unit where a 4 x 20 LED should display the results.
So far, I’ve successfully connected a DHT11 to the unit with the LED and can display the Temp and Humidity sensor values. The other unit (with the BME280) can send THP sensor values to my MQTT.fx to view the sensor data. However, the problems I’m having are that I really don’t understand how to configure the following:
-
…to configure the BME280 NodeMCU unit to publish the sensor data on an MQTT topic of my choice.
-
…to configure the NodeMCU unit (with the LED) to subscribe to the other units sensor data so that I can display the remote BME280 sensor data in the LED.
I’ve spent days playing around with the settings but just not making any significant progress.
I’ve provided the following yaml file to show progress so far but would appreciate any help i getting this sorted. If any further details required then more than happy to provide them.
Thanks in anticipation.
The ESPHome unit with the BME280 unit has yaml file…
esphome:
name: temp_press_humidity
platform: ESP8266
board: nodemcuv2
# Enable logging
logger:
# Enable Home Assistant API
#api:
# password: 'xxxxxxxxxxxx'
ota:
password: 'xxxxxxxxxxxxx'
wifi:
ssid: "RobsBillion-2.4g"
password: "xxxxxxxx"
manual_ip:
# Set this to the IP of the ESP
static_ip: 192.168.1.132
# Set this to the IP address of the router. Often ends with .1
gateway: 192.168.1.254
# The subnet of the network. 255.255.255.0 works for most home networks.
subnet: 255.255.255.0
i2c:
sda: D2
scl: D1
sensor:
- platform: bme280
temperature:
name: "BME280 Temperature"
oversampling: 16x
id: bme28_temperature
pressure:
name: "BME280 Pressure"
id: bme28_pressure
humidity:
name: "BME280 Humidity"
id: bme28_humidity
address: 0x76
update_interval: 10s
mqtt:
broker: 192.168.1.120
username: robshamqtt
password: xxxxxxxxx
topic_prefix: /robs
log_topic: /house/frontroom/thpsensor
The ESPHome unit with the LED unit has yaml file…
esphome:
name: rgb_lights
platform: ESP8266
board: nodemcuv2
wifi:
ssid: "RobsBillion-2.4g"
password: "xxxxxxxxxxxxxxxx"
manual_ip:
# Set this to the IP of the ESP
static_ip: 192.168.1.131
# Set this to the IP address of the router. Often ends with .1
gateway: 192.168.1.254
# The subnet of the network. 255.255.255.0 works for most home networks.
subnet: 255.255.255.0
# Enable logging
logger:
# Enable Home Assistant API
#api:
# password: 'xxxxxxxxxxxxxxx'
ota:
password: 'xxxxxxxxxxxxxx'
light:
- platform: fastled_clockless
chipset: WS2812
pin: D5
num_leds: 12
rgb_order: GRB
name: "FastLED WS2812 Light"
effects:
- addressable_rainbow:
- addressable_color_wipe:
- flicker:
- strobe:
- addressable_scan:
- addressable_twinkle:
name: Twinkle Effect With Custom Values
twinkle_probability: 5%
progress_interval: 4ms
- addressable_random_twinkle:
- addressable_fireworks:
i2c:
sda: D1
scl: D2
time:
- platform: sntp
id: my_time
display:
- platform: lcd_pcf8574
dimensions: 20x4
address: 0x27
lambda: |-
//it.print("Hello World! Rob...");
// Let's write a sensor value (let's assume it's 42.1)
// Print the current time
it.strftime("%H:%M %d.%m.%Y", id(my_time).now());
# it.printf(0, 1, "Temperature: %.1fC Humidity : %.1f%%", id(robstemperature).state, id(robshumidity).state);
# it.printf(0, 1, "Temperature: %.1fC Humidity : %.1f%%", id(bme280_temperature).state, id(bme280_humidity).state);
sensor:
- platform: dht
pin: D6
temperature:
name: "DHT11 Temperature"
id: robstemperature
humidity:
name: "DHT11 Humidity"
id: robshumidity
update_interval: 10s
model: dht11
mqtt:
broker: 192.168.1.120
port: 1883
username: robshamqtt
password: xxxxxxxxxxxxxx
on_message:
- topic: house/frontroom/thpsensor
then:
- logger.log: MQTT is connected!
Update as needed to make some progress.
I uninstalled the MQTT package I was using and cleaned out the configuration.yaml of any mqtt references. I then installed the package “MQTT Server & Web client” v1.1.0 (i.e. the one with Hivemq’s web client) and managed to get the web-client working with test topics. The problem is that I still can’t find the right mqtt confurations settings to use in one of my ESPHome commands as when I upload it to the device i get the mqtt error…
========================= [SUCCESS] Took 27.62 seconds =========================
INFO Successfully compiled program.
INFO Connecting to 192.168.1.132
INFO Uploading /data/temp_press_humidity/.pioenvs/temp_press_humidity/firmware.bin (354368 bytes)
Uploading: [============================================================] 100% Done…INFO Waiting for result…
INFO OTA successful
INFO Successfully uploaded program.
INFO Starting log output from temp_press_humidity/debug
ERROR Cannot connect to MQTT broker: [Errno -2] Name or service not known
The configuration.yaml mqtt config is…
mqtt:
broker: 192.168.1.120:1884
username: robshamqtt
password: xxxxxxxxxxx
client_id: hassio-mqtt-client
The MQTT Server & Web Client config looks like…
{
"ssl": false,
"certfile": "fullchain.pem",
"keyfile": "privkey.pem",
"broker": true,
"allow_anonymous": false,
"mqttusers": [
{
"username": "robshamqtt",
"password": "xxxxxxxxxxx",
"readonly": false,
"topics": [
"#"
]
}
]
}
…and the ESPHome units MQTT config, attempting to publish sensor values, looks like…
mqtt:
broker: 192.168.1.120:1884
username: "robshamqtt"
password: "xxxxxxxxxxxx"
client_id: hassio-mqtt-client
log_topic: house/room/
So, I’ve absolutely no idea why I’m getting the above error and if anyone out there knows then please get back to me.
Thanks…