MQTT connection lost

mqtt
mqtt-binding
mqttsonoff
Tags: #<Tag:0x00007fe05d8fe928> #<Tag:0x00007fe05d8fe748> #<Tag:0x00007fe05d8fe5e0>

(Angelos) #27

so… did the mosqsub|1730-openHABian dissapear?


(Angelos) #28

no response from what? (OH2 or the Sonoff?)

post your item config to check it


(Peter) #29

yes! (for now?)

EDIT: NO!

1500719565: New connection from 127.0.0.1 on port 1883.
1500719565: New client connected from 127.0.0.1 as openHAB2 (c1, k60).
1500720088: New connection from 127.0.0.1 on port 1883.
1500720088: New client connected from 127.0.0.1 as mosqsub|7105-openHABian (c1, k60).
1500720244: New connection from 192.168.178.160 on port 1883.

still no communication with openHAB2 ?

[12:34:38] openhabian@openHABianPi:~$ mosquitto_sub -v -t 'tele/#' -t 'stat/#'
tele/sonoff/LWT Online
stat/sonoff/RESULT {"POWER":"OFF"}
stat/sonoff/POWER OFF
tele/sonoff/STATE {"Time":"2017-07-22T11:43:00", "Uptime":3, "Vcc":3.204, "POWER":"OFF", "Wifi":{"AP":1, "SSID":"NETGEAR47", "RSSI":32, "APMac":"80:2A:A8:4A:C7:AC"}}

thoughts: if the TOPIC is “sonoff1”, my item should be:

Switch Sonoff_TH16A "Sonoff Test" <light>
    { mqtt=">[broker:cmnd/sonoff1/POWER:command:*:default],
            <[broker:stat/sonoff1/POWER:state:default]" }

right?

'til now i have used the client id of the sonoff device…

changing (correcting) the item doesn’t help, still no signs in openhab.log…


(Paulo Wang) #30

[quote=“Dim, post:28, topic:31993”]
no response from what? (OH2 or the Sonoff?)
[/quote] no response from Sonoff. I don’t know how to see if could be any chance on OH2. But the log is below:

2017-07-22 07:23:49.078 [INFO ] [penhab.io.transport.mqtt.MqttService] - MQTT Service initialization completed.
2017-07-22 07:23:49.083 [INFO ] [t.mqtt.internal.MqttBrokerConnection] - Starting MQTT broker connection 'raspberrypi’
2017-07-22 07:23:49.619 [INFO ] [ui.habmin.internal.servlet.HABminApp] - Started HABmin servlet at /habmin
2017-07-22 07:23:49.921 [INFO ] [panel.internal.HABPanelDashboardTile] - Started HABPanel at /habpanel
2017-07-22 07:23:50.023 [WARN ] [mqtt.internal.MqttPersistenceService] - mqtt-persistence:topic
2017-07-22 07:23:50.026 [WARN ] [mqtt.internal.MqttPersistenceService] - mqtt-persistence:message

the sonoff.item:

Switch Abajur_light “Abajur” (LR, gLight)
{ mqtt=">[raspberrypi:cmnd/sonoff-abajur/POWER:command:ON:on], >[raspberrypi:cmnd/sonoff-abajur/POWER:command:OFF:off],
<[raspberrypi:stat/sonoff-abajur/POWER:state:default]" }


(Paulo Wang) #31

When I tried to move the switch at OH2, I got the following message:

2017-07-22 07:56:06.192 [ERROR] [ui.internal.items.ItemUIRegistryImpl] - Cannot retrieve item for widget org.eclipse.smarthome.model.sitemap.Text
2017-07-22 07:56:06.207 [ERROR] [ui.internal.items.ItemUIRegistryImpl] - Cannot retrieve item ‘Abajur’ for widget org.eclipse.smarthome.model.sitemap.Switch
2017-07-22 07:56:06.211 [ERROR] [ui.internal.items.ItemUIRegistryImpl] - Cannot retrieve item ‘Abajur’ for widget org.eclipse.smarthome.model.sitemap.Switch
2017-07-22 07:56:06.215 [ERROR] [ui.internal.items.ItemUIRegistryImpl] - Cannot retrieve item for widget org.eclipse.smarthome.model.sitemap.Switch
2017-07-22 07:56:06.244 [WARN ] [ui.internal.items.ItemUIRegistryImpl] - Exception while formatting value ‘93.25861’ of item LivingRoom_Light_RSSI with format ‘%d %%’: java.util.IllegalFormatConversionException: d != java.math.BigDecimal


(Angelos) #32

:frowning:
anything useful with lsof -i :1883 ?
or ps -efwww |grep 7105 (that seems to be the process id)

checking your item now…
for starters, change broker to mqttson :slight_smile:
edit: check examples from here:

it should be something like:

Switch Sonoff_TH16A "Sonoff Test" <light> { mqtt=">[mqttson:cmnd/sonoff/power:command:*:default], <[mqttson:stat/sonoff1/power:state:default]" }

( ) #33

Hello, jumping in here because of the mentioning before.

Pay attention to the first topic level: cmnd vs. stat - that’s something I personally don’t like about the Tasmota default settings. This order can btw be changed in settings.
The config is in sync with what I’ve given as a template here.

Sooo from what I’ve read we are looking at two problems here. Why is there an additional connection with the clientID mosqsub|1234-openHABian and why is your openHAB not able to receive states and send commands.

  1. The additional connection is not present on my system
  2. @narf27 looking at this posting your setup is simply wrong. The topic name of your module is “sonoff”, you are subscribing to “sonoff1”. Change the topic of your module before adding it to openHAB! Also just as @Dim said, you need to use the right broker name. Please check your setup against this article: https://github.com/arendst/Sonoff-Tasmota/wiki/openHAB#requirements

(Angelos) #34

this is driving me crazy :slight_smile:

anyway this thread is a mess with 2 different setups that we are trying to debug :stuck_out_tongue:

edit: You are right… I didn’t see the first topic level :slight_smile:


( ) #35

Example setup Click to see fill image

–> Added to the Tasmota wiki

And the corresponding items configuration:

Switch BK_Balkonmagic "Balkonmagic" <stars> (BK,gLight)                           {mqtt=">[broker:tasmota/sonoff-A00EEA/cmnd/POWER:command:*:default], <[broker:tasmota/sonoff-A00EEA/stat/POWER:state:default]"}
Number BK_Balkonmagic_RSSI "Balkonmagic RSSI [%d %%]" (gRSSI)                     {mqtt="<[broker:tasmota/sonoff-A00EEA/tele/STATE:state:JSONPATH($.Wifi.RSSI)]"}
Switch BK_Balkonmagic_Unreach "Balkonmagic unreachable" <siren> (gUnreach)        {mqtt="<[broker:tasmota/sonoff-A00EEA/tele/LWT:state:MAP(unreach.map)]"}

(Paulo Wang) #36

@ThomDietrich , mine is quite the same. How is your Topic/ Full topic configuration??


( ) #37

Click the image :slight_smile:


(Paulo Wang) #38

@ThomDietrich thank you! Mine configuration is the same!!! :slight_smile:


(Angelos) #39

@paulo9999 : you have some errors in your sitemap file

your item is defined as Abajur_light but your sitemap is complaining about an item named Abajur

post your items and sitemap contents to be checked :slight_smile:


(Paulo Wang) #40

@Dim:

thank you, sorry for this slight mistake, I’ve corrected it, now sitemap is ok but unfortunately things still isn’t working…

Paulo


(Angelos) #41

is anything useful in the logs?
read again the examples that Thom posted, You will get it working :slight_smile: (it seems that your broker connection is fine)


(Peter) #42
[19:34:12] openhabian@openHABianPi:~$ lsof -i :1883
COMMAND    PID       USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
mosquitto 7105 openhabian    5u  IPv4  21570      0t0  TCP localhost:40962->localhost:1883 (ESTABLISHED)

ANYWAY… these are my settings now:
sonoff device TH16:

Client Id = OH2MQTT
Topic = sonoff1
Full Topic = tasmota/%topic%/%prefix%/

items (according to @ThomDietrich) :

Switch Sonoff_TH16A "Balkonmagic" <stars>                            {mqtt=">[broker:tasmota/sonoff1/cmnd/POWER:command:*:default], <[broker:tasmota/sonoff1/stat/POWER:state:default]"}
Number Sonoff_TH16A_RSSI "Balkonmagic RSSI [%d %%]"                  {mqtt="<[broker:tasmota/sonoff1/tele/STATE:state:JSONPATH($.Wifi.RSSI)]"}
Switch Sonoff_TH16A_Unreach "Balkonmagic unreachable" <siren>        {mqtt="<[broker:tasmota/sonoff1/tele/LWT:state:MAP(unreach.map)]"}

mqtt.cfg:

[19:59:02] openhabian@openHABianPi:~$ cat /var/lib/openhab2/config/org/openhab/mqtt.config
mqttson.clientId="openHAB2"
mqttson.url="tcp://127.0.0.1:1883"
service.pid="org.openhab.mqtt"

( ) #43

So… does it work?

I feel like both of you should take a step back. For example in your posting the Client Id = OH2MQTT - Do you know what this means? Your setting doesn’t make much sense, you should just leave it with the default setting. Next your Topic setting. Why sonoff1? Give it a meaningful name, something you can work with (e.g. “sonoff-coridorlight”, not too long, no underscore).

Your config looks okay. You can again leave the client Id setting commented to have a random one generated. I take it your broker doesn’t provide authentication? If you’ve installed via openHABian setting up a password was offered.

After you’ve set up everything do a test. You could for example restart openHAB, then wait a few minutes and check the log for mqtt related messages. It should look similar to this one:

[21:22:34] openhabian@openHABianPiW66a:~$ grep "mqtt" /var/log/openhab2/*
/var/log/openhab2/openhab.log:2017-07-22 16:52:19.891 [INFO ] [penhab.io.transport.mqtt.MqttService] - MQTT Service initialization completed.
/var/log/openhab2/openhab.log:2017-07-22 16:52:19.893 [INFO ] [t.mqtt.internal.MqttBrokerConnection] - Starting MQTT broker connection 'broker'
/var/log/openhab2/openhab.log:2017-07-22 17:13:40.344 [INFO ] [penhab.io.transport.mqtt.MqttService] - Stopping broker connection 'broker'
/var/log/openhab2/openhab.log:2017-07-22 17:15:24.084 [INFO ] [penhab.io.transport.mqtt.MqttService] - MQTT Service initialization completed.
/var/log/openhab2/openhab.log:2017-07-22 17:15:24.089 [INFO ] [t.mqtt.internal.MqttBrokerConnection] - Starting MQTT broker connection 'broker'


(Peter) #44

sadly it doesn’t
Client id - it’s the id i’m connecting to the broker?
which part of the (mqtt.cfg?) setting doesn’t make sense?

why sonoff1? because for now i have two sonoff devices and this is the one i’m testing with (i’m not sure where the device will be installed later, so a meaningful name would be hard to find)

[quote=“ThomDietrich, post:43, topic:31993”]
Your config looks okay. You can again leave the client Id setting commented to have a random one generated. I take it your broker doesn’t provide authentication? If you’ve installed via openHABian setting up a password was offered.
[/quote]didn’t set auth.

reboot:

2017-07-22 23:28:41.980 [ERROR] [t.mqtt.internal.MqttBrokerConnection] - MQTT connection to broker was lost
        at org.eclipse.paho.client.mqttv3.internal.CommsReceiver.run(CommsReceiver.java:146)[197:org.openhab.io.transport.mqtt:1.10.0]
        at org.eclipse.paho.client.mqttv3.internal.wire.MqttInputStream.readMqttWireMessage(MqttInputStream.java:65)[197:org.openhab.io.transport.mqtt:1.10.0]
        at org.eclipse.paho.client.mqttv3.internal.CommsReceiver.run(CommsReceiver.java:107)[197:org.openhab.io.transport.mqtt:1.10.0]
2017-07-22 23:28:41.998 [ERROR] [t.mqtt.internal.MqttBrokerConnection] - MQTT connection to 'mqttson' was lost: Connection lost : ReasonCode 32109 : Cause : null
2017-07-22 23:28:41.999 [INFO ] [t.mqtt.internal.MqttBrokerConnection] - Starting connection helper to periodically try restore connection to broker 'mqttson'
2017-07-22 23:28:52.002 [INFO ] [t.mqtt.internal.MqttBrokerConnection] - Starting MQTT broker connection 'mqttson'
2017-07-22 23:28:55.288 [INFO ] [penhab.io.transport.mqtt.MqttService] - Stopping broker connection 'broker'
2017-07-22 23:28:55.289 [INFO ] [penhab.io.transport.mqtt.MqttService] - Stopping broker connection 'mqttson'
2017-07-22 23:30:04.375 [INFO ] [penhab.io.transport.mqtt.MqttService] - MQTT Service initialization completed.
2017-07-22 23:30:04.387 [INFO ] [t.mqtt.internal.MqttBrokerConnection] - Starting MQTT broker connection 'mqttson'

(Angelos) #45

2 mqtt broker configs… did you clear /var/lib/openhab2/config/org/openhab/mqtt.config ?


( ) #46

Since when is this really needed? I personally never had to mess around in these files…