I need some help with MQTT. I have it working in HA and a Node MCU and DHT22 sensor. When I added another NodeMCU and DHT22 sensor Im not getting the sensor data.
My first piece of code:
#define masterbed_humidity_topic “sensor/masterbed_humidity”
#define masterbed_temperature_topic “sensor/masterbed_temperature”
…
client.publish(masterbed_temperature_topic, String(temp).c_str(), true);
}
if (checkBound(newHum, hum, diff)) {
hum = newHum;
Serial.print("New humidity:");
Serial.println(String(hum).c_str());
client.publish(masterbed_humidity_topic, String(hum).c_str(), true);
HA only sees this as the temp & humidity.sensor
My second NodeMCU code is:
#define test_humidity_topic “sensor/test_humidity”
#define test_temperature_topic “sensor/test_temperature”
…
client.publish(test_temperature_topic, String(temp).c_str(), true);
}
if (checkBound(newHum, hum, diff)) {
hum = newHum;
// sensor 2
Serial.print("New humidity:");
Serial.println(String(hum).c_str());
client.publish(test_humidity_topic, String(hum).c_str(), true);
HA does not see this at all.
my yaml file:
mqtt:
broker: 192.168.0.187
password: !secret mqtt
discovery: true
discovery_prefix: homeassistant
port: 1883
client_id: home-assistant-1
TEST BOARD
sensor 1:
platform: mqtt
name: “Temperature”
state_topic: “sensor/test_temperature”
qos: 0
unit_of_measurement: “ºF”
sensor 2:
platform: mqtt
name: “Humidity”
state_topic: “sensor/test_humidity”
qos: 0
unit_of_measurement: “%”
sensor 5:
platform: mqtt
name: “Temperature”
state_topic: “/sensor/masterbed_temperature”
qos: 0
unit_of_measurement: ‘°F’
sensor 6:
platform: mqtt
name: “Humidity”
state_topic: “/sensor/masterbed_humidity”
qos: 0
unit_of_measurement: ‘%’
Please point me in the right direction with MQTT