From another sensor I would receive a similar one, but, of course, the SensorID field would be different, i.e. “22:22:22:22:22:22:22:22”.
My question is this: What is the best way to separate them so they will become separate sensors in HA?
so far I experimented with something like this:
- name: Solar heater
state_topic: "viktak/spiti/esp-now-bridge/tele"
value_template: >
{%- if value_json["Measurement"]["SensorID"]=="11:11:11:11:11:11:11:11" %}
{{ value_json["Measurement"]["Value"] }}
{% endif -%}
The problem is, that while when a new value arrives from SensorID “11:11:11:11:11:11:11:11”, it gets displayed correctly, when another one sends its data, this value template evaluates to an empty string, erasing the value from my dashboard.
Is there a way to separate data from different SensorIDs into different mqtt sensors?
The issue here is that the data published to viktak/spiti/esp-now-bridge/tele
is multiplexed. In other words, one topic is used to transmit data for multiple devices.
The simplest technique is to demultiplex the data. Create an automation that receives the data and re-publishes it to separate topics, one topic per device. Now each device can listen to its own dedicated topic and receive data that is exclusively meant for it.
I have offered this solution to several other users, here’s one example that demonstrates the concept:
Here’s a more complex example:
For your application, the automation would look like this: