Stuck getting mqtt / miscale to work

Hi,

I appreciate some help, as I am stuck trying to get my new Mi Scale to work. I installed miscale and mosquitto. It looks like the connection between miscale and mqtt is working fine.
The miscale log states:

2021-11-18 02:22:16 - Starting Xiaomi mi Scale...
2021-11-18 02:22:16 - Loading Config From Add-On Options...
2021-11-18 02:22:16 - Config Loaded...
2021-11-18 02:22:53 - Publishing data to topic miscale/Bjorn/weight: {"weight":XX.00,"weight_unit":"kg","bmi":XX.09,"basal_metabolism":XXXX.07,"visceral_fat":XX.78,"timestamp":"2021-11-18 02:22:53.058659"}
2021-11-18 02:22:53 - Data Published ...
2021-11-18 09:14:53 - btle disconnected: Device disconnected

So that looks good to me. Even the right user is identifiey by the weight. Also the mosquitto log looks good to me:

1637252878: New connection from 192.168.42.11 on port 1883.
1637252878: New client connected from 192.168.42.11 as auto-E99A6C92-1692-0DC7-D935-D00EC9D34659 (p2, c1, k60, u'mqtt').
1637252878: Client auto-E99A6C92-1692-0DC7-D935-D00EC9D34659 disconnected.

So I added this as sensor to my configuration.yaml:

  - platform: mqtt
    name: "Gewicht Bjorn"
    state_topic: "miscale/Bjorn/weight"
    value_template: "{{ value_json['weight'] }}"
    unit_of_measurement: "kg"
    json_attributes_topic: "miscale/Bjorn/weight"
    icon: mdi:scale-bathroom

The sensor is initiated, but never populated. So I assume it has something to do with mqtt, but I have no experience and dont even know what to look for.
This are my mosquitto settings:

logins:
  - username: mqtt
    password: ***
customize:
  active: true
  folder: mosquitto
certfile: fullchain.pem
keyfile: privkey.pem
require_certificate: false

And finally I configured the mqtt integration settings to

Broker: 192.168.42.11
Port: 1883
User: mqtt
Password: **** 

Thanks for your help in advance!

And yes, I created the user mqtt with the respective password in HA.

Try this in your sensor:

value_template: "{{ value_json.weight }}"

Unfortunately no noticeable difference :frowning:

Any errors in the logs? Did you setup the mqtt integration through the UI?

Yes, in general logs there is an error:

21-11-18 18:56:34 ERROR (MainThread) [supervisor.services.modules.mqtt] There is already a MQTT service in use from core_mosquitto

I installed mqtt only through the UI, I did not enter anything into the configuration.yaml.

Where did you install mosquitto?

I dont quite understand the question… I am running normal hassio and installed mosquitto via the official Add-on store.

The above error seems to be gone after a proper restart of the host.

I thought you maybe installed it in two places.

Did you try using a tool like MQTT explorer to see if everything is working?

Your thought was right. After not getting complains about the code, I completely deinstalled mqtt and miscale including host reboots. I think I missed those before and had some historic mqtt stuff still on board. After reinstalling, I got away with just standard settings. So thanks for your help, works now.

1 Like