flick116 / MMM-Hive

A module for the MagicMirror project (https://github.com/MichMich/MagicMirror) to display inside / outside temperature from your Hive receiver
MIT License
3 stars 0 forks source link

Two Factor Auth Issue #4

Closed pjestico closed 3 years ago

pjestico commented 3 years ago

I have two factor auth enabled on my account after repeated badgering from the App to enable it. This prevents the module from logging in. Is there a fix planned for this?

flick116 commented 3 years ago

Hi,

I need to look into this as it looks like they have changed the authentication.

sithlordhood commented 3 years ago

Hi, Any update at all? I really want to get this module back up and working on my mirror!

flick116 commented 3 years ago

Hi, I have been looking into this. Seems like British Gas are now using Amazon Web Services for the authentication. Some clever folks look to have worked out what is needed to connect, but I am not sure whether the solution will work with Magic Mirror where you have no interaction bar the initial module setup. I'll look into it in a bit more detail at the weekend

flick116 commented 3 years ago

Changes have been made to use the new login method. I've tested it to a certain extent and it all appears to be working. Give it a test and let me know...

flick116 commented 3 years ago

Caveat to these changes - you will need to disable 2FA initially, and once the install process has been followed 2FA can be re-enabled.

sajkhanvict commented 3 years ago

Hey, thank you so much for this module.

we got 2 issues, number one: the file index.js doesnt exist in MMM-Hive/tokenGeneration

and secondly: if we ignore above and continue with editing index file.

after adding (login('xxxx@xxxxxx.com','xxxxxxxxx')): to the bottom of the file. we get the following error:

pi@magicmirror:~/node_modules/amazon-user-pool-srp-client $ node /home/pi/node_modules/amazon-user-pool-srp-client/index.js > /home/pi/node_modules/amazon-user-pool-srp-client/HiveTokens.json /home/pi/node_modules/amazon-user-pool-srp-client/index.js:122 (login('xxxxx.com','xxxxxx')): ^

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 Function.Module.runMain (internal/modules/cjs/loader.js:831:12) at startup (internal/bootstrap/node.js:283:19) at bootstrapNodeJSCore (internal/bootstrap/node.js:623:3)

can you please suggest what i should do as i have deleted and installed multiple times and followed everything as requested.

Thank you

sithlordhood commented 3 years ago

Hi, I have tried to get it working tonight and still have an issue:

[2021-04-02 23:11:02.108] [ERROR] Whoops! There was an uncaught exception... [2021-04-02 23:11:02.111] [ERROR] Error: ENOENT: no such file or directory, open '/home/pi/node_modules/amazon-user-pool-srp-client/HiveTokens.json' at Object.openSync (fs.js:447:3) at Object.func (electron/js2c/asar.js:138:31) at Object.func [as openSync] (electron/js2c/asar.js:138:31) at Object.readFileSync (fs.js:349:35) at Object.fs.readFileSync (electron/js2c/asar.js:580:40) at Object.fs.readFileSync (electron/js2c/asar.js:580:40) at Class.getData (/home/pi/MagicMirror/modules/MMM-Hive/node_helper.js:41:24) at Class.socketNotificationReceived (/home/pi/MagicMirror/modules/MMM-Hive/node_helper.js:136:9) at Socket. (/home/pi/MagicMirror/js/node_helper.js:112:11) at Socket.emit (events.js:200:13) { errno: -2, syscall: 'open', code: 'ENOENT', path: '/home/pi/node_modules/amazon-user-pool-srp-client/HiveTokens.json' } [2021-04-02 23:11:02.129] [ERROR] MagicMirror will not quit, but it might be a good idea to check why this happened. Maybe no internet connection? [2021-04-02 23:11:02.133] [ERROR] If you think this really is an issue, please open an issue on GitHub: https://github.com/MichMich/MagicMirror/issues

I did a git pull && npm install with 2FA disabled on the hive app, then enabled 2FA and reloaded MM

Thanks!

flick116 commented 3 years ago

Hi,

Realised this morning I'd forgotten the index.js 🤦‍♂️

It's there now though, so please use that file when following the install. When you open the file you will see at the bottom there is already a section to add your Hive username and password, so overwrite the xxxxx's with your details so it should end up like this (I've included extra lines from the file to make it easier to see where to edit):

    })
        .then(({ AuthenticationResult }) => {
              console.log('{"token":"'+AuthenticationResult.IdToken+'",'+
                          '"refreshToken":"'+AuthenticationResult.RefreshToken+'",'+
                          '"accessToken":"'+AuthenticationResult.AccessToken+'"}')

              })
  })
}

login('hive@hive.com','P@55W0RD')

Once that's edited, save and you should be good to follow the remaining steps.

sithlordhood commented 3 years ago

Working perfectly now!! Thanks so much for your effort and a great module!

flick116 commented 3 years ago

Fantastic - glad it's working 👍 and thanks for letting me know

flick116 commented 3 years ago

Just in case you wanted to add it, I also added a batteryIcon option in this release that shows the Thermostat battery. It hasn't been fully tested, but looks to work correctly.

sithlordhood commented 3 years ago

Tried the batteryIcon but i dont see any change on the module :(

flick116 commented 3 years ago

Oh, that's disappointing. Just tested again on my end and you should see it next to the inside temperature (as per the below, highlighted in the red square). Can you send me you config.js for the MMM-Hive (blank out the username / password if they are still in the file).

batteryIcon

sithlordhood commented 3 years ago

Definetly no icon, config below:

                    module: "MMM-Hive",
                    header: "Hive",
                    position: "top_right",
                    config: {
                            temperatureSuffix: "°C",

// username: "xxx", // password: "xxx", postcode: 'xxx', updateInterval: '120000', //60000 is 1 minute showNext: true, //shows target temp insideIconSet: 'fa fa-fire', //fa fa-fire or fa fa-home or any font awesome font insideText: 'Hallway', highestTemp: '24', // full icon temp highTemp: '20', // 3/4 icon temp lowTemp: '18', // 1/2 icon temp lowestTemp: '15', // 1/4 icon temp, below this will show empty batteryIcon: 'true', //displays battery level of thermo animatedLoading: 'true', //animates loading image }, },

i have commented out the username and password from the file, i guess now 2FA is used it does not need them here?

flick116 commented 3 years ago

Can you remove the single quotes either side of the true settings for batteryIcon and animatedLoading same as below:

{
    module: "MMM-Hive",
    header: "Hive",
    position: "top_right",
    config: {
        temperatureSuffix: "°C",
        // username: "xxx",
        // password: "xxx",
        postcode: 'xxx',
        updateInterval: '120000', //60000 is 1 minute
        showNext: true, //shows target temp
        insideIconSet: 'fa fa-fire', //fa fa-fire or fa fa-home or any font awesome font
        insideText: 'Hallway',
        highestTemp: '24', // full icon temp
        highTemp: '20', // 3/4 icon temp
        lowTemp: '18', // 1/2 icon temp
        lowestTemp: '15', // 1/4 icon temp, below this will show empty
        batteryIcon: true, //displays battery level of thermo
        animatedLoading: true, //animates loading image
    },
},
sithlordhood commented 3 years ago

Its working great now after this suggestion, thanks again!