bytespider / Meross

Investigating the Meross/Refoss MSS310 Smart Plug and getting these devices to communicate with our private MQTT brokers
113 stars 19 forks source link

mss110 power switch with firmware 7.3.19 requires user and key #65

Closed amair closed 1 year ago

amair commented 1 year ago

After upgrading an ms110 switch to firmware 7.3.19 using meross-setup without a user and key setup results in an error.

The user (as returned from meross-info is the MAC address of the device. Trying to set this as the user in meross-setup results in the app trying to interpret the string as an integer which then fails validation.

bytespider commented 1 year ago

The username and password reported by meross-info is the MQTT credentials. The username you are setting in meross-setup is only used in signing the message and communication with Meross cloud.

amair commented 1 year ago

OK, some more details of the issue using verbose logging option

Initial Attempt: No user or key user@host bin % sudo ./meross-setup --verbose --gateway 10.10.10.1 --wifi-ssid '' --wifi-pass '' --mqtt mqtts://mqtt.local:8883 Setting up device with IP 10.10.10.1 │Primary MQTT broker │mqtt.local:8883 │ │Failover MQTT broker │mqtt.local:8883 │

POST /config Host: 10.10.10.1 Accept: application/json, text/plain, / Content-Type: application/json

{ header: { from: '', method: 'SET', namespace: 'Appliance.Config.Key', messageId: 'bc7d4be83a18449f4112e8ff7ddb85c0', timestamp: 1695711098, sign: '8bacc21ffe154410dadf9e6db34b1de8' }, payload: { key: { userId: '0', key: '', gateway: { host: 'mqtt.local', port: '8883', secondHost: 'mqtt.local', secondPort: '8883', redirect: 1 } } } }

node:internal/errors:496 ErrorCaptureStackTrace(err); ^

TypeError [ERR_INVALID_ARG_TYPE]: The "url" argument must be of type string. Received undefined at new NodeError (node:internal/errors:405:5) at validateString (node:internal/validators:162:11) at Url.parse (node:url:170:3) at Object.urlParse [as parse] (node:url:141:13) at new URL (/Users/alastair/Programming/openhab/Meross/lib/api.js:6:35) at logRequest (/Users/alastair/Programming/openhab/Meross/lib/api.js:62:15) at handleRequestError (/Users/alastair/Programming/openhab/Meross/lib/api.js:99:13) at API.configureMqttServers (/Users/alastair/Programming/openhab/Meross/lib/api.js:341:13) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async /Users/alastair/Programming/openhab/Meross/bin/meross-setup:89:9 { code: 'ERR_INVALID_ARG_TYPE' }

Query Device for key and password user@host bin % sudo ./meross-info -g 10.10.10.1 Getting info about device with IP 10.10.10.1 │Device │mss110 us rtl8710cm (hardware:7.0.0 firmware:7.3.19) │ │UUID │ │ │Mac address │ │ │IP address │10.10.10.1 │ │Credentials │User: │ │ │Password: │ │MQTT topics │Publishes to: /appliance//publish │ │ │Subscribes to: /appliance//subscribe │

Successful attempt using user and key (with code modification to remove conversion to int for user) user@host bin % sudo ./meross-setup --user '' --key '' --verbose --gateway 10.10.10.1 --wifi-ssid '' --wifi-pass '' --mqtt mqtts://mqtt.local:8883 Setting up device with IP 10.10.10.1 │Primary MQTT broker │mqtt.local:8883 │ │Failover MQTT broker │mqtt.local:8883 │

POST /config Host: 10.10.10.1 Accept: application/json, text/plain, / Content-Type: application/json

{ header: { from: '', method: 'SET', namespace: 'Appliance.Config.Key', messageId: 'a28b60639e297bc1f69c8af767fce2ce', timestamp: 1695711279, sign: '281b8f920e604f226668ddfa40d9e1ec' }, payload: { key: { userId: '', key: '', gateway: { host: 'mqtt.local', port: '8883', secondHost: 'mqtt.local', secondPort: '8883', redirect: 1 } } } }

< 200 OK < content-type: application/json < connection: close < { header: { messageId: 'a28b60639e297bc1f69c8af767fce2ce', namespace: 'Appliance.Config.Key', method: 'SETACK', payloadVersion: 1, from: '/appliance//publish', uuid: '', timestamp: 32, timestampMs: 898, sign: '9b25af7524db47bd472446e416768c6a' }, payload: {} }

POST /config Host: 10.10.10.1 Accept: application/json, text/plain, / Content-Type: application/json

{ header: { from: '', method: 'GET', namespace: 'Appliance.System.All', messageId: '1737c7fa27afb3964a5ea1f4d24fd9c0', timestamp: 1695711279, sign: '894ba6fa214f54d179b093b3dfb7c077' }, payload: {} }

< 200 OK < content-type: application/json < connection: close < { header: { messageId: '1737c7fa27afb3964a5ea1f4d24fd9c0', namespace: 'Appliance.System.All', method: 'GETACK', payloadVersion: 1, from: '/appliance//publish', uuid: '', timestamp: 32, timestampMs: 975, sign: '6d1261848d88a0ffd79ea2387b636fa2' }, payload: { all: { system: { hardware: { type: 'mss110', subType: 'us', version: '7.0.0', chipType: 'rtl8710cm', uuid: '', macAddress: '' }, firmware: { version: '7.3.19', homekitVersion: '6.3', compileTime: '2023/06/02-16:58:57', encrypt: 1, wifiMac: '', innerIp: '10.10.10.1', server: 'mqtt.local', port: 8883, userId: 48 }, time: { timestamp: 32, timezone: '', timeRule: [] }, online: { status: 0, bindId: '', who: 0 } }, digest: { togglex: [ { channel: 0, onoff: 1, lmTime: 0 } ], triggerx: [], timerx: [] } } } }

│Device │mss110 us rtl8710cm (hardware:7.0.0 firmware:7.3.19) │ │UUID │ │ │Mac address │ │ │IP address │10.10.10.1 │ │Current MQTT broker │mqtt.local:8883 │ │Credentials │User: │ │ │Password: 48_cd55f6626f1146c799fbee3377cab427 │ │MQTT topics │Publishes to: /appliance//publish │ │ │Subscribes to: /appliance//subscribe │

POST /config Host: 10.10.10.1 Accept: application/json, text/plain, / Content-Type: application/json

{ header: { from: '', method: 'SET', namespace: 'Appliance.Config.Wifi', messageId: '9dd06cd2a64f4990ea11c872b2d076e9', timestamp: 1695711280, sign: '0067591d72122b9b549a5e9af2602bf9' }, payload: { wifi: { ssid: '', password: '' } } }

< 200 OK < content-type: application/json < connection: close < { header: { messageId: '9dd06cd2a64f4990ea11c872b2d076e9', namespace: 'Appliance.Config.Wifi', method: 'SETACK', payloadVersion: 1, from: '/appliance//publish', uuid: '', timestamp: 33, timestampMs: 460, sign: 'c82c8620f4443780167834e7f4082df1' }, payload: {} }

Device will reboot...

bytespider commented 1 year ago

Have you tried passing a user id that isn't 0. It's possible they have changed the firmware so that 0 is no longer valid.

bytespider commented 1 year ago

Closing due to inactivity