brunohorta82 / EasyIot

Firmware Oficial OnOfre
https://onofre.store
MIT License
30 stars 16 forks source link

Improve Home Assistant MQTT integration #73

Closed jfmcarreira closed 2 years ago

jfmcarreira commented 4 years ago

Added device information in order to allow Home Assistant to create a new device under MQTT integration.

Moreover, each sensor should have a unique_id which was added too. This was tested with BHOnfre and BHPzem.

I have some concerts regarding the device information. This is how it is built:

void createDevJson(const JsonObject &root)
{
  JsonObject dev_object = root.createNestedObject("dev");
  JsonArray array = dev_object.createNestedArray("ids");
  array.add( String( getAtualConfig().chipId ) );
  dev_object["name"] = String( getAtualConfig().nodeId );
  dev_object["model"] = "BHOnfre EasyIot7";
  dev_object["sw"] = String( getAtualConfig().firmware );
  dev_object["mf"] = "Bruno Horta";
}

It would be interested if the field "model" could be able to differentiate between BH models, but I did not find any reference inside the code.