albertogeniola / Custom-Meross-Pairer

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

Local API Login Setup #8

Closed ghost closed 2 years ago

ghost commented 3 years ago

I've got an MQTT broker running (The Home Assistant Add-on) and it runs perfectly, I'm using it for sensors and all sorts. I recently git a good deal on some Meross Smart Plugs with monitoring (MSS310) and wanted to set them up with the meross_lan HACS Integration to control them locally. I've installed the HACS Integration and restated HA. Then I downloaded the Pairer Beta app from the play store and I'm stuck. Its asking for the Local API Login, I pressed discovery, nothing, HA Ip, nothing, Ha Hostname, Nothing. I'm a little confused. Do I need a differnt broker or?

cryptedx commented 3 years ago

I have the same problem!

prjcarr commented 3 years ago

I am struggling with this as well. I think it has something you do with only being able to use MQTT with TLS. I have created self signed certificates, but its still not working. The home assistant MQTT log says "error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown"

The app error is "An error while executing the request"

Any ideas?

Ostepanov commented 3 years ago

It's because MQTT6, which is integrated in HA, does not accept special characters, like ":" in username. So first of all you need to downgrade your mqtt. I've made a huge manual of how to integrate meross devicess in HA, and there you can find information about how to downgrade mqtt

https://github.com/krahabb/meross_lan/discussions/63

jaytea33 commented 3 years ago

Thank you Ostepanov for the writeup - I was wondering what I was doing wrong and have been bashing my brain for a few weeks now on and off.

Are there any known issues with downgrading from MQTT6 to MQTT5, such as any missing features or broken compatibility? This seems like the kind of change you implement for a workaround and then bash your head a year from now when you forget you did this and you're wondering why your MQTT isn't working, so I'm a bit hesitant to try this since I have other devices currently using MQTT.

prjcarr commented 3 years ago

Yes, thanks for the write up, it's great. Are the special characters the only reason for the mqtt downgrade? Do you know the other reasons, maybe we can work around them without downgrading?

Ostepanov commented 3 years ago

Thank you Ostepanov for the writeup - I was wondering what I was doing wrong and have been bashing my brain for a few weeks now on and off.

Are there any known issues with downgrading from MQTT6 to MQTT5, such as any missing features or broken compatibility? This seems like the kind of change you implement for a workaround and then bash your head a year from now when you forget you did this and you're wondering why your MQTT isn't working, so I'm a bit hesitant to try this since I have other devices currently using MQTT.

As far I know, there should not be any issues with downgrading. Therefore, people suffer much more bugs and problems with migrating from version 5 to version 6.

Patch notes: 6.0.0 Support for anonymous logins has been removed Replaced Home Assistant authentication handling Merged local account handling with authentication plugin Add watchdog endpoint for health monitoring Updated mosquitto to 1.6.12 Updated mosquitto auth plugin to 0.1.5 Migrate add-on layout to S6 Overlay Migrate all script to use Bashio Update base image to Alpine Linux 3.13 Add port descriptions

Yes, thanks for the write up, it's great. Are the special characters the only reason for the mqtt downgrade? Do you know the other reasons, maybe we can work around them without downgrading?

For meross devices, yes. Special characters and removed anonymous login are the main reason why we can't use version 6. @kr0ner is trying to make some workarounds, but unfortunately, they don't accept yet his pull request

kr0ner commented 3 years ago

@kr0ner is trying to make some workarounds, but unfortunately, they don't accept yet his pull request

I would not call them workarounds ^^ The password-file approach has some limitations that sqlite does not have. So the latter will be more future proof :D But you are totally right: downgrading to 5.x seems to be the easiest solution. For me this did not work, but this was because of MSS310 and timestamp issues.

Ostepanov commented 3 years ago

@kr0ner is trying to make some workarounds, but unfortunately, they don't accept yet his pull request

I would not call them workarounds ^^ The password-file approach has some limitations that sqlite does not have. So the latter will be more future proof :D But you are totally right: downgrading to 5.x seems to be the easiest solution. For me this did not work, but this was because of MSS310 and timestamp issues.

It's strange, because when I've downgraded mqtt, my mss310 started to work like a charm, but as you mentioned in your comment in meross_lan, with a new update it still not working. Can you tell me how do you check if time on device is correct?

kr0ner commented 3 years ago

@kr0ner is trying to make some workarounds, but unfortunately, they don't accept yet his pull request

I would not call them workarounds ^^ The password-file approach has some limitations that sqlite does not have. So the latter will be more future proof :D But you are totally right: downgrading to 5.x seems to be the easiest solution. For me this did not work, but this was because of MSS310 and timestamp issues.

It's strange, because when I've downgraded mqtt, my mss310 started to work like a charm, but as you mentioned in your comment in meross_lan, with a new update it still not working. Can you tell me how do you check if time on device is correct?

Sorry ... missed your comment before. I've checked the mqtt logs and in the messages you see either a large value == seconds from 1.1.1979 or a very small number == device started to count from zero see this: https://github.com/krahabb/meross_lan/issues/55 and this https://github.com/krahabb/meross_lan/discussions/63#discussioncomment-1233937

mlazzarotto commented 3 years ago

I'm having the same issue From the Addon configuration I see that the following ports are configured:

Container | Host | Descrizione -- | -- | -- 1883/tcp |  1883 | Normal MQTT 1884/tcp |  1884 | MQTT over WebSocket 8883/tcp |  8883 | Normal MQTT with SSL 8884/tcp |  8884 | MQTT over WebSocket with SSL

Given that my HA Ip address is 192.168.1.111, what string should I put on the "HTTP server hostname" field of the app?

harphere commented 3 years ago

Same question here. What exactly is expected as the HTTP server hostname? It could use a better name or a description.

Ostepanov commented 3 years ago

Same question here. What exactly is expected as the HTTP server hostname? It could use a better name or a description.

Hello nickelnine, HTTP server hostname should be IP only of your Home assistant. For example if your home assistant has this ip: 192.168.1.99, you should put as HTTP server hostname 192.168.1.99

rcdailey commented 2 years ago

Hello nickelnine, HTTP server hostname should be IP only of your Home assistant. For example if your home assistant has this ip: 192.168.1.99, you should put as HTTP server hostname 192.168.1.99

This is wrong. Field validation fails with "URL is invalid". It seems to want it in the format http://192.168.1.99, but even this doesn't work (at least it accepts the URL itself though)

maxshcherbina commented 2 years ago

I have also downloaded this app and cannot get my credentials to be accepted. Returns an error. the MQTT service in the logs seems to accept a connection from the device im using.

albertogeniola commented 2 years ago

Hi guys, I've released a couple of newer versions which should be more user-friendly and let you decide whether to connect to meross-lan or other third party plugins.

prjcarr commented 2 years ago

Hi guys, I've released a couple of newer versions which should be more user-friendly and let you decide whether to connect to meross-lan or other third party plugins.

Thanks, Does this still require an mqtt downgrade or can we use the standard HA mqtt?

jaytea33 commented 2 years ago

I highly doubt anything's changed there but I'll let someone else chime in if I'm off base. No need to downgrade though just use kr0ner's fork. Was an easy switch for me but obv back up first before switching. Been running smoothly for a while now

https://github.com/kr0ner/mosquitto

albertogeniola commented 2 years ago

Thanks, Does this still require an mqtt downgrade or can we use the standard HA mqtt?

This has nothing to do with MQTT: in fact you still need to downgrade mqtt addon or early adopt the dev-version of the MerossLocal addon I am developing (which includes both mqtt and a lan-only http api daemon).

The second option is still in early stage, but enables both local control and remote proxy against Meross cloud: in this way also the app will work while HA relies on local broker. Also, it includes the necessary logic to implement login as you would do with the official app: this will make it harder for Meross to break compatibility via firmware upgrade :)

rcdailey commented 2 years ago

This probably isn't the place, but I really need to vent my frustration here. It is not clear at all how to get Meross devices working locally in general. I see 3 different developers with seemingly separate but maybe not integrations for HASS. It's not clear to me which I need to use: Meross IoT? Meross LAN? Which is local and which is cloud based? How does the app come into play? Which hostnames/URLs do I use? I set up an MQTT Broker, how does that fit into the picture (I see hints that when "mqtt broker" is mentioned in the Meross context, we're not talking about a vanilla one for some reason)? Can I set up already provisioned devices or do I need to factory reset them and provision them using your custom app or the official one? So many questions, but seemingly no answers.

I've spent hours trying to figure all this out and get it working but it's only made it more confusing and frustrating. I think someone really needs to write a from 0% to 100% step by step, detailed, sensible guide on how to get an end-to-end setup working with the Meross smart garage door opener. Right now I've resorted to using Homekit to connect to mine because none of this Meross stuff makes any sense to me.

Sorry for the frustration. I know this is a "me" problem. I really do appreciate your work here, I just wish it was easier to figure out. Thank you for the hard work.

prjcarr commented 2 years ago

early adopt the dev-version of the MerossLocal addon I am developing (which includes both mqtt and a lan-only http api daemon).

Thank you, I have been looking forward to your local addon as I think it will simplify the process a lot. I only have a basic HA setup on a RPi, without docker. Any ideas when it will be ready for this type of setup? Appreciate all your efforts.

jaytea33 commented 2 years ago

This probably isn't the place, but I really need to vent my frustration here. It is not clear at all how to get Meross devices working locally in general. I see 3 different developers with seemingly separate but maybe not integrations for HASS.

I feel you and I agree but sadly this is the way open source operates these days - everything you need is there... but the answers and instructional gaps you need are in 400 different threads.

I was eventually able to get it working but only after about 20 hours of grinding and trial and error and I've been scared to breathe on it ever since I got it working. Right now your options are either: 1. Wait for this new app, which will hopefully be much easier. 2. Use the closest thing to a full writeup (which worked for me, and doesn't use the app at all):

https://github.com/krahabb/meross_lan/discussions/63

It's still not fully complete though and you'd have to read all the comments to get the full instruction set. But if you combine my comment on there with the instructions you should be able to get it working, as I added all the pain points I experienced and how I overcame them (although I'd avoid replacing the /lib/api.js file at first unless you receive errors as it could've been fixed by now). Hopefully that helps point you in the right direction.

Once you get it working, regardless of what method is used to get there, if anyone plans to block all internet access (and you should), note that at least with the MSG100, it will spam NTP requests like crazy and you'll see it in the firewall logs. The workaround is here

https://github.com/krahabb/meross_lan/issues/84