Meross Devices in openHAB 3

This very good tutorial on how to integrate Meross Devices (Meross Devices with local MQTT Broker - Cloudless) is afaik a solution for those who want to exclusevily bind their devices to openHAB (and lose, for instance, google home integration); that’s not what I want - I’d like to have my devices here and there. So, I followed the steps from here Meross: python library with mqtt - #21 by Denis_Lambert but now I don’t know what to do with GitHub - OpusTerra/meross2mqttv2: Python Merossiot 0.4 bridge for OpenHAB 2 - how and where should it be installed? Thanks in advance!

Hi Zisco,
If you follow my tutorial (for the Cloudless Meross connection to OH) you can add Metadata to the items and expose them to Google Home over the OpenHab Connector as a switch.
Works perfectly fine for me and it is way faster then the Meross Google Home integration. Most of the times it takes less then a second to switch devices on/off.

I’ve also used the python way before and it is way more complicated and I often ran into rate limiting on Meross Cloud, even though I had configured time outs for my requests, Meross seems to calculate the in another way then python, lol.

Thank you! I followed your instructions (I didn’t use docker, but a plain installation), now I ended up when I try to bind my meross to mqtt broker with that error:

              return emojiWidthLookup.get( code ) ?? 2 ;

SyntaxError: Unexpected token ?
    at Module._compile (internal/modules/cjs/loader.js:723:23)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)
    at Module.require (internal/modules/cjs/loader.js:692:17)
    at require (internal/modules/cjs/helpers.js:25:18)
    at Object.<anonymous> (/home/bodhi/Downloads/Meross-master/node_modules/string-kit/lib/string.js:54:13)
    at Module._compile (internal/modules/cjs/loader.js:778:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)

Altough I’m connected to it’s WIFI npx meross info -v says:

npx: installed 27 in 72.531s
Getting info about device with IP
> POST /config
> Host:
Error Object.fromEntries is not a function

…and the result of

bodhi@bodhi:~$ npx meross setup --wifi-ssid '<SSID>' --wifi-pass '<PASS>' --mqtt mqtts://zshq-ohab:8883
npx: installed 27 in 72.512s
Setting up device with IP
│Primary MQTT broker                                   │zshq-ohab:8883
│Failover MQTT broker                                  │zshq-ohab:8883
Error Unable to connect to device
Error Unable to connect to device
Error Unable to connect to device
Device will reboot...

(device switches two times)

Mh maybe meross meanwhile sets a different default IP.
You also can setup the device over the Meross app, as you would normally do and connect to your wifi. After that run the same command from a device in the same network, but replace the IP with the one the meross device has on in your network. You can get the IP from the meross app in the device settings.

Didn’t change the behaviour - clicking two times, but same error…

This most likely means, that there is something wrong with the mqtt server. One click for the accepted config and the second one is a reset. I’ve experienced this as well as I tried to make my setup work. I would start checking the mqtt server. Verify that there is a certificate served from server for example with a mqtt client, there are plenty of apps for this.

Mosquitto is up and running, but
strace mosquitto_pub -h broker -t 'test/topic' --cafile certs/ca.crt -m 'test message' -p 8883
leads to

openat(AT_FDCWD, "certs/ca.crt", O_RDONLY) = -1 ENOENT (No such file or directory)
write(2, "Error: Problem setting TLS optio"..., 52Error: Problem setting TLS options: File not found.) = 52

File exists ----r-x---+ 1 root root 1.1K Jan 7 17:43 ca.crt, any idea what to try further?

I’m not a pro regarding MQTT, that’s why I’m running it in docker, takes a lot of work of your shoulders regarding permissons etc.
Maybe there is still something fishy with the folder permissions.
Try setting the permissons with

chmod 0700 ./ca_certificates
chmod 0600 ./ca_certificates/*

for the folder and the cert.

After hours of investigating and the help of (many thanks to) simonporter007 (Unable to setup device MSS210 · Issue #55 · bytespider/Meross · GitHub) it has finished in binding to my MQTT broker (mea culpa - I had an old node.js version…)! The device is still not connected to openHAB, I’ll try the docker-way the next days. But now, from here, thank you @ElBobo!

A little update: Plug is finally connected:

1673718921: New connection from on port 8883.
1673718922: Client fmware:2009072623298651802748e1e92fbcb9_Mdpk5bcXwO6q4oFr already connected,
ng old connection.
1673718922: New client connected from as fmware:2009072623298651802748e1e92
_Mdpk5bcXwO6q4oFr (p1, c1, k30, u'48:e1:e9:2f:bc:b9').

But if I want to change the state, it reboots and reconnects, but doesn’t change the state - any ideas left? I think we’re not very far from the goal!