Creating devices in home assistant with lora gateway

Hello,

I am working to integrate a sensor emitting LoRa messages to home assistant.
The default model seems to manually define a collection of MQTT sensors in home assistant (for instance this project which uses the same moisture sensor I have).

Situation gets a bit more complex when using OMG for multiple sensors. The link above suggest to define sensor that filter values:

value_template: >-
    {% if (value_json.message|from_json).name == "Soil_1" %}
      {{ (value_json.message|from_json).hum }}
    {% else %}
      {{ states("sensor.soil_1_Humidity") }}
    {% endif %}

This is quite tedious (it has to be done once per sensor value and per sensor). My understanding is that this happens because the LoRa gateway in OMG does not uses different MQTT channel per LoRa “device”.

I also understand LoRa does not naturally identify messages emitters (which bluetooth does for instance using their mac address). So OMG cannot distinguish emitters unless they all follow some convention in the message they send.

I’d like to know what are your ideas regarding this issue which can be formulated in different manners:

  • how to automatically create distinct devices in home assistant when data comes from LoRa gateway
  • how to distinguish devices at OMG level when using LoRa gateway
1 Like

Hello,

That’s an interesting question, that’s good to took the BLE gateway behavior as a comparison.

I think a device identifier could be added by the sender, id:01 for example
and we could add this id at the end of the topic like we do for BLE
So for id:01 the payload would be published into:
home/OpenMQTTGateway/LORAtoMQTT/01

At one point in time we could even have auto-discovery leverage by the LORA gateway.

Fully agreed with this. I don’t know if there already exist some convention to do this. Otherwise I wonder how lora gateways deal with with several sensors.

Are you talking about the lora gateway guessing format used by sender and sending home assistant auto discovery information about sensors? That would be great!

In the meantime, I’ve setup a simple services listening on MQTT messages sent by the LoRa gateway and sending properly formatted MQTT message to home-assistant. This allows to quickly improve devices description exposed in home-assistant.