[SOLVED] MQTT sonoff working with OH but not with Google - whats wrong?

Hello folks,

I searched the community and tried different “solutions” but nothing works.

I have a tasmotized sonoff basic which i can control using the embedded mqtt broker. In my sitemap the switch works and also updates state.

My google home is linked, the sonoff shows in the google home app, i can push the button to turn on/off the sonoff but nothing works.

here’s my switch config:

Switch Sonoff_B_01 "bureaulamp  [%s]" [ "Switchable" ] {mqtt=">[broker:cmnd/sonoff_1/POWER:command:*:default]],<[broker:stat/sonoff_1/POWER:state:default]"}

As i said, in OH i can fully control the device as well with the OH app on my phone. But not with voice commands.

This is what i found in my LOG:

==> /var/log/openhab2/events.log <==

2019-09-05 19:50:54.406 [ome.event.ItemCommandEvent] - Item 'Sonoff_B_01' received command ON

==> /var/log/openhab2/openhab.log <==

2019-09-05 19:53:08.941 [WARN ] [moquette.spi.impl.SessionsRepository] - Session does not exist. CId=mqtt-explorer-6a9c723a

2019-09-05 19:57:46.872 [WARN ] [su.litvak.chromecast.api.v2.Channel ] - Error while handling

org.codehaus.jackson.map.JsonMappingException: Could not resolve type id 'MULTIZONE_STATUS' into a subtype of [simple type, class su.litvak.chromecast.api.v2.StandardResponse]

 at [Source: N/A; line: -1, column: -1]

	at org.codehaus.jackson.map.JsonMappingException.from(JsonMappingException.java:163) ~[256:org.openhab.binding.chromecast:2.4.0]

	at org.codehaus.jackson.map.deser.StdDeserializationContext.unknownTypeException(StdDeserializationContext.java:273) ~[256:org.openhab.binding.chromecast:2.4.0]

	at org.codehaus.jackson.map.jsontype.impl.TypeDeserializerBase._findDeserializer(TypeDeserializerBase.java:117) ~[256:org.openhab.binding.chromecast:2.4.0]

	at org.codehaus.jackson.map.jsontype.impl.AsPropertyTypeDeserializer.deserializeTypedFromObject(AsPropertyTypeDeserializer.java:74) ~[256:org.openhab.binding.chromecast:2.4.0]

	at org.codehaus.jackson.map.deser.AbstractDeserializer.deserializeWithType(AbstractDeserializer.java:89) ~[256:org.openhab.binding.chromecast:2.4.0]

	at org.codehaus.jackson.map.deser.StdDeserializerProvider$WrappedDeserializer.deserialize(StdDeserializerProvider.java:494) ~[256:org.openhab.binding.chromecast:2.4.0]

	at org.codehaus.jackson.map.ObjectMapper._readValue(ObjectMapper.java:2695) ~[256:org.openhab.binding.chromecast:2.4.0]

	at org.codehaus.jackson.map.ObjectMapper.readValue(ObjectMapper.java:1990) ~[256:org.openhab.binding.chromecast:2.4.0]

	at su.litvak.chromecast.api.v2.EventListenerHolder.deliverEvent(EventListenerHolder.java:56) ~[256:org.openhab.binding.chromecast:2.4.0]

	at su.litvak.chromecast.api.v2.Channel.notifyListenersOfSpontaneousEvent(Channel.java:452) ~[256:org.openhab.binding.chromecast:2.4.0]

	at su.litvak.chromecast.api.v2.Channel.access$600(Channel.java:51) ~[256:org.openhab.binding.chromecast:2.4.0]

	at su.litvak.chromecast.api.v2.Channel$ReadThread.run(Channel.java:195) [256:org.openhab.binding.chromecast:2.4.0]

Did you ask GA to “sync my devices”?

Yes, several times, even refreshing the app, unlinking the accounts en re-linking them.

There is a two minute gap there.

Are you very sure the Item you can see in Google is the same Item that you control from sitemap? People sometimes get into a knot with duplicates.

pretty sure, because i only have 1 sonoff linked to Openhab for testing and learning purposes.

I use MXTT.fx and MQTT explorer to troubleshoot, both can publish and subscribe to the topics and i can simply control the one switch. it seems like a problem between Google and Openhab maybe?

this is what i get in my LOG

2019-09-05 21:13:51.804 [vent.ItemStateChangedEvent] - TasmotaTest_Sonoff_1 changed from ON to OFF

==> /var/log/openhab2/openhab.log <==

2019-09-05 21:14:02.962 [WARN ] [moquette.spi.impl.SessionsRepository] - Session does not exist. CId=mqtt-explorer-6a9c723a

2019-09-05 21:14:03.145 [WARN ] [moquette.spi.impl.SessionsRepository] - Session does not exist. CId=mqtt-explorer-6a9c723a

2019-09-05 21:14:03.168 [WARN ] [moquette.spi.impl.SessionsRepository] - Session does not exist. CId=mqtt-explorer-6a9c723a

==> /var/log/openhab2/events.log <==

2019-09-05 21:14:03.211 [vent.ItemStateChangedEvent] - TasmotaTest_Sonoff_1 changed from OFF to ON

This looks relevant (suggests the warn message is irrelevant !)

umm, not being funny but this Item

is not the same as this Item

:thinking:
the one device is named: Sonoff_1 in it’s mqtt tasmota config, MQTT topic is sonoff_1
(And i truly only have one sonoff basic configured up till now)

Paper-ui shows me this: image

my config shows me this:

Switch Sonoff_B_01 "bureaulamp  [%s]" [ "Switchable" ] { mqtt=">[broker:cmnd/sonoff_1/POWER:command:*:default]],<[broker:stat/sonoff_1/POWER:state:default]" }

When i switch states using control in paper-ui, MQTT explorer shows me following:
(device was off, switched on and off again)

image

I’m trying to figure out what’s the difference in the names: Sonoff_1 and Sonoff_B_01
After all i is the same device, but isn’t Sonoff_B_01 just a group name?

Items are openHAB’s internal model representation of simple devices.
These are the things (small t) that you show and manipulate in your user UI, and you examine and manipulate in rules.

Things (big T) are a bindings representation of (usually) a real device or external service. A Thing representing a weather service will be wildly different from a Thing representing a light switch.

channels are the pathway to link Items to Things.

Example - We might make a Thing for some smart thermostat. It would have channels for room temperature, target temperature, and heat demand. We would link those channels to three Items - probably a Number type, another Number type, and a Switch type.


Okay, so what is wrong here is that you are looking at an old tutorial. Be careful about this sort of thing.

You clearly have the current MQTT version 2 binding installed, because you are making Things for it.

But in your Item, the { mqtt=">[broker… part is a configuration for MQTT binding version 1.
That’s not going to work with v2, because v2 works with Things and channels.

1 Like

Aha, that’s what i was afraid of when copy-pasting the config and changing the commands to my own needs.

i’ll dive into this.

Thanks so much.