MQTTController map different values from same topic?
-
This would be done the same way as mapping any other topic to an entity. I'm... not sure what the question is.
-
I have multiple sensors connected to via Bluetooth to a Tasmota device.
All sensors report their values in theSENSOR
topic, how do I map those to individual entities?@Crille I do not use the MSR (yet!
), but I do have a Tasmota device reporting three Xiaomi Mi BLE devices to OpenLuup over Mqtt.
They report the following:
{"Time":"2021-11-24T16:00:25","ATC-6d5d44":{"Temperature":20.6,"Humidity":48.0,"DewPoint":9.2,"Battery":76,"RSSI":-89},"ATC-9446bf":{"Temperature":19.6,"Humidity":52.0,"DewPoint":9.5,"Battery":42,"RSSI":-84},"ATC-f159bf":{"Temperature":19.6,"Humidity":55.0,"DewPoint":10.3,"Battery":45,"RSSI":-84},"TempUnit":"C"}
on the following topic:
tele/TasmotaBLE/SENSOR
The message contains all three devices each under their name.
Not sure how about the syntax in MSR but in e.g. Home Assistant you write something in this direction in the config.yaml to retrieve the temperature for one device.
- platform: mqtt name: "Temperatur" state_topic: "tele/TasmotaCO2Ax/SENSOR" value_template: "{{value_json['ATC-6d5d44'].Temperature}}" device_class: temperature unit_of_measurement: "°C"
-
There are templates documented for Tasmota devices reporting temperature, humidity, and battery. Any of them can be used as a model for dewpoint if that's needed. You set
source
in the entity configuration to pick which sensor (e.g.source: ATC-6d5d44
orsource: ATC-9446bf
), like this:temp_sensor_1: name: "Tasmota XXXX sensor 1" topic: "tasmota_FFFFFF" uses_template: tasmota_temperature_humidity source: ATC-9d5d44 temp_sensor_2: name: "Tasmota XXXX sensor 2" topic: "tasmota_FFFFFF" uses_template: tasmota_temperature_humidity source: ATC-9446bf etc...
-
The issue is that the sensors do not report at the same time, one publish contains one or two devices and when
source
id is not found it's setting null values.
Lets say I usesource
LYWSD03aa6def17:19:25.359 MQT: tele/Växthuset/SENSOR = {"Time":"2021-11-24T17:19:25","LYWSD03aa6def":{"mac":"a4c138aa6def","Temperature":7.0,"Humidity":98.0,"DewPoint":6.7,"Battery":24,"RSSI":-71},"Flora6cabfa":{"mac":"c47c8d6cabfa","Temperature":7.8,"Illuminance":265,"Moisture":20,"Fertility":85,"RSSI":-86}} 17:19:26.372 MQT: tele/Växthuset/SENSOR = {"Time":"2021-11-24T17:19:26","Flora6cab88":{"mac":"c47c8d6cab88","Temperature":8.6,"Illuminance":167,"Moisture":0,"Fertility":0,"RSSI":-81}} 17:19:37.399 MQT: tele/Växthuset/SENSOR = {"Time":"2021-11-24T17:19:37","Switch1":"ON","Switch2":"ON","ENERGY":{"TotalStartTime":"2021-05-04T07:45:50","Total":0.000,"Yesterday":0.000,"Today":0.000,"Period":[ 0, 0],"Power":[ 0, 0],"ApparentPower":[ 0, 0],"ReactivePower":[ 0, 0],"Factor":[0.00,0.00],"Frequency": 0,"Voltage": 0,"Current":[0.000,0.000]},"ESP32":{"Temperature":40.0},"TempUnit":"C"}
It maps the temperature and humidity on the first tele but applies null on the next ones.
Also, what to put in
init
? -
T toggledbits locked this topic on