openhab / openhab-addons

Add-ons for openHAB
https://www.openhab.org/
Eclipse Public License 2.0
1.9k stars 3.59k forks source link

[mqtt] Bug in HASS autodiscovery with latest Tasmota firmware #4461

Closed h4lloween closed 5 years ago

h4lloween commented 5 years ago

Tasmota device updated to the latest version (Sonoff-Tasmota 6.4.1) That version supports HASS auto discovery option (SetOption19).

1st: Discovery message: The device is sending the following discovery message:

13:03:41 MQT: homeassistant/light/45D1FA_LI_1/config = (retained) 13:03:41 MQT: homeassistant/switch/45D1FA_RL_1/config = {"name":"Sonoff_Garage","cmd_t":"~cmnd/POWER","stat_t":"~tele/STATE","val_tpl":"{{value_json.POWER}}","pl_off":"OFF","pl_on":"ON","avty_t":"~tele/LWT","pl_avail":"Online","pl_not_avail":"Offline","uniq_id":"45D1FA_RL_1","device":{"identifiers":["45D1FA"],"name":"Sonoff_Garage","model":"1 Channel","sw_version":"6.4.1(sonoff)","manufacturer":"Tasmota"}, "~":"sonoff/sonoff_garage/"} (retained) 13:03:41 MQT: homeassistant/light/45D1FA_LI_2/config = (retained) 13:03:41 MQT: homeassistant/switch/45D1FA_RL_2/config = (retained) 13:03:41 MQT: homeassistant/light/45D1FA_LI_3/config = (retained) 13:03:41 MQT: homeassistant/switch/45D1FA_RL_3/config = (retained) 13:03:41 MQT: homeassistant/light/45D1FA_LI_4/config = (retained) 13:03:41 MQT: homeassistant/switch/45D1FA_RL_4/config = (retained) 13:03:41 MQT: homeassistant/light/45D1FA_LI_5/config = (retained) 13:03:41 MQT: homeassistant/switch/45D1FA_RL_5/config = (retained) 13:03:41 MQT: homeassistant/light/45D1FA_LI_6/config = (retained) 13:03:41 MQT: homeassistant/switch/45D1FA_RL_6/config = (retained) 13:03:41 MQT: homeassistant/light/45D1FA_LI_7/config = (retained) 13:03:41 MQT: homeassistant/switch/45D1FA_RL_7/config = (retained) 13:03:41 MQT: homeassistant/light/45D1FA_LI_8/config = (retained) 13:03:41 MQT: homeassistant/switch/45D1FA_RL_8/config = (retained)

The device is discovered in OH but with the Home Assistant config ID set to “config” instead of the real value (should be 45D1FA_RL_1 in this case) causing the thing to be non-functional. After updating the HASS config ID to the correct value and re-sending the discovery message the thing goes online.

2nd: Discovery message to remove device/ empty discovery message: 20:56:21 CMD: setoption19 0 20:56:21 MQT: homeassistant/light/45D1FA_LI_1/config = (retained) 20:56:21 MQT: homeassistant/switch/45D1FA_RL_1/config = (retained) 20:56:21 MQT: homeassistant/light/45D1FA_LI_2/config = (retained) 20:56:21 MQT: homeassistant/switch/45D1FA_RL_2/config = (retained) 20:56:21 MQT: homeassistant/light/45D1FA_LI_3/config = (retained) 20:56:21 MQT: homeassistant/switch/45D1FA_RL_3/config = (retained) 20:56:21 MQT: homeassistant/light/45D1FA_LI_4/config = (retained) 20:56:21 MQT: homeassistant/switch/45D1FA_RL_4/config = (retained) 20:56:21 MQT: homeassistant/light/45D1FA_LI_5/config = (retained) 20:56:21 MQT: homeassistant/switch/45D1FA_RL_5/config = (retained) 20:56:21 MQT: homeassistant/light/45D1FA_LI_6/config = (retained) 20:56:21 MQT: homeassistant/switch/45D1FA_RL_6/config = (retained) 20:56:21 MQT: homeassistant/light/45D1FA_LI_7/config = (retained) 20:56:21 MQT: homeassistant/switch/45D1FA_RL_7/config = (retained) 20:56:21 MQT: homeassistant/light/45D1FA_LI_8/config = (retained) 20:56:21 MQT: homeassistant/switch/45D1FA_RL_8/config = (retained) 20:56:21 MQT: sonoff/sonoff_garage/stat/RESULT = {"SetOption19":"OFF"}

Results in:

2018-12-27 20:46:35.671 [ERROR] [ansport.mqtt.internal.ClientCallback] - MQTT message received. MqttMessageSubscriber#processMessage() implementation failure java.lang.NullPointerException: null at org.eclipse.smarthome.binding.mqtt.generic.internal.discovery.HomeAssistantDiscovery.receivedMessage(HomeAssistantDiscovery.java:168) ~[?:?] at org.eclipse.smarthome.binding.mqtt.discovery.TopicSubscribe.processMessage(TopicSubscribe.java:52) ~[?:?] at org.eclipse.smarthome.io.transport.mqtt.internal.ClientCallback.lambda$3(ClientCallback.java:90) ~[223:org.eclipse.smarthome.io.transport.mqtt:0.11.0.201812232227] at java.util.ArrayList.forEach(ArrayList.java:1257) ~[?:?] at org.eclipse.smarthome.io.transport.mqtt.internal.ClientCallback.messageArrived(ClientCallback.java:90) [223:org.eclipse.smarthome.io.transport.mqtt:0.11.0.201812232227] at org.eclipse.paho.client.mqttv3.internal.CommsCallback.deliverMessage(CommsCallback.java:499) [214:org.eclipse.paho.client.mqttv3:1.2.0] at org.eclipse.paho.client.mqttv3.internal.CommsCallback.handleMessage(CommsCallback.java:402) [214:org.eclipse.paho.client.mqttv3:1.2.0] at org.eclipse.paho.client.mqttv3.internal.CommsCallback.run(CommsCallback.java:206) [214:org.eclipse.paho.client.mqttv3:1.2.0] at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:?] at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:?] at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180) [?:?] at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293) [?:?] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:?] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:?] at java.lang.Thread.run(Thread.java:748) [?:?]

wborn commented 5 years ago

Please use the Eclipse SmartHome issue tracker for reporting MQTT Binding related issues. That's the repository where the MQTT Binding source code is maintained.