[OBSOLETE] - Hive (Connect) V3.2c (British Gas Hive)

@Alyc100
Maybe I celebrated too soon :pensive:

If I change my Hive Heating externally to ST, i.e. using the actual Hive app, ST does seem to detect and reflect whatever the change was (for example, changing from off to boost).

However, the controls for Hive Heating in the ST app don’t seem to perform any changes at all. Changing temp or changing mode, it thinks about it for a few seconds and then just gives up and keeps whatever the setting was before.

So it only seems to be a one way thing. The Hive Connect ST smartapp can read changes fine, it just can’t make changes itself.

Has anyone else experienced this?

1 Like

@Alyc100
ST IDE log output for the Hive (Connect) smartapp shows messages about the authorization header needing certain parameters, as shown in the attached screenshot.

Very strange. I just had a look at mine. I’m not getting any of those errors you’re seeing and also changing the values in the device handler synchronises with Hive just fine. Anyone else having issues?
Screenshot 2020-12-06 at 23.52.01

It still the same for me. In Simulation I can see list of my devices but in app there is “Tap to refresh authenticaton”.

When you are in the app and tap the area that says ‘Tap to refresh Authentication’ make sure you have Live Logging open and let me know if you see any error messages that appear in there. Make sure that you don’t post any tokens in this public forum.

When I create the HiveToken file (step 10), the file is created but it is blank with no token string shown.
Any ideas what I’ve done wrong.

Any help is greatly appreciated.

You probably have 2 factor authentication enabled on your account. Turn it off in your Hive mobile app. Then generate tokens.

Thanks Alex but 2FA was already off.

When running ‘node index.js > HiveToken.json’
Even though it is creating the file, I am getting the following:

c:\Users\glenb\node_modules\amazon-user-pool-srp-client>node index.js > HiveTokens.json
c:\Users\glenb\node_modules\amazon-user-pool-srp-client\index.js:144
const userPoolId = process.env.CognitoUserPoolUsers.split(’_’)[1]
^

TypeError: Cannot read property ‘split’ of undefined
at login (c:\Users\glenb\node_modules\amazon-user-pool-srp-client\index.js:144:55)
at Object. (c:\Users\glenb\node_modules\amazon-user-pool-srp-client\index.js:179:1)
at Module._compile (internal/modules/cjs/loader.js:1063:30)
at Object.Module._extensions…js (internal/modules/cjs/loader.js:1092:10)
at Module.load (internal/modules/cjs/loader.js:928:32)
at Function.Module._load (internal/modules/cjs/loader.js:769:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
at internal/main/run_main_module.js:17:47

I see Andrew (post 353) had the same issue but resolved it with a reboot. But that did not work for me.

The environment variables in step 9 haven’t been defined properly. If using Windows 10, you need the commands
$env:CognitoUserPoolUsers = ‘eu-west-1_SamNfoWtf’ and then
$env:CognitoUserPoolClientWeb = ‘3rl4i0ajrmtdm8sbre54p9dvd9’

If that fails, you can always edit the index.js to hardcode these values.
replace all occurrences of process.env.CognitoUserPoolClientWeb (appears twice) with '3rl4i0ajrmtdm8sbre54p9dvd9'

and all occurrences of process.env.CognitoUserPoolUsers (appears once) with 'eu-west-1_SamNfoWtf'

so for example the line (appears twice in index.js)
ClientId: process.env.CognitoUserPoolClientWeb
becomes
ClientId: '3rl4i0ajrmtdm8sbre54p9dvd9'

and the line (appears once in index.js)
const userPoolId = process.env.CognitoUserPoolUsers.split('_')[1]
becomes
const userPoolId = 'eu-west-1_SamNfoWtf'.split('_')[1]

Alex, that has worked and I now have a token string.
Thanks so much for your help.
British Gas should be paying you for this!!

Please post an update if you get this working. Need to get an indication on the number of successes versus number of issues.

I know people are more likely to post if they have an issue and keep quiet if it works as expected.

Alex,
All seems to be working well. I can control my Hive devices (Heating, bulbs and smart plugs) from Smartthings/ActionTiles, with feed back received from all devices as well.
Again, thanks so much for your help.

1 Like

For me is still the same. When i started whole process again i had “Tap to refresh authentication” and after some time it changes to “Authenticated as null. Tap to refresh authentication” (I’m doing that on Linux (debian 10) and on Windows 10) .

That is my log from Simulation when I’m pressing “updateDevices”: https://pastebin.com/qmQKh6M6 (ofc. i hid all tokens)
And log from " Live Logging" on IDE when I’m opening Hive (Connect) app and pressing “Done” in SmartThigs: https://pastebin.com/DRWjQvew

I think your integration might be working. Check your devices. The username isn’t actually being populated from an API like I thought, it’s just a value I had hanging around from an old value I had typed in with the older version of the smart app (doh!).

Will look to update this in the code, but I think you’re actually up and running.

EDIT: Update code to 3.2c from Github. Removed username reference as it’s redundant. Should now say AUTHENTICATED if working or NOT AUTHENTICATED.

Remember when you update from GitHub, you will have to paste in HiveTokens.json content again. You probably shouldn’t have to regenerate again though. Just copy the last value generated.

Now in Hive (Connect) I can see “AUTHENTICATED. Tap to refresh authentication” but when I want to click “Devices” I have nothing to select (only black screen with “Next” on the bottom). When I press “Next” I’m getting “We.re having trouble connection. Check your network connection and try agian.”

Log from “Live Logging” of that process: https://pastebin.com/jYcLGd37

Ah. There was a missing def on that line from when I was playing about with some code. I’ve updated GitHub but you can quickly fix by changing line 1197 as below:

resp = apiGET("/products") to
def resp = apiGET("/products")

Save, publish and try again.

1 Like

Now I can see all of my devices buy when I’m pressing “Done” after select all of them there is a Error “We’re having trouble connection. Check your network connection and try again.”

But! Some devices has added (about 4 or 5). After repeat that process i had the same error but again has been added 4 or 5 devices. I was repeating that few times until all devices has been added. Everything is working now <3

Error Log: 16:47:40: error java.util.concurrent.TimeoutException: Execution time exceeded 20 app execution seconds: 422751915047418 @line -1 (doCall)

You are the best! :wink:

Thanks Alex, all working now for me in the ST Cloud.

I did try porting the app back into HE, but received the error

‘Error: No signature of method: user_app_alyc100_Hive__Connect__289.findChildAppByName() is applicable for argument types: (org.codehaus.groovy.runtime.GStringImpl) values: [Hive (Connect)]’

after hitting ‘Next’ following successful authentication. Not sure if it’s an obvious issue with the porting of the app (before Hive messed around with the authentication there wasn’t any problem using the previous SmartApp code).

Thanks for all your help!
Guy

I’m finding the devices go offline after a while, can’t quite work out the timings yet.

It’s odd, as I log the temperature data to Grafana via a Google Sheets smart app, and that’s still pulling the data.

So seems they are updating, just showing as offline, so can’t control directly through SmartThings.

Changing and reading data through webcore works fine though…

@Alyc100
I was being dumb.

I hadn’t realised that you had updated the Hive Heating DTH back in mid-October, to reflect a URL change. So I was running an older version of that DTH.

I have now updated the Hive Heating DTH to the latest from your GitHub, as well as updated the Hive (Connect) smartapp to the latest v3.2c.

Regenerated the HiveTokens.json file again and pasted its contents into the smartapp in ST IDE at the appropriate line.

Now my new ST app reads the thermostat data AND the controls work again (thanks to updating the DTH) :blush:

I see AUTHENTICATED in the smartapp and all looks to be working as expected again.

Thanks again for all your work and help on this, always appreciated. I just hope BG doesn’t decide to mess things up for us again anytime soon :face_with_symbols_over_mouth:

Thanks again, Alex.