MQTT - Custom software trying to register with broker

Hi all,

I’m trying to implement MQTT support in my API for monitoring my solar array. I’ve been following this article / section and from what I understand, I’m doing exactly as it says.

First of all, my app submits a message onto the topic:
homeassistant/sensor/iconica_solar_pv_input_current_for_batteries/config
with the following payload:

{
  "device_class": "number",
  "name": "PV Input Current For Battery",
  "state_topic": "homeassistant/sensor/iconica_solar/state",
  "unit_of_measurement": "current",
  "value_template": "{{ value_json.pvInputCurrentForBattery }}",
  "unique_id": "pvinputcurrentforbatteries",
  "device": {
    "identifiers": [
      "pvInputCurrent"
    ],
    "name": "IconicaSolar"
  }
}

Then it submits a full payload to the homeassistant/sensor/iconica_solar/state topic:

{
  "pvInputVoltage": 53.1,
  "pvInputCurrentForBattery": 2,
  "pvTotalChargingPower": 69,
  "batteryVoltage": 24.7,
  "batteryChargingCurrent": 0,
  "batteryDischargeCurrent": 5,
  "batteryCapacity": 72,
  "acOutputVoltage": 240.1,
  "acOutputFrequency": 49.98,
  "acOutputPower": 181,
  "acOutputApparentPower": 240
}

I can see when listening for messages within Home Assistant that they are coming through, however when I try and view the “Devices” or “Entities” tab, I still can’t find anything related to my sensor.

Can anyone point me in the right direction please?

I’m using a self hosted version of an MQTT broker called Mosquitto (as suggested in the docs).

Thanks,
Owen

Ok, so typically when you post asking for help you end up finding the solution. I checked the logs and saw the “device_class” needed to be swapped with “UnitOfMeasurement”. After the code change I saw them instantly appear in Home Assistant.

The problem now, is that I now have 3 seperate devices for 3 different sensors when I’d like them grouped together. How should I structure the messages to do this?

Ok, solved the other issue. Turns out the “Device” object needs to be exactly the same across the sensors. After that I deleted the other sensors that were created and they all got grouped under the one.