Modifying Legend Labels Associated with InfluxDB query

I am using an InfluxDB query to populate legend labels on a graph. I would like to know how I may modify the legend label further after the query is executed. What workarounds are available in lieu of if-then logic for parsing the incoming legend label tag? In the image below, the time series are labeled with MAC addresses. I would like to give them more human readable labels such as “Sensor 1”. I must be able to associate target MAC addresses to specific labels. I may not be able to modify the database.

I think here’s a workaround that could provide the functionality that you are looking for; it’s a little bit repetitive but it gets the job done.

For each sensor that you have, make a unique query with the format:

SELECT "temperature" AS "*insert readable name here*" FROM "sensorreadings" WHERE "mac" = "*insert mac address here*" AND $timeFilter

and leave the Alias by option blank.
So, in your case, you would have 5 different queries.
I know this is not the ideal solution, but hey it works