Robdel12 / homebridge-meross-plug

Homebridge plugin for the meross MSS110 plug
15 stars 6 forks source link

getOnCharacteristicHandler #5

Closed cfgCarl closed 5 years ago

cfgCarl commented 5 years ago

Hi there,

I worked a little Bit and looked for the HTTP Requests of the Meross App, so now the getOnCharacteristicHandler is working (at my house). I finally used for the coding the Original MessageID, Sign and Timestamp.

For a Meross Plugbar i had touse diffrent channels, so I added those to the Config.

ghost commented 5 years ago

Hey man, thanks for your contribution. I'm seeing the following error at console after installing your commit, any ideas?

[3/2/2019, 2:51:33 PM] Homebridge is running on port 51827.
^[[B^[[B^[[B^[[B^[[B(node:42235) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'onoff' of undefined
    at MerossPlug.getOnCharacteristicHandler (/Users/x/homebridge-meross-plug/src/index.js:173:91)
    at process._tickCallback (internal/process/next_tick.js:68:7)
(node:42235) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:42235) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
cfgCarl commented 5 years ago

Hey man, thanks for your contribution. I'm seeing the following error at console after installing your commit, any ideas?

[3/2/2019, 2:51:33 PM] Homebridge is running on port 51827.
^[[B^[[B^[[B^[[B^[[B(node:42235) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'onoff' of undefined
    at MerossPlug.getOnCharacteristicHandler (/Users/jackpearce/homebridge-meross-plug/src/index.js:173:91)
    at process._tickCallback (internal/process/next_tick.js:68:7)
(node:42235) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:42235) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Hi @jackpearcecom, It look like in the Response of the plug, it can't find the onoff-stuff.

Did you add the channel in the config? Example: { "accessory": "Meross", "name": "Wäschetrockner", "deviceUrl": "http://...", "authToken": "Basic XYZ", "channel": 0 }

If so: You can try to edit your index.js (/Users/jackpearce/homebridge-meross-plug/src/index.js) in line 173 from this.log('lucky, status:', response.payload.all.digest.togglex[${this.config.channel}].onoff) to this.log('lucky, status:', response) and look if you can see a response in the log. If so keep going an try this.log('lucky, status:', response.payload.all.digest.togglex) Maybe you have a diffrent plug with a diffrent response structure which we can see then.

ghost commented 5 years ago

Thank you @cfgCarl, it's working now I added "channel": 0 to my config

Robdel12 commented 5 years ago

It’s a rainy weekend so I’m hoping to give this a try and if all is well I’ll merge 😃

cfgCarl commented 5 years ago

Great to hear @jackpearcecom ! It‘s my first Pull request and first coding for HomeBridge

Sent with GitHawk

cfgCarl commented 5 years ago

It’s a rainy weekend so I’m hoping to give this a try and if all is well I’ll merge 😃

@Robdel12 It‘s rainy in Germany too 😅

Maybe some words to the channel. With my pull request you have to use it in the config as described above. It’s no difference with the normal plugs, but it adds support for MSS425. Channel 0 are all plugs in the plug strip at once and channel 1-X are for each plug.

In the response the one-off status is separated for each channel, even when there is only one channel.

Any questions? (hopefully you can understand my great english😂)

Sent with GitHawk

Robdel12 commented 5 years ago

Hey @cfgCarl, thank you for the PR! Sorry it took me so long to get around and merge this. I appreciate the time you put in. I should be releasing a new version of this with these changes after #6 gets merged through 👍