I’m trying to use the platform: mqtt to capture temp/humidity sensor values via MQTT. The device the temp/humidity sensor is connected to runs the latest Tasmota release.
I configured the mqtt platform in configuation.yaml (following MQTT Sensor - Home Assistant) but I’m stuck in adding this sensor to lovelace; i.e. the mapping from MQTT payload to entity. What entity am I looking for in lovelace?
btw I’m using the Tasmota integration in Home Assistant
The issue is I have 3 ESP32 around the house running Tasmota but I have no control over which ESP32 picks up which sensor. Say ESP32#1 picks up temp sensor#1. I go and update the entity IDs based on my rules and add them to lovelace. All good.
If an ESP restarts for whatever reason another ESP might pick up sensor#1 and the entity IDs set initially suddenly become unavailable.
I don’t understand how that can happen. I have 9 sonoff/nodemcu devices, 4 with temperature sensors. All of the sensor ID’s/entity id’s include that device name and are thus unique.
This is what I’m doing, maybe I’m going wrong somewhere.
I’m using Xiaomi BLE temp/humidity sensors (LYWSD03MMC) running the custom firmware (ATC). Say one of the sensors MAC ends in 52:DE. Starting ESP#1 I see 52:DE. 52:DE might be in range for ESP#2 as well.
With the Tasmota integration on Home Assistant the sensor entities for 52:DE appear in both devices (ESP#1 and ESP#2). I take the nearest ESP (based on signal) and change the entity ID according to my entity model and leave the other ESPs entity IDs unchanged.
The changed entity IDs go to lovelace. Coming back to lovelace after a while I might find an entity ID unavailable and when I go to the Tasmota device it’s gone even though the entity ID is still available on the other Tasmota device.
Do you have situations where a sensor appears in multiple ESPs?
I’m using ESP32s as BLE gateway devices. The ESP32 picks up the Xiaomi sensor data via BLE and the ESP32 makes this data available to Home Assistant. I thought I hit the jackpot when I found the Tasmota integration in Home Assistant making this an easy process.
For example on TMR04 I see these 3 sensors. As long as there’s Bluetooth coverage I might see 52:DE on another ESP as well and as a result get multiple entity IDs in Home Assistant from the same sensor.
Ah! So you must pair the sensor with an ESP or are you pairing them with all esp’s seperately? I would suspect the latter in which case there is some duplication?
I am not familiar with this BLE gateway though.
I do have a similar problem with my fuel station pricing sensor whereby all entities are randomly allocated a name which is a PITA for the exact same reason but I can get around it as there is some unique data I can use with a template sensor to sort out the mess… maybe you can as well?
There’s no pairing involved with BLE. ESP32’s have a Bluetooth stack which can be used to “listen” to BLE traffic and once known to Tasmota it then can be integrated into Home Assistant via MQTT or the new Tasmota integration on Home Assistant - until you have more than 1 ESPs
What ends up happening is I get entitiy IDs as follows: tasmota_16cdac_sensor, tasmota_16cdac_sensor_1, tasmota_16cdac_sensor_2 and so on with state unknown in lovelace and no state history.
Further to my post above I have restarted mosquitto on HA and checked the log. Two things to note:
There’s a message about not being able to setup the mqtt service
[services.d] starting services
[services.d] done.
[09:45:39] INFO: Setup mosquitto configuration
[09:45:39] INFO: No local user available
[09:45:39] INFO: Initialize Home Assistant Add-on services
[09:45:39] ERROR: Can't setup Home Assistant service mqtt
[09:45:39] INFO: Initialize Home Assistant discovery
[09:45:39] INFO: Start Mosquitto daemon
The ESP in question above does indeed connect to the broker
1620431149: New connection from 192.168.2.70 on port 1883.
1620431149: New connection from 192.168.2.171 on port 1883.
1620431149: New client connected from 192.168.2.70 as DVES_16CDAC (p2, c1, k30, u'mqttuser').
I used mqtt.fx to connect to the HA broker and subscribed to the topic of 2.70; i.e. tasmota_16cdac/SENSOR to see whether sensor data is transmitted and I can see the correct payload.