[SOLVED] MQTT Switch do not works

Hi

i know that there’s a lot of MQTT threads issue but this one is weirdest :triumph:

MQTT.cfg is configured as below

# URL to the MQTT broker, e.g. tcp://localhost:1883 or ssl://localhost:8883

broker.url=tcp://192.168.1.110:1883

Mosquitto is up

My openhab server is up and connected to mosquitto

openhab.log:

2018-02-07 14:04:22.210 [INFO ] [er.internal.HomeBuilderDashboardTile] - Started Home Builder at /homebuilder
2018-02-07 14:04:23.399 [INFO ] [.dashboard.internal.DashboardService] - Started dashboard at http://192.168.1.110:8080
2018-02-07 14:04:23.440 [INFO ] [.dashboard.internal.DashboardService] - Started dashboard at https://192.168.1.110:8443   
2018-02-07 14:04:54.315 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'newitems.items'
2018-02-07 14:04:58.780 [INFO ] [thome.model.lsp.internal.ModelServer] - Started Language Server Protocol (LSP) service on port 5007
2018-02-07 14:04:59.489 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'SMH2.sitemap' 
2018-02-07 14:05:03.366 [INFO ] [basic.internal.servlet.WebAppServlet] - Started Basic UI at /basicui/app
2018-02-07 14:05:03.471 [INFO ] [arthome.ui.paper.internal.PaperUIApp] - Started Paper UI at /paperui
2018-02-07 14:05:03.747 [INFO ] [panel.internal.HABPanelDashboardTile] - Started HABPanel at /habpanel
2018-02-07 14:05:04.165 [INFO ] [penhab.io.transport.mqtt.MqttService] - MQTT Service initialization completed.
2018-02-07 14:05:04.168 [INFO ] [t.mqtt.internal.MqttBrokerConnection] - Starting MQTT broker connection 'broker'

My mosquitto server is up without any errors and even got a connection from openhab

mosquitto.log:

1518005040: mosquitto version 1.4.10 (build date Mon, 29 May 2017 13:43:29 +0100) starting
1518005040: Config loaded from /etc/mosquitto/mosquitto.conf.
1518005040: Opening ipv4 listen socket on port 1883.
1518005040: Opening ipv6 listen socket on port 1883.
1518005104: New connection from 192.168.1.110 on port 1883.

i can publish and subscribe from mqttfx or from android mqtt

my items is well defined and displayed

Switch MQTT_chauffage   "Switch MQTT_Chauffage" <poweroutlet> [ "Switchable" ] {mqtt=">[192.168.1.110:broadlink/SP2_1/power:command:ON:1],>[192.168.1.110:broadlink/SP2_1/power:command:OFF:0]"}

when i turn on/off the switch, it’s well logged in the events but nothing is published.
i have subscribed on mqttfx to #

2018-02-07 14:15:43.002 [ome.event.ItemCommandEvent] - Item 'MQTT_chauffage' received command ON
2018-02-07 14:15:43.023 [vent.ItemStateChangedEvent] - MQTT_chauffage changed from NULL to ON
2018-02-07 14:15:43.401 [ome.event.ItemCommandEvent] - Item 'MQTT_chauffage' received command OFF   
2018-02-07 14:15:43.408 [vent.ItemStateChangedEvent] - MQTT_chauffage changed from ON to OFF

No error but nothing is published

  1. it’s after a uninstall/install of openhab
  2. i have uninstalled the mqtt binding and reinstalled
  3. i have uninstalled the mqtt action and reinstalled
  4. i have not uninstalled the mqtt persistence

I am driving crazy, please help, i need to sleep:disappointed_relieved:

please check my items , what i am missing?

MQTT Manual

First thing that comes into my sight. You named your broker = broker. But your item calls a broker named “192.168.1.110” which does not exsist.

my mqtt.cfg

mosquitto.url=tcp://192.168.178.5:1883
mosquitto.user=openhabian
mosquitto.pwd=SuperSecretPasswd
mosquitto.qos=1
mosquitto.retain=true
mosquitto.async=true

My mqtt.items

////SONOFF sonoff-977686
Switch   a_Licht_Outdoor_SonoffBasic_Grilllampe                 "Grilllampe schalten"             (g_Outdoor, g_MYSQL)  { mqtt=">[mosquitto:cmnd/sonoff-977686/POWER:command:*:default], <[mosquitto:stat/sonoff-977686/POWER:state:default]" }
1 Like

thank you so much!

i have put the hostname instead of the broker url

thank you so much!

Did this solve it? :thinking:

Now mosquitto can interact with openhab . awesome

BUTTTTTTTT

with my current switch definition, it’s only turn off. impossible to turn on

Switch MQTT_chauffage "Switch MQTT_Chauffage" <poweroutlet> [ "Switchable" ] {mqtt=">[mosquitto:broadlink/SP2_1/power:command:ON:1],>[mosquitto:broadlink/SP2_1/power:command:OFF:0]"}

with your format, i have added another switch :slight_smile:

   Switch MQTT_chauffage2   "Switch MQTT_Chauffage2 " <poweroutlet> [ "Switchable" ] {mqtt=">[mosquitto:broadlink/SP2_1/power:command:*:default],>[mosquitto:broadlink/SP2_1/power:state:default]"}`

but i am getting this error

2018-02-07 15:11:48.402 [ERROR] [el.item.internal.GenericItemProvider] - Binding configuration of type 'mqtt' of item 'MQTT_chauffage2' could not be parsed correctly.
org.eclipse.smarthome.model.item.BindingConfigParseException: Configuration 'mosquitto:broadlink/SP2_1/power:state:default' is not a valid outbound configuration: Configuration requires 5 parameters separated by ':'

	at org.openhab.core.binding.internal.BindingConfigReaderDelegate.processBindingConfiguration(BindingConfigReaderDelegate.java:51) [207:org.openhab.core.compat1x:2.2.0]
	at org.eclipse.smarthome.model.item.internal.GenericItemProvider.internalDispatchBindings(GenericItemProvider.java:341) [135:org.eclipse.smarthome.model.item:0.10.0.b1]
	at org.eclipse.smarthome.model.item.internal.GenericItemProvider.internalDispatchBindings(GenericItemProvider.java:310) [135:org.eclipse.smarthome.model.item:0.10.0.b1]
	at org.eclipse.smarthome.model.item.internal.GenericItemProvider.processBindingConfigsFromModel(GenericItemProvider.java:195) [135:org.eclipse.smarthome.model.item:0.10.0.b1]
	at org.eclipse.smarthome.model.item.internal.GenericItemProvider.modelChanged(GenericItemProvider.java:377) [135:org.eclipse.smarthome.model.item:0.10.0.b1]
	at org.eclipse.smarthome.model.core.internal.ModelRepositoryImpl.notifyListeners(ModelRepositoryImpl.java:314) [134:org.eclipse.smarthome.model.core:0.10.0.b1]


	at org.eclipse.smarthome.model.core.internal.ModelRepositoryImpl.addOrRefreshModel(ModelRepositoryImpl.java:143) [134:org.eclipse.smarthome.model.core:0.10.0.b1]

	at org.eclipse.smarthome.model.core.internal.folder.FolderObserver.checkFile(FolderObserver.java:247) [134:org.eclipse.smarthome.model.core:0.10.0.b1]


	at org.eclipse.smarthome.model.core.internal.folder.FolderObserver.processWatchEvent(FolderObserver.java:311) [134:org.eclipse.smarthome.model.core:0.10.0.b1]

	at org.eclipse.smarthome.core.service.WatchQueueReader.run(WatchQueueReader.java:209) [109:org.eclipse.smarthome.core:0.10.0.b1]


	at java.lang.Thread.run(Thread.java:748) [?:?]

There is still something fishy. You have both mqtt configurations outbound.
This is the error message.

You could read my configuration like this.
> outbound send default openhab command ON/OFF 1/0
< inbound receive manual pressed state

yours

Switch MQTT_chauffage2   "Switch MQTT_Chauffage2 " <poweroutlet> [ "Switchable" ] {mqtt=">[mosquitto:broadlink/SP2_1/power:command:*:default],>[mosquitto:broadlink/SP2_1/power:state:default]"}`

Try this

Switch   MQTT_chauffage2    "Switch MQTT_Chauffage2"    <poweroutlet>    [ "Switchable" ]    { mqtt=">[mosquitto:broadlink/SP2_1/power:command:*:default], <[mosquitto:broadlink/SP2_1/power:state:default]" }

Thanks a lot

do you know a way to run python scripts a a service ?

Wups! :blush:
I did not see this question since now you marked this as Solved…

I assume you are on Linux (please work on Linux…) if yes take a look at this

2 Likes

Thanks a lot . Simple and clear