Configuring a second thermometer

I am finishing my integration with ANAVI Thermometer, so I can switch the control of the temperature when we go to sleep (it is already placed in our bedroom).

I have successfully created a MQTT generic thing for the thermometer, added the channels for Anavi’s temperature and humidity, and linked two new items, AnaviTemp and AnaviHumi. I have created an additional item ThermometerSwitch for selecting the leading sensor, with two possible values: Anavi and My for HestiaPi (so I can get easily to AnaviTemp and MyTemp)

Finally, I have successfully modified the Process Sensor Changes rule (following @rlkoshak comprehensive How to customize a rule guide), adding AnaviTemp changed and AnaviHumi changed to triggers, and modifying the logic this way:

var OPENHAB_CONF = Java.type('java.lang.System').getenv('OPENHAB_CONF');
load(OPENHAB_CONF + '/automation/lib/hestia/utils.js');
load(OPENHAB_CONF + '/automation/lib/hestia/defaults.js');

var process = true;
var logName = "sensor";
var device;

logDebug(logName, "Changed "+event.itemName);

if (event.itemName.indexOf("Anavi") == 0) {
  if (items["ThermometerSwitch"] != "Anavi") {
    process = false;
  } else {
    device = event.itemName.replace("Anavi", "");
  }
} else {
  if (items["ThermometerSwitch"] != "My" && event.itemName != "MyPressure") {
    process = false;
  } else {
    device = event.itemName.replace("My", "");
  }
}

if (process) {
  // Update the proxy
  events.sendCommand("My"+device+"Proxy", newState);

  // Verifying the newState can be parsed is already checked in the but only if...
  var newReading = parseFloat(newState.toString());


  var prev = items["Previous"+device+"Reading"].floatValue();
  if(prev == NaN) prev = 0;

  var hyst = (device == "Temp") ? DEFAULTS.get("Temp"+items["TempUnit"]+"_DIFF") : DEFAULTS.get(device+"_DIFF");

  logDebug(logName, "Processing " + device + " with value " + newState + " and prevState " + prev + " and delta " + delta);
  var delta = Math.abs(newReading - prev);
  if(delta > hyst) {
    logDebug(logName, "Updating Previous"+device+"Reading with " + newState);
    events.postUpdate("Previous"+device+"Reading", newState);
  }
  else {
    logDebug(logName, "Ignoring " + device + " sensor reading, change is too small");
  }
} else {
  logDebug(logName, "Skipping "+event.itemName+", ThermometerSwitch is "+items["ThermometerSwitch"]);
}

Everything works great!.. but. When I switch ThermometerSensor to Anavi, the readings in the Hestia touch display follow Anavi’s instead of Hestia’s. It seems the code above (probably MyTempProxy publishes the readings to the MQTT topic (instead of MyTemp maybe, which is the item from the sensor?)

I am following a correct path? Is this the right point for the modifications or I should take a different approach?