Read British Gas Hive Heating temperature

In this subforum you can show projects you have made, or you are busy with. Please create your own topic.

Moderator: leecollings

homemonitor
Posts: 1
Joined: Friday 02 October 2020 17:06
Target OS: Linux
Domoticz version:
Contact:

Re: Read British Gas Hive Heating temperature

Post by homemonitor »

How do you get it to work with the new two-factor login? My monitoring stopped working on 30/9.
Rowsdower
Posts: 3
Joined: Friday 02 October 2020 17:31
Target OS: -
Domoticz version:
Contact:

Re: Read British Gas Hive Heating temperature

Post by Rowsdower »

My script failed a couple of hours ago. Now when I try to get a session from
https://api.prod.bgchprod.info/omnia/auth/sessions
I get
{
"genericError": {
"error": {
"reason": "GONE",
"message": "Not supported anymore"
}
}
}

I can get an OAuth Bearer Token, using the Authorize button at
https://api.prod.bgchprod.info/omnia/swagger-ui.html

so instead of the header
X-Omnia-Access-Token: <SESSIONID>

you can use
Authorization: Bearer <TOKEN>

but this only lasts a while and I can't find a way to refresh it.

https://oauth.prod.bgchprod.info/oauth2/token
seems to want to play ball, but with no documentation, I can't work out what to pass it, so I always just get an Unauthorized response.
Can anyone who's better at internet protocols than me figure it out?
dgilbert2
Posts: 84
Joined: Wednesday 16 August 2017 8:08
Target OS: Raspberry Pi / ODroid
Domoticz version: 2023.1
Location: UK
Contact:

Re: Read British Gas Hive Heating temperature

Post by dgilbert2 »

My Hive scripts also stopped working at 14:30 today :cry: . My account though does not (yet?) require any two-factor login.

Maybe it will start working again soon!!?? I'm fearing not though!
orionn2o
Posts: 2
Joined: Friday 02 October 2020 21:08
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: Read British Gas Hive Heating temperature

Post by orionn2o »

Another person who's Hive dropped out today at 14:30 after working flawlessly for years :(

I wasn't specifically using a python plugin, just Bash with some Curl scripts.

Started getting the same error "not supported anymore" :(

does this mean I've now got to go get a new heating control system ...

Ive heard EvoHome is pretty good
Last edited by orionn2o on Friday 02 October 2020 21:50, edited 1 time in total.
mark.sellwood
Posts: 101
Joined: Tuesday 04 March 2014 10:33
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Surrey, UK
Contact:

Re: Read British Gas Hive Heating temperature

Post by mark.sellwood »

I'm looking to move to something else possibly Nest due to the problems with Hive.
My Hive hub drops off the internet randomity, Hive have admitted its a software issue but will not be fixing it, they have given me 2 options, pay to replace the hub or plug the hub in to a time switch & power cycle it daily.
3 x Pi, 1 Master, 2 Slaves, 1x Aeotec Z-Stick S2, 4xSP103 PIR, 5xPowerNode 1, 1xSmart Energy Switch Gen5, 4xFGSS101 Smoke Sensor, 2xFGD212, 9xFGS212 , 7xFGS221/2, 1xAD142 , 1xTKB TZ68E , 2xAeotec Multi Sensor, 3 x NodOn CRC-3-1-00.
Rowsdower
Posts: 3
Joined: Friday 02 October 2020 17:31
Target OS: -
Domoticz version:
Contact:

Re: Read British Gas Hive Heating temperature

Post by Rowsdower »

OK, I'm making progress. By using Stream (an iOS network debug tool) to sniff the protocol from the iOS Hive app, I've found that it calls

https://beekeeper-uk.hivehome.com/1.0/c ... resh-token

passing it a token, accessToken and refreshToken

It gets the same items back with new values, and "token" can be used to access the API using

--header 'Authorization: Bearer '$TOKEN

This seems to be working - it's clumsy having to get your initial tokens from Stream, but from a bit more sniffing, it seems like the initial login is a complex challenge/response interaction with AWS. So long as I set a script to refresh my tokens every 30 min though, I hopefully won't have to do this again.
dgilbert2
Posts: 84
Joined: Wednesday 16 August 2017 8:08
Target OS: Raspberry Pi / ODroid
Domoticz version: 2023.1
Location: UK
Contact:

Re: Read British Gas Hive Heating temperature

Post by dgilbert2 »

Some more clues maybe??

I looked at https://community.smartthings.com/t/hiv ... g/206851/8 and github https://github.com/alyc100/SmartThingsP ... ect.groovy, although a different platform / project, they have managed to get the hive api to work again by changing to https://beekeeper.hivehome.com/1.0/cognito/login.

I don't know though how to get this working on the scripts we use here. eg I've tried changing the login lines as below;

Code: Select all

login=$(curl  -s -k --cookie-jar cookie.jar -g -H "Content-Type: application/vnd.alertme.zoo-6.4+json" \
	-H "Accept: application/vnd.alertme.zoo-6.4+json" -H "Content-Type: 'application/*+json'" \
	-H "X-AlertMe-Client: Hive Web Dashboard" \
	-d '{"sessions":[{"username": "xx@xx", "password": "xx", "devices": false, "products": false}]}' \
	https://beekeeper.hivehome.com/1.0/cognito/login)
...but this produces an error "MALFORMED_REQUEST".

Hopefully someone who understands these scripts better than me can get it working as it does seem possible if you know what your doing ;)
dgilbert2
Posts: 84
Joined: Wednesday 16 August 2017 8:08
Target OS: Raspberry Pi / ODroid
Domoticz version: 2023.1
Location: UK
Contact:

Re: Read British Gas Hive Heating temperature

Post by dgilbert2 »

FIXED!!!

The login & sessionId sides of the script needs updating as below, which is based on Mike's older version, but it worked for me :)

(Only applicable if your still using MikeF's original V6 script.)

Code: Select all

#!/bin/bash
# Sends current and target temperatures to Domoticz

cd "${0%/*}"

login=$(curl -s -k -g -H "Content-Type: application/json" \
	-H "Accept: application/json"  \
	-d '{"username":"xx@xx","password":"xx"}' \
	https://beekeeper.hivehome.com/1.0/cognito/login)
	
sessionId=$(echo $login | python -c 'import sys, json; print json.load(sys.stdin)["token"]')
dgilbert2
Posts: 84
Joined: Wednesday 16 August 2017 8:08
Target OS: Raspberry Pi / ODroid
Domoticz version: 2023.1
Location: UK
Contact:

Re: Read British Gas Hive Heating temperature

Post by dgilbert2 »

homemonitor wrote: Friday 02 October 2020 17:10 How do you get it to work with the new two-factor login? My monitoring stopped working on 30/9.
Easiest way to get things working is to turn off two-factor login. In the Hive app go to the three bars in the top corner, Account, My Details and then edit Two Factor authentication to disabled.
mark.sellwood
Posts: 101
Joined: Tuesday 04 March 2014 10:33
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Surrey, UK
Contact:

Re: Read British Gas Hive Heating temperature

Post by mark.sellwood »

I have never setup two-factor login & its showing as disabled but still the Plugin isn't working.
3 x Pi, 1 Master, 2 Slaves, 1x Aeotec Z-Stick S2, 4xSP103 PIR, 5xPowerNode 1, 1xSmart Energy Switch Gen5, 4xFGSS101 Smoke Sensor, 2xFGD212, 9xFGS212 , 7xFGS221/2, 1xAD142 , 1xTKB TZ68E , 2xAeotec Multi Sensor, 3 x NodOn CRC-3-1-00.
dgilbert2
Posts: 84
Joined: Wednesday 16 August 2017 8:08
Target OS: Raspberry Pi / ODroid
Domoticz version: 2023.1
Location: UK
Contact:

Re: Read British Gas Hive Heating temperature

Post by dgilbert2 »

mark.sellwood wrote: Saturday 03 October 2020 13:51 I have never setup two-factor login & its showing as disabled but still the Plugin isn't working.
Got ya. Hopefully @imcfarla will update the plugin soon with the revised Hive API login details as detailed above.
Rowsdower
Posts: 3
Joined: Friday 02 October 2020 17:31
Target OS: -
Domoticz version:
Contact:

Re: Read British Gas Hive Heating temperature

Post by Rowsdower »

dgilbert2 wrote: Saturday 03 October 2020 12:25 FIXED!!!

The login & sessionId sides of the script needs updating as below, which is based on Mike's older version, but it worked for me :)

(Only applicable if your still using MikeF's original V6 script.)

Code: Select all

#!/bin/bash
# Sends current and target temperatures to Domoticz

cd "${0%/*}"

login=$(curl -s -k -g -H "Content-Type: application/json" \
	-H "Accept: application/json"  \
	-d '{"username":"xx@xx","password":"xx"}' \
	https://beekeeper.hivehome.com/1.0/cognito/login)
	
sessionId=$(echo $login | python -c 'import sys, json; print json.load(sys.stdin)["token"]')
Good jobs, thanks! This is the final piece of the jigsaw - it annoyed my having to store my login credentials on my IoT devices, but this lets me generate tokens on my laptop, then pass them over for periodic refreshing on the ESP. Thanks!
orionn2o
Posts: 2
Joined: Friday 02 October 2020 21:08
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: Read British Gas Hive Heating temperature

Post by orionn2o »

brill well done :)

back up and running again phew!

If i could ask, how did you debug this?
dgilbert2
Posts: 84
Joined: Wednesday 16 August 2017 8:08
Target OS: Raspberry Pi / ODroid
Domoticz version: 2023.1
Location: UK
Contact:

Re: Read British Gas Hive Heating temperature

Post by dgilbert2 »

orionn2o wrote: Saturday 03 October 2020 16:26 ....If i could ask, how did you debug this?
I added "echo $login" to the bash script so that I could see what was going on when manually running it in PuTTY.
I'm sure there are much smarter ways though ;)
imcfarla
Posts: 64
Joined: Monday 04 December 2017 13:18
Target OS: Linux
Domoticz version:
Contact:

Re: Read British Gas Hive Heating temperature

Post by imcfarla »

Panic over I have updated both the plugin.py and plugin.urllib.py
both are now version 1.2 and should handle the new login API
dgilbert2
Posts: 84
Joined: Wednesday 16 August 2017 8:08
Target OS: Raspberry Pi / ODroid
Domoticz version: 2023.1
Location: UK
Contact:

Re: Read British Gas Hive Heating temperature

Post by dgilbert2 »

imcfarla wrote: Sunday 04 October 2020 0:04 Panic over I have updated both the plugin.py and plugin.urllib.py
both are now version 1.2 and should handle the new login API
Where do you download these files from? Thanks

EDIT:
Found them ;) https://github.com/imcfarla2003/domoticz-hive/
dgilbert2
Posts: 84
Joined: Wednesday 16 August 2017 8:08
Target OS: Raspberry Pi / ODroid
Domoticz version: 2023.1
Location: UK
Contact:

Re: Read British Gas Hive Heating temperature

Post by dgilbert2 »

imcfarla wrote: Sunday 04 October 2020 0:04 Panic over I have updated both the plugin.py and plugin.urllib.py
both are now version 1.2 and should handle the new login API
@imcfaria

I still use the original bash script by MikeF and have found the Logout section no longer works (so have #'ed it out for now). I see the equivalent "def onStop(self)" in your plugin code also has remarks that its not currently working. I would be interested how you manage to fix this in the future so I can go back and update my bash scripts. I guess though this is a "nice to have" for now, to end the session rather than keep asking for new tokens. At least the main parts are all working now :D
Och
Posts: 2
Joined: Sunday 14 September 2014 14:43
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Read British Gas Hive Heating temperature

Post by Och »

imcfarla wrote: Sunday 04 October 2020 0:04 Panic over I have updated both the plugin.py and plugin.urllib.py
both are now version 1.2 and should handle the new login API
Thank you! :D

My system failed on Friday and I had to rebuild yesterday. It took me a few hours to work out that the Hive plug-in not working was nothing to do with me rebuilding the system. Great to have the plug-in updated so quickly.
roadsnail
Posts: 39
Joined: Wednesday 08 November 2017 20:42
Target OS: Raspberry Pi / ODroid
Domoticz version: 13314
Location: UK
Contact:

Re: Read British Gas Hive Heating temperature

Post by roadsnail »

imcfarla wrote: Sunday 04 October 2020 0:04 Panic over I have updated both the plugin.py and plugin.urllib.py
both are now version 1.2 and should handle the new login API
Thank you for the quick fix!

BTW. I am still running a very of version of plugin.urllib.py so I was able to fix my old version by patching GetSessionID from your github version. But in doing so I spotted that you need to add a close curly bracket to the end of line 806, (only in the plugin.urllib.py version), else a syntax error is thrown at execution time.

ie line 806...
payload = {'username':Parameters["Username"], 'password':Parameters["Password"]

becomes
payload = {'username':Parameters["Username"], 'password':Parameters["Password"]}

Thanks again!

Cheers
Chris
_______________________________________________________________________________________________
Pi4, Z-Wave: Danfoss TRVs, aeotec hem, d-link siren, heiman door contacts. Hive heating ctrl, esp8266 based sensors, zigbee2mqtt, Zigbee bulbs etc
imcfarla
Posts: 64
Joined: Monday 04 December 2017 13:18
Target OS: Linux
Domoticz version:
Contact:

Re: Read British Gas Hive Heating temperature

Post by imcfarla »

Fixed that now - thanks
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests