Help with mqtt

Tried alost everything but cant get mqtt values to show up. They report unknown now

I succeeded in getting a broker message from one window to an other.

mqtt settings:

sensor settings:

mqtt:
broker: 192.168.1.31
username: homeassistant
password: ********

  • platform: mqtt
    name: temperature
    state_topic: “/WeatherSensors/Environment - BMP085/180/Temperature”
    unit_of_measurement: “C”

trying to run it with espeasy:

Controller Settings

Controller Hostname: localhost
Controller Port: 1883
Controller User: homeassistant
Controller Password: •••••••••
Controller Subscribe: /%sysname%/#
Controller Publish: /%sysname%/%tskname%/%valname%

and the device setting in espeasy:

Task Settings
Device: Environment - BMP085/180 :grey_question:
Name: Sensor1
Enabled: yes
Altitude [m]: 0
Data Acquisition
Send to Controller ❶ IDX: 50
Send to Controller ❷
Delay: 60 [sec]

Values

Temperature %value%
Pressure %value%

In ESPeasy go to Advanced/logs and confirm that it’s connecting to the broker.

Then download MqttLens or something similar and confirm that you can see ESPEasy sending payloads on the topics you expect.

Is whatever you have ESPEasy installed on called ‘WeatherSensors’ under Config/Name ?

Also your device name should be in the state topic instead of the device type.
ie: Sensor1 instead of Environment…

Assuming your ESPEasy install is called WeatherSensors, your state_topic should be

/WeatherSensors/Sensor1/Temperature

I found out that when I call mosquitto -v there is an error:

1521053012: Error: Address already in use

When I then stop mosquitto and call mosquitto -v it says listening on ipv4 and ipv6 no error.

when I then start mosquitto and call mosquitto -v it gives the error that it is already in use.

You also might want to take a look at this:

Don’t use a leading forward slash
It is allowed to use a leading forward slash in MQTT, for example /myhome/groundfloor/livingroom. But that introduces a unnecessary topic level with a zero character at the front. That should be avoided, because it doesn’t provide any benefit and often leads to confusion.

Don’t use spaces in a topic
A space is the natural enemy of each programmer, they often make it much harder to read and debug topics, when things are not going the way, they should be. So similar to the first one, only because something is allowed doesn’t mean it should be used. UTF-8 knows many different white space types, it’s pretty obvious that such uncommon characters should be avoided.

tried some other stuffstill no go:

config:

mqtt:
broker: localhost
port: 1883
client_id: homeassistant
keepalive: 60

Replacing localhost by ip doesn’t work:

The error:

2018-03-16 22:44:36 ERROR (MainThread) [hbmqtt.broker] Broker startup failed: [Errno 98] error while attempting to bind on address (‘0.0.0.0’, 1883): address already in use
2018-03-16 22:44:37 ERROR (MainThread) [homeassistant.components.mqtt.server] Error initializing MQTT server
Traceback (most recent call last):
File “/usr/lib/python3.5/asyncio/base_events.py”, line 958, in create_server
sock.bind(sa)
OSError: [Errno 98] Address already in use

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/home/ha/homeassistant/lib/python3.5/site-packages/hbmqtt/broker.py”, line 275, in start
loop=self._loop)
File “/usr/lib/python3.5/asyncio/streams.py”, line 113, in start_server
return (yield from loop.create_server(factory, host, port, **kwds))
File “/usr/lib/python3.5/asyncio/base_events.py”, line 962, in create_server
% (sa, err.strerror.lower()))
OSError: [Errno 98] error while attempting to bind on address (‘0.0.0.0’, 1883): address already in use

During handling of the above exception, another exception occurred:

This means that something else is already using the port for mqtt. Most likely you have already started another mqtt broker.

And please format your yaml using the instructions in the link in the big blue box at the top of the page. Without that, many errors are impossible to spot.

The port is also used by Ubiquity Unify software in case you are running that.

started with a clean install:

It looks like the embedded broker is started:

2018-03-20 18:57:43 ERROR (MainThread) [hbmqtt.broker] Broker startup failed: [Errno 98] error while attempting to bind on address (‘0.0.0.0’, 1883): address already in use

But this shouldn’t from the config:

mqtt:
broker: 192.168.1.31
port: 1883
client_id: home-assistant-1
username: ha
password: ******
keepalive: 60

There may be an error in your indentation we can’t see until you format your yaml using the instructions in the link in the big blue box at the top of the page.

Eddited the message above.

If your config file is actually that way, the spacing is wrong.

Your state topic is wrong.
Refer to mine.

Upper screenshot is my MH-Z19 CO2 sensor.
You need the just the %valname% in the topic like the below.

Controller Subscribe: home/sensors/mhz19_livingroom/# (In fact, it doesn’t matter)
Controller Publish: home/sensors/mhz19_livingroom/%valname%

#I am using the embeded broker
mqtt:
sensor:

  • platform: mqtt
    state_topic: “home/sensors/mhz19_livingroom/co2”
    name: “MH-Z19 livingroom CO2”
    unit_of_measurement: “ppm”

  • platform: mqtt
    state_topic: “home/sensors/mhz19_livingroom/temp”
    name: “MH-Z19 livingroom Temperature”
    unit_of_measurement: “°C”

Fixed the indent now I got no errors about MQTT anymore.

1 Like

Played around with the publish settings and sensor declaration, it’s working now.