I’m looking to see if there is a way to disable mqtt posting on a per sensor basis. I’ve tried to see if the answer has been asked or if it was in the documentation and haven’t found an answer.
mqtt:
broker: !secret mqtt_broker
topic_prefix: esphome/test
log_topic:
topic: debug
level: WARN
sensor:
- platform: dht
pin: D4
model: DHT11
temperature:
name: "Living Room Temperature"
id: dht_t
filters:
- lambda: return x * (9.0/5.0) + 32.0;
unit_of_measurement: "°F"
humidity:
name: "Living Room Humidity"
id: dht_h
update_interval: 60s
- platform: adc
pin: VCC
id: vcc
name: "VCC Voltage"
- platform: adc
pin: A0
name: "ESP-2 Gas ADC"
id: gas_adc
update_interval: 60s
filters:
- multiply: 100
unit_of_measurement: "%"
icon: "mdi:percent"
binary_sensor:
- platform: gpio
id: pir
name: "PIR Motion"
device_class: motion
pin:
number: D6
mode:
input: true
- platform: gpio
id: photoresistor
name: photoresistor
device_class: light
pin:
number: D5
mode:
input: true
- platform: gpio
pin:
number: D3
mode:
input: true
name: "Home Multisensor Motion"
id: milimeterwave_motion
device_class: motion
filters:
- lambda: return x * 0.004882814;
text_sensor:
- platform: wifi_info
ip_address:
name: ESP IP Address
id: ip
mac_address:
name: ESP Mac Wifi Address
id: mac
interval:
- interval: 60s
then:
- mqtt.publish_json:
topic: !lambda |-
return "esphome/sensor/" + id(mac).state;
payload: |-
root["name"] = "test";
root["mac_address"] = id(mac).state;
root["ip_address"] = id(ip).state;
root["dht_temperature"] = id(dht_t).state;
root["dht_temperature_uom"] = "°F";
root["dht_humidity"] = id(dht_h).state;
root["dht_humidity_uom"] = "%";
root["photoresistor"] = id(photoresistor).state;
root["vcc"] = id(vcc).state;
root["gas_adc"] = id(gas_adc).state;
In this example I would like the interval and the motion detection to be published to mqtt but the other sensor to not publish (as they would be a duplicate of the interval publishing). Is this possible?