Temperature (degree) bug

Home assistant don’t get correct unit, this resolves in it not showing up in homekit.
As an example, this is the same for all location where unit is missing ° sign.

Current implementation, not working, "C"}, is the intresseting part

void MiJiaDiscovery(char* mac) {
#    define MiJiaparametersCount 5
  Log.trace(F("MiJiaDiscovery" CR));
  char* MiJiasensor[MiJiaparametersCount][8] = {
      {"sensor", "MiJia-batt", mac, "battery", jsonBatt, "", "", "%"},
      {"sensor", "MiJia-tem", mac, "temperature", jsonTempc, "", "", "C"}, // remove for 0.9.6 release
      {"sensor", "MiJia-tempc", mac, "temperature", jsonTempc, "", "", "C"},
      {"sensor", "MiJia-tempf", mac, "temperature", jsonTempf, "", "", "F"},
      {"sensor", "MiJia-hum", mac, "humidity", jsonHum, "", "", "%"}
      //component type,name,availability topic,device class,value template,payload on, payload off, unit of measurement
  };

  createDiscoveryFromList(mac, MiJiasensor, MiJiaparametersCount);
}

Tested to replace "C"}, with "°C"}, (and "F"}, with "°F"}, and now it works flawless

void MiJiaDiscovery(char* mac) {
#    define MiJiaparametersCount 5
  Log.trace(F("MiJiaDiscovery" CR));
  char* MiJiasensor[MiJiaparametersCount][8] = {
      {"sensor", "MiJia-batt", mac, "battery", jsonBatt, "", "", "%"},
      {"sensor", "MiJia-tem", mac, "temperature", jsonTempc, "", "", "°C"}, // remove for 0.9.6 release
      {"sensor", "MiJia-tempc", mac, "temperature", jsonTempc, "", "", "°C"},
      {"sensor", "MiJia-tempf", mac, "temperature", jsonTempf, "", "", "°F"},
      {"sensor", "MiJia-hum", mac, "humidity", jsonHum, "", "", "%"}
      //component type,name,availability topic,device class,value template,payload on, payload off, unit of measurement
  };

Was thinking of doing a PR, but not sure if this will break some other integration.

Thanks for pointing that, you can submit a PR. Maybe just verify that the ° is transmitted by mqtt.

Interesting, I did about the same


void LYWSD03MMCDiscovery(char* mac) {
#    define LYWSD03MMCparametersCount 5
  Log.trace(F("LYWSD03MMCDiscovery" CR));
  char* LYWSD03MMCsensor[LYWSD03MMCparametersCount][8] = {
      {"sensor", "LYWSD03MMC-batt", mac, "battery", jsonBatt, "", "", "%"},
      {"sensor", "LYWSD03MMC-volt", mac, "", jsonVolt, "", "", "V"},
      {"sensor", "LYWSD03MMC-tempc", mac, "temperature", jsonTempc, "", "", "°C"},
      {"sensor", "LYWSD03MMC-tempf", mac, "temperature", jsonTempf, "", "", "F"},
      {"sensor", "LYWSD03MMC-hum", mac, "humidity", jsonHum, "", "", "%"}
      //component type,name,availability topic,device class,value template,payload on, payload off, unit of measurement
  };

  createDiscoveryFromList(mac, LYWSD03MMCsensor, LYWSD03MMCparametersCount);
}

(I don’t care about F, so I did not change that :slight_smile: )

They would have a separate graph with the other temp sensor I have in HA otherwise, and not merge nicely in influxdb/grafana.

when using “°C” Home assistant seems to fix correct temperature for the unit systems configured on home assistant (metric or imperial), see pr comment.

Edit: Don’t know if other systems does otherwise