Influxdb: assign tag based on sensor value

hi,

I am “fighting” with home assistant, influxdb and grafana
The target sounds easy but I am not able to get it right - even with the help of guys from Grafana:

Target: assign a tag to the measurements, based on sensor value so that in Grafana I could separate the graphs for devices depending on their communication type.
Full description: I have a device that exposes to HA the sensor called: sensor.devicename_communication_type
This sensor is text type - no unit there.
It can have values such as: “ESPnow”, “LoRa” or “WiFi”
So in Grafana I would like to have separate graph for (i.e.) RSSI fo:

  • WiFi devices
  • LoRa devices
  • ESPnow devices

Today I can only do it by filtering (manually) entity_id, provided I know which entity_id belongs to LoRa device, which to ESPnow and which to WiFi device.
But I would like to automate it, i.e. in Grafana query:
“show me RSSI values on the graph but ONLY for LoRa devices” - such query would have to understand that device (i.e.) “Kitchen device” that has value of sensor: “sensor.kitchen_communication_type” = “WiFi”
and for LoRa/ESPnow accordingly: “show me only devices that are LoRa/ESPnow”

But it seems neither influxdb nor grafana can do it unless the measurement is tagged (or at least nobody can help me how to build such query in influx).
So the natural suggestion would be: all measurements from “WiFi” device tag as “wifi” - this way the filter in the query would be easy.
But now: how to tell HA: “tag the measurements from WiFi devices as wifi in influxdb”?

I know - it sounds complicated but generally speaking it is not - it is just my lack of knowledge.
So maybe someone could help :wink:

thx.