HA and Mosquitto broker not comunicating?

I have hassos setup via virtualbox on a windows machine. I have added addon mosquitto broker with default settings.

i have another MQTT client which is sending messages to mosquitto broker via topic=homeassistant/sensor/voltronic_Battery_voltage

When i go to Developer Tools -> MQTT -> Listen to a topic and type the above topic and start listening i can see all the messages (as below)
/----------------------
Message 111 received on homeassistant/sensor/voltronic_Battery_voltage at 9:00 PM:
52.4
QoS: 0 - Retain: false
/-------------------

My problem is i am using this sensor in lovelace.yaml and it says on my Dashboard
/-----------
Entity not available: sensor.voltronic_Battery_voltage
/------------

Maybe i am missing a step. It seems like HA is not listening to the Mosquitto broker. Also i have not received any notification of this new sensor. any help appreciated. my skills are novice.

Thanks

How did you configure this sensor ? Did you create a sensor at all ?

no, i haven’t created a sensor, probably thats the step i was missing. how do i create one?

this is what i have in my lovelace yaml
/-----------------------
type: glance
- entity: sensor.voltronic_Battery_voltage
name: Battery Voltage (V)
type: sensor
show_header_toggle: false
/------------------------------------------

i am also passing topic = homeassistant/sensor/voltronic_Battery_voltage/config
which looks like
/--------------------------------------------------
Message 113 received on homeassistant/sensor/voltronic_Battery_voltage/config at 6:32 AM:

{
“name”: “voltronic_Battery_voltage”,
“unit_of_measurement”: “V”,
“state_topic”: “homeassistant/sensor/voltronic_Battery_voltage”,
“icon”: “mdi:battery-outline”
}

QoS: 0 - Retain: true
/----------------------------------------------------

That message 114 seems a valid mqtt auto-discovery message, but it will create a sensor.voltronic_battery_voltage not sensor.voltronic_Battery_voltage

ok, makes sense. i have updated my client to send the topic in all lowercase, i can see Mosquitto broker can listen (Screenshot below)

I have also updated my lovelace.yaml to use sensor in lowercase i.e. sensor.voltronic_battery_voltage

Its still not doing anything, I am getting message “Entity not available: sensor.voltronic_battery_voltage” on my dashboard. I dont see any new entitiy / sensor created in HA.
I know Mosquitto broker is receiving my messages, i am not sure why HA is not listening to them. do i need to use a specific user/pass? currently i am using the same credential i use to login to HA. Or is there another configuration or step i need to do in HA to get it to listen to the MQTT?

Also if i have to manually create the sensor based on above config, how do i go about, is it done in configuration.yaml?

In configuration.yaml under sensor: (or if you have in configuration.yaml sensor: !include sensor.yaml in sensor.yaml)

  - platform: mqtt
    name: "voltronic_battery_voltage"
    state_topic: "homeassistant/sensor/voltronic_battery_voltage"
    unit_of_measurement: 'V'
1 Like

Thanks @francisp for your help with my sensor settings in configuration file. It worked. Thanks again