Monitoring Hive v6

I’ve previously used node-red to get weather data from darksky and into emoncms. I’ve just got a BG Hive and found that it’s possible to use an undocumented api to get data data from it and to write commands to it. So far I’ve used a combination of http://www.smartofthehome.com/2016/05/hive-rest-api-v6/ and Hive Hot Water boost control example. (flow) - Node-RED to get started. I can log in. I can read nodes and channels. But I can’t get anything back when I try to read the temperature and targetTemperature channel data from the receiver node. It needs start and end times (unix seconds), but having tried a variety of times over the last day or so, I just keep getting the error ‘no data available’. Just wondering if anyone else has successfully read temperature and targetTemperature this?

Hi,

I recently took on this challenge myself. Below is how I achieved it using node-red.
The only thing you may need to change this the index of your devices in the data.products array.

e.g data.products[1] maybe data.products[0] for you or you may have many more devices. Add a debug and log the response from the http to inspect.

inject → function → http → function → mqtt

function - Set Headers For Login

msg.payload = {"username":"USERNAME","password":"PASSWORD","devices":true,"products":true,"actions":true,"homes":true};
msg.headers = {};
msg.headers['Sec-Fetch-Dest'] = 'empty';
msg.headers['User-Agent'] = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.132 Safari/537.36';
msg.headers['Content-Type'] = 'application/json';
msg.headers['Accept'] = '*/*';
msg.url = 'https://beekeeper.hivehome.com/1.0/global/login'
return msg;

http - Login To Hive
http

function - Parse and extract target temperature

var data = JSON.parse(msg.payload);

msg.payload = data.products[0].state.target;
return msg;

Send Target Temperature to MQTT
image

Repeat the steps for the other values

function - Parse and extract Hot Water Status

var data = JSON.parse(msg.payload);
msg.payload = data.products[1].state.status == "OFF" ? 0 : 1;
return msg;

function - Parse and extract Current Temperature

var data = JSON.parse(msg.payload);
msg.payload = data.products[0].props.temperature;
return msg;

function - Parse and extract Heating Status

var data = JSON.parse(msg.payload);

msg.payload = data.products[0].props.working ? 1 : 0;
return msg;

This is my current logging of all this information. Interesting to observe.

Been working with something similar to this, but recently getting a combination of 403 and 500 responses, seems to be UserAgent related - anyone spotted this, got a resource around what these guys keep changing in their API

Hi Pete, welcome to OEM. This is quite an old thread so can you be more specific about your setup and what you’re doing, have tried as the original users in this discussion may not be about.

Are you using nodered?

There have been lots of changes with hive recently, they changed api, again. They changed url to “beekeeeper” (exclusively) not so long ago, and more recently at the end of 2020 they moved to an AWS server which has introduced a different authentication level.

If you checkout the hivehome threads on openhab, home assistant and domoticz you will find many users experienced authentication errors and someone worked out how to use NPM to get an initial auth token which could then be used and regularly renewed in other softwares.

I use Python and used to communicate with hive without a library, now I use pyhiveapi (via pip) as they too have now cracked that initial authentication token api. Although intended for Home Assistant, it can be used freestanding which is how I use it currently.

I know nothing of nodered or how their hive integration works and where it’s at currently, but there’s been lots going on at hive to contend with.

Paul,

Thanks, originally i was using the bgchprod.info version, this worked for a number of years and happily grabbed data from hive (i haven’t been doing any command pushes) - This was all setup in node-red and pushed to an influxDB displayed by Grafana.

It all died a while back when i got the same “NOT_SUPPORTED_ANYMORE” messages and i quickly moved to update this to the beekeeper address, with some minor updates to the headers to cope with the API changes, had this running for a couple of months, until about 4pm on Wednesday i started getting 500 errors back. Here is my really simple call vis http post through NodeRed:

msg.payload = {'username':'[email protected]', 'password':'XXX','devices':true,'products':true,'actions':true,'homes':true}

msg.headers = {"Accept": "*/*","Accept-Encoding": "gzip, deflate, br","Accept-Language": "en-US,en;q=0.9,en-GB;q=0.8","Access-Control-Request-Headers": "content-type","Origin": "https://my.hivehome.com","Referer": "https://my.hivehome.com/","Sec-Fetch-Dest": "empty","Sec-Fetch-Mode": "cors","Sec-Fetch-Site": "same-site",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.141 Safari/537.36"}

msg.url = 'https://beekeeper.hivehome.com/1.0/cognito/login'

I was then processing the JSON output that returned, pushing it straight into Influx.

Since yesterday i have downloaded and am using pyhiveapi, really simple configuration, running the console command and grabbing the output (this time it comes back in YAML) which is easy to process again. So, for now its working again - but mi sure it could be more efficient, and probably more feature rich.

That’s pretty much where I’m at now and as I have more pressing things to do, I can see it staying that way for a while. Good to hear you’re back up and running (for now at least :roll_eyes:)

Hi, really interesting thread. I’m interested in just reading the Target and Actual temperature from Hive and I was wondering if anyone is still able to use that flow or if the only route now is as you describe @peteshoard to use pyhiveapi?
If so, apologies I’m new to all of this, if it is coming back in YAML how are you processing that for use in emoncms?
Thanks Brian

The API stopped working for me, the schema has completely changed as has the authentication I think. You can use the python script with node red pretty easily and cut up the output with a little bit of Java (happy to share an example) but another way is to link to Home assistant and use an automation to publish the data to influx or to an MQTT broker.

I’ve been using a Home Assistant integration which works well, but haven’t managed to get the data into influx yet. how do you do that @peteshoard?

that would be really helpful Pete

Give me a day or so and I’ll write up a tutorial