albertogeniola / Custom-Meross-Pairer

Android APP that allows pairing Meross Devices with third party MQTT brokers
GNU General Public License v2.0
61 stars 5 forks source link

Device Key ? #24

Closed Write closed 8 months ago

Write commented 11 months ago

Hi, my Meross_Lan integration find automatically the freshly paired Meross devices, but I can't find the Device_Key ? Is there a way to find it ?

I tried to use your plugin and set to a "custom" broker, but it won't connect to Local Meross Broker, hence why I'm asking if there's a way to retrieve device_key,

Thanks

rubixcubez commented 11 months ago

+1, I don't know how to get the device key either.

Write commented 11 months ago

+1, I don't know how to get the device key either.

I found out it's way easier to ditch Meross local Broker and don't use custom pairer app.

I setup my own mosquito server (HA Broken can't allow anonymous) via Docker, and paired manually with this tutorial : https://github.com/bytespider/Meross/wiki/MQTT

Then, the device will simply be discovered via Meross_Lan https://github.com/krahabb/meross_lan integration, and the key will simply be empty !

As for the Mosquitto container, I used this one : https://github.com/vvatelot/mosquitto-docker-compose (clone the repo)

And simply mounted a volume with the certs (That you create during the tutorial).

The docker-compose.yaml simply look like this :

services:
  mosquitto:
    build:
      context: .
    volumes:
      - type: bind
        source: ./config/
        target: /mosquitto/config/
      - type: bind
        source: ./log/
        target: /mosquitto/log/
      - type: bind
        source: ./data/
        target: /mosquitto/data/
      - type: bind
        source: ./certs/
        target: /mosquitto/certs/
    ports:
      - target: 2001
        published: 2001
        protocol: tcp
        mode: host
    restart: always

mosquitto.conf

persistence true
persistence_location /mosquitto/data/

log_type all
log_dest file /mosquitto/log/mosquitto.log

allow_anonymous true

port 2001
require_certificate false

cafile   /mosquitto/certs/ca.crt
certfile /mosquitto/certs/server.crt
keyfile  /mosquitto/certs/server.key

# password_file /mosquitto/config/password.txt
krahabb commented 10 months ago

@Write, the device key is stored in the Meross cloud profile and you could use some curl to actually login to the meross cloud infrastructure and get this information or, in meross_lan, use the feature that allows you to recover the device key from the cloud profile automatically (so you don't have to tinker with manual message formatting and the likes) I guess there are many other tools that, once provided with username/password for the Meross account could grab your device key without too much effort.

Here the background on the cloud login procedure

Write commented 10 months ago

@Write,

the device key is stored in the Meross cloud profile and you could use some curl to actually login to the meross cloud infrastructure and get this information or, in meross_lan, use the feature that allows you to recover the device key from the cloud profile automatically (so you don't have to tinker with manual message formatting and the likes)

I guess there are many other tools that, once provided with username/password for the Meross account could grab your device key without too much effort.

Here the background on the cloud login procedure

Well, I know about cloud key, but tje whole point of this custom pairer app is to not login w/ meross cloud, since you pair it with your own MQTT Broker instead of Meross one. Now, I don't know why this app (Custom Pairer Tool) assign an unknown key (that is not retrievable trough the cloud, since you never logged in trough meross in the first place). Anyway my method allows your device to have an empty key, as such Meross_Lan plugin will work.

krahabb commented 10 months ago

Well, I know about cloud key, but tje whole point of this custom pairer app is to not login w/ meross cloud, since you pair it with your own MQTT Broker instead of Meross one. Now, I don't know why this app (Custom Pairer Tool) assign an unknown key (that is not retrievable trough the cloud, since you never logged in trough meross in the first place). Anyway my method allows your device to have an empty key, as such Meross_Lan plugin will work.

Right..I thought the meross pairer app would allow you to set the key (or leave it empty) and you were instead troubling getting a Meross cloud paired device key.... My misunderstanding ;)

Write commented 10 months ago

Well, I know about cloud key, but tje whole point of this custom pairer app is to not login w/ meross cloud, since you pair it with your own MQTT Broker instead of Meross one. Now, I don't know why this app (Custom Pairer Tool) assign an unknown key (that is not retrievable trough the cloud, since you never logged in trough meross in the first place). Anyway my method allows your device to have an empty key, as such Meross_Lan plugin will work.

Right..I thought the meross pairer app would allow you to set the key (or leave it empty) and you were instead troubling getting a Meross cloud paired device key.... My misunderstanding ;)

To be fair, I have absolutely no Idea why this custom pairer app add a custom key, since the default way of doing the same thing (without any app + custom broker) (https://github.com/bytespider/Meross/wiki/MQTT) add an empty key (which was my solution in the end).

albertogeniola commented 8 months ago

Hi @Write , I am not sure I understand the exact issue here, but please let me state the following.

To be fair, I have absolutely no Idea why this custom pairer app add a custom key, since the default way of doing the same thing (without any app + custom broker) (https://github.com/bytespider/Meross/wiki/MQTT) add an empty key (which was my solution in the end).

This app was born to make sure people could use the Meross HA Addon. And, to ensure maximum compatiblity with the library, the Addon mimics exactly what the Meross cloud does. In other words, the addon generates an ID+cloudkey for the user (as the Meross Cloud does) and allows the pairer app to log-in in you "HA Meross Private cloud" (that's far from being a private cloud, but you can look at it that way). Of course, if you didn't use the HA Addon, you don't see any of it, and that's why you are so confused.

Now, there are still methods to customize the cloud-key and avoid logging in at all. You just have to select "Manual user/key setup" in the first screen of the app, and that will bring you here:

In any case, "power users" like you are better going directly via CURL/APIs, which have been documented in details here. Pairing with a custom broker is just a matter of sending a POST request via CURL with the right payload!

Write commented 8 months ago

Hi @Write , I am not sure I understand the exact issue here, but please let me state the following.

To be fair, I have absolutely no Idea why this custom pairer app add a custom key, since the default way of doing the same thing (without any app + custom broker) (https://github.com/bytespider/Meross/wiki/MQTT) add an empty key (which was my solution in the end).

This app was born to make sure people could use the Meross HA Addon. And, to ensure maximum compatiblity with the library, the Addon mimics exactly what the Meross cloud does. In other words, the addon generates an ID+cloudkey for the user (as the Meross Cloud does) and allows the pairer app to log-in in you "HA Meross Private cloud" (that's far from being a private cloud, but you can look at it that way). Of course, if you didn't use the HA Addon, you don't see any of it, and that's why you are so confused.

Now, there are still methods to customize the cloud-key and avoid logging in at all. You just have to select "Manual user/key setup" in the first screen of the app, and that will bring you here:

In any case, "power users" like you are better going directly via CURL/APIs, which have been documented in details here. Pairing with a custom broker is just a matter of sending a POST request via CURL with the right payload!

Thanks. Well I was missing the Manuel USER/KEY setup indeed, guess it could've fixed my issue back then. Anyway thank you for answering.