Community
OpenEnergyMonitor

Community

Monitoring Hive v6

Tags: #<Tag:0x00007fc33aca5a58>

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 https://flows.nodered.org/flow/62e04c333b192f6119d9d5b72f675d5f 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.