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

Post Reply
MikeF
Posts: 350
Joined: Sunday 19 April 2015 0:36
Target OS: Raspberry Pi / ODroid
Domoticz version: V2022.2
Location: UK
Contact:

Read British Gas Hive Heating temperature

Post by MikeF »

I'm using the Hive Heating system from British Gas in the UK, which provides wireless control of central heating and hot water. As well as the Hive iOS and Android apps, there is a Hive website, with a number of underlying APIs / JSON commands.

I have put together a python script (attached) to read the current (inside) and target heating temperatures, and send these to Domoticz.

To use this, do the following:
1. Create 2 dummy temperature devices (one for inside, and one for target), and note their IDx's
2. Download the attached zip file
3. Unzip and edit the python file with your own values: Hive and Domoticz logins(*), Domoticz url and IDx's
(* I've commented out the Domoticz authentication at line 49, but you can uncomment this if you use authentication)
4. Place the file in the Domoticz script folder
5. Create a crontab which runs the script every x minutes (I run mine every 10); my crontab looks like this:

Code: Select all

 */10 * * * *  python /home/pi/domoticz/scripts/hive2domo.py 
Let me know if you have any issues with this - I'll try to help.

I have separately created a lua script to set the target temperature (thermostat setpoint), and I'll include this in another post.

Mike
Attachments
hive2domo.py.zip
(1.63 KiB) Downloaded 645 times
MikeF
Posts: 350
Joined: Sunday 19 April 2015 0:36
Target OS: Raspberry Pi / ODroid
Domoticz version: V2022.2
Location: UK
Contact:

Set British Gas Hive Heating temperature

Post by MikeF »

Following on from my previous post, I've also created a lua script to set the Hive target temperature (thermostat setpoint)
- setting this above the current temperature should turn the heating on, and below should turn it off.

To use this, do the following:
1. Create a dummy thermostat device, and note its device name
2. Download the attached zip file
3. Unzip and edit the lua file with your own values: Hive login, Domoticz thermostat device name
4. Place the file in the Domoticz lua script folder

The thermostat device should appear on the Utility tab on the Domoticz webpage. Clicking on the device's icon will bring up a separate box with up / down arrows and a Set icon. Use these to increase / decrease the target temperature. You can check that this has been successfully changed on the physical wall thermostat and the Hive apps / website.

Note: you may need a recent version of Domoticz to get the thermostat setpoint device - I'm using V2.2418.

Let me know if this works, or if you have any issues.

Mike
Attachments
script_device_thermostat.lua.zip
(1.2 KiB) Downloaded 358 times
User avatar
1bigwink
Posts: 11
Joined: Wednesday 17 June 2015 21:07
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Wiltshire, UK
Contact:

Re: Read British Gas Hive Heating temperature

Post by 1bigwink »

Hi Mike,
Thanks very much for sharing this useful script. I'm having some problems with my Hive (2) in getting this to work... have followed the instructions but my target and room temp stay as zero - the Thermostat however does update ok. I have checked the logs and can't see any errors, cron appears to work ok without errors. Here is my config...

hiveuser = "[email protected]"
hivepass = "my_hive_password"
domouser = "DOMOTICZ_USERNAME"
domopass = "DOMOTICZ_PASSWORD"
insideIDx = "123AA"
targetIDx = "123AB"
baseURL = 'http://192.168.2.24:8080/json.htm?type= ... e&nvalue=0'

I noticed the original file didn't have quotations around the IDx's so I have tried with and without these - also tried both versions using the IDx value and the ID value of my 2 dummy temp switches. Any idea what could be causing the 2 dummy switches to not update?

Thanks in advance,
dk
1x RasPi, RFXtrx433e, v5 Aeon ZWave, MD210R Door Contacts, MC335R PIRs, MD326 Siren, 25 x MiLight RGBW Bulb (4 x WiFi Contoller), 12 IP Cam, Fibaro FGS221, 5x433mhz venetian blind, 433mhz TV ceiling lift.
Next: Touchscreen + frontpage.html
MikeF
Posts: 350
Joined: Sunday 19 April 2015 0:36
Target OS: Raspberry Pi / ODroid
Domoticz version: V2022.2
Location: UK
Contact:

Re: Read British Gas Hive Heating temperature

Post by MikeF »

Hi dk,

Sorry to hear you're having problems with this.

The IDx's don't need quotes, e.g.,
insideIDx = 30

I did say in my original post that I had commented out line 49, as I wasn't using authentication. If you're using authentication, you'll need to uncomment this line.

You could also uncomment line 87, and see what values you get for inside and target.

Hope this helps.

Mike
User avatar
1bigwink
Posts: 11
Joined: Wednesday 17 June 2015 21:07
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Wiltshire, UK
Contact:

Re: Read British Gas Hive Heating temperature

Post by 1bigwink »

Ace thanks Mike - did those changes and found a rogue quotation I had left in. Works great now.

Can you suggest any way to keep the stat value in sync if it's changed locally? I notice that if the temperature is changed via the Hive app (or locally on the Thermostat) then the temperature on the Domoticz thermostat becomes out of sync. I did think about setting a blockly to run every few minutes to update the Thermostat value from the target temp value, but this would only work if I could define a 'on change' event in blockly, which I can't find. I could set it to update periodically, but that would overwrite any local change if the blockly runs before the cron has updated the value of the target temp after it's been set locally.

Thanks again for sharing your script!
1x RasPi, RFXtrx433e, v5 Aeon ZWave, MD210R Door Contacts, MC335R PIRs, MD326 Siren, 25 x MiLight RGBW Bulb (4 x WiFi Contoller), 12 IP Cam, Fibaro FGS221, 5x433mhz venetian blind, 433mhz TV ceiling lift.
Next: Touchscreen + frontpage.html
MikeF
Posts: 350
Joined: Sunday 19 April 2015 0:36
Target OS: Raspberry Pi / ODroid
Domoticz version: V2022.2
Location: UK
Contact:

Re: Read British Gas Hive Heating temperature

Post by MikeF »

I've not had any success writing the 'actual' temperature to the thermostat - as others have reported elsewhere: http://www.domoticz.com/forum/viewtopic.php?f=6&t=4347.
SDISDI
Posts: 17
Joined: Wednesday 09 March 2016 9:18
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.4834
Contact:

Re: Read British Gas Hive Heating temperature

Post by SDISDI »

Thanks for your scripts Mike. I bought Hive last week and your scripts help me integrate to Domoticz straight away. I'm pretty new to this so just at the stage where I'm lifting other people's scripts! ;) Did you ever look at integrating the hot water control (or maybe you don't have that in your system?). It would be nice to see the status and boost from Domoticz. It looks more complex since I thing you need to retrieve the HUB ID and MAC ADDRESS first.

Code: Select all

https://api.hivehome.com/v5/users/<YOUR HIVE LOGIN>/hubs/<HUB ID>/devices/hotwatercontroller/<HUB MAC ADDRESS>/controls
Cheeky to ask but wondered if anyone else had done it. Also any pointers to the API since I haven't found full documentation yet, and if I could get hold of it I have a colleague who can probably work with me on it.

Cheers.
RFXtrx433E
Hive 2 Active Heating
Owl CM180 Energy Monitor
Various HomeEasy Receivers
LightwaveRF Plug-in sockets
MikeF
Posts: 350
Joined: Sunday 19 April 2015 0:36
Target OS: Raspberry Pi / ODroid
Domoticz version: V2022.2
Location: UK
Contact:

Re: Read British Gas Hive Heating temperature

Post by MikeF »

Hello SDISDI,

I'm guessing you've got a Hive 2 (with the shiny thermostat, rather than the boring plain white one)? With the introduction of Hive 2, BG changed the API - the version you've quoted (and in my scripts) is v5, whereas the latest is v6 (v5 still works, presumably for backwards compatibility with Hive 1).

The new API is quite different - see dannydev's post on Nov 12 2015: http://britishgashive.freeforums.org/au ... t7-40.html (it was this thread which gave me the original inspiration for my scripts).

I haven't yet converted my scripts to v6 - and yes, I do have hot water control - and boost is only available with Hive 2. I have, though, recently been playing around with curl, and have created the boost script below. You will need to insert your own username and password, and you can also delete the echo statements if you don't want to see the (lengthy!) JSON outputs from the curl statements. In the last curl statement, you can change the boost duration and temperature - you could even make the script interactive, and prompt for these!

Code: Select all

#!/bin/bash


login=$(curl -s -k --cookie-jar cookie.jar -g -H "Content-Type: application/vnd.alertme.zoo-6.1+json" \
	-H "Accept: application/vnd.alertme.zoo-6.2+json" -H "Content-Type: 'application/*+json'" \
	-H "X-AlertMe-Client: Hive Web Dashboard" \
	-d '{"sessions":[{"username":"<YOUR USERNAME>", "password":"<YOUR PASSWORD>"}]}' \
	https://api.prod.bgchprod.info:443/omnia/auth/sessions)
	
echo $login | python -m json.tool

sessionId=$(echo $login | python -c 'import sys, json; print json.load(sys.stdin)["sessions"][0]["sessionId"]')
	
echo $sessionId

nodes=$(curl -s -k --cookie-jar cookie.jar -g -H "Content-Type: application/vnd.alertme.zoo-6.2+json" \
	-H "Accept: application/vnd.alertme.zoo-6.2+json" -H "Content-Type: 'application/*+json'" \
	-H "X-AlertMe-Client: swagger" -H 'X-Omnia-Access-Token: '"$sessionId" \
	https://api.prod.bgchprod.info:443/omnia/nodes)
	
echo $nodes | python -m json.tool

nodeId=$(echo $nodes | python -c 'import sys, json; print json.load(sys.stdin)["nodes"][3]["id"]')

echo $nodeId

temp=$(curl -s -k --cookie-jar cookie.jar -X PUT -H "Content-Type: application/vnd.alertme.zoo-6.2+json" \
	-H "Accept: application/vnd.alertme.zoo-6.2+json" -H "Content-Type: 'application/*+json'" \
	-H "X-AlertMe-Client: swagger" -H 'X-Omnia-Access-Token: '"$sessionId" \
	-d '{"nodes":[{"attributes":{"activeHeatCoolMode":{"targetValue":"BOOST"},"scheduleLockDuration":{"targetValue":30},"targetHeatTemperature":{"targetValue":22}}}]}' \
	"https://api.prod.bgchprod.info:443/omnia/nodes/${nodeId}")
When I get round to converting my scripts to v6 of the API, I'll post them here.

Mike
SDISDI
Posts: 17
Joined: Wednesday 09 March 2016 9:18
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.4834
Contact:

Re: Read British Gas Hive Heating temperature

Post by SDISDI »

That's awesome thanks. I'll try it out when I get some time.
RFXtrx433E
Hive 2 Active Heating
Owl CM180 Energy Monitor
Various HomeEasy Receivers
LightwaveRF Plug-in sockets
SDISDI
Posts: 17
Joined: Wednesday 09 March 2016 9:18
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.4834
Contact:

Re: Read British Gas Hive Heating temperature

Post by SDISDI »

This seems to be working pretty well now if anyone has the same requirement. I wanted an ad-hoc early wake-up in Hive since I couldn't find a way to make a one-off early start using their own app or website. This seems to cover it for me.

This switch allows me to pre-select the early wake-up time...
Screen Shot 2016-03-27 at 19.50.53.png
Screen Shot 2016-03-27 at 19.50.53.png (25.78 KiB) Viewed 14155 times
And this script activates another switch which actions MikeF's script above. (I'd have preferred to execute the script directly from Blocky, but I don't think that is possible).
Screen Shot 2016-03-27 at 19.51.32.png
Screen Shot 2016-03-27 at 19.51.32.png (165.66 KiB) Viewed 14155 times
RFXtrx433E
Hive 2 Active Heating
Owl CM180 Energy Monitor
Various HomeEasy Receivers
LightwaveRF Plug-in sockets
MikeF
Posts: 350
Joined: Sunday 19 April 2015 0:36
Target OS: Raspberry Pi / ODroid
Domoticz version: V2022.2
Location: UK
Contact:

Re: Read British Gas Hive Heating temperature

Post by MikeF »

Hi SDISDI, this looks really good, I'll give it a try (would have been useful today, as my wife had to get up at 5:30 :lol: )

I've now created a bash script using curl commands for the v6 (Hive 2) API - you need to substitute your Hive username and password, Domoticz URL and port, and Domoticz IDX's for Hive current and target temperatures.

Code: Select all

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

login=$(curl -s -k --cookie-jar cookie.jar -g -H "Content-Type: application/vnd.alertme.zoo-6.1+json" \
	-H "Accept: application/vnd.alertme.zoo-6.2+json" -H "Content-Type: 'application/*+json'" \
	-H "X-AlertMe-Client: Hive Web Dashboard" \
	-d '{"sessions":[{"username":"<HIVE USERNAME>", "password":"<HIVE PASSWORD>"}]}' \
	https://api.prod.bgchprod.info:443/omnia/auth/sessions)
	
sessionId=$(echo $login | python -c 'import sys, json; print json.load(sys.stdin)["sessions"][0]["sessionId"]')

nodes=$(curl -s -k --cookie-jar cookie.jar -g -H "Content-Type: application/vnd.alertme.zoo-6.2+json" \
	-H "Accept: application/vnd.alertme.zoo-6.2+json" -H "Content-Type: 'application/*+json'" \
	-H "X-AlertMe-Client: swagger" -H 'X-Omnia-Access-Token: '"$sessionId" \
	https://api.prod.bgchprod.info:443/omnia/nodes)

nodeId=$(echo $nodes | python -c 'import sys, json; print json.load(sys.stdin)["nodes"][3]["id"]')

temp1=$(echo $nodes | python -c 'import sys, json; print json.load(sys.stdin)["nodes"][2]["attributes"]["temperature"]["reportedValue"]')
temp=$(echo "$temp1" | sed -re 's/([0-9]+\.[0-9]{1})[0-9]+/\1/g')

targetTemp=$(echo $nodes | python -c 'import sys, json; print json.load(sys.stdin)["nodes"][2]["attributes"]["targetHeatTemperature"]["reportedValue"]')

domoTemp=$(curl -s "http://<DOMO URL>:<DOMO PORT>/json.htm?type=command&param=udevice&nvalue=0&idx=<TEMP IDX>&svalue=${temp}")
domoTargetTemp=$(curl -s "http://<DOMO URL>:<DOMO PORT>/json.htm?type=command&param=udevice&nvalue=0&idx=<TARGET IDX>&svalue=${targetTemp}")

curl -s -k -X DELETE --cookie-jar cookie.jar -g -H "Content-Type: application/vnd.alertme.zoo-6.1+json" \
	-H "Accept: application/vnd.alertme.zoo-6.2+json" -H "Content-Type: 'application/*+json'" \
	-H "X-AlertMe-Client: Hive Web Dashboard" -H 'X-Omnia-Access-Token: '"$sessionId" \
	"https://api.prod.bgchprod.info:443/omnia/auth/sessions/${sessionId}"
ajroads
Posts: 1
Joined: Saturday 20 August 2016 21:15
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Read British Gas Hive Heating temperature

Post by ajroads »

Hi Mike

I am new to domoticz and keen to get my Hive 2 connected up - although I am disappointed that Hive don't seem to be as open to integration as Nest etc...

I've tried your scripts and steps etc but not had any luck getting it to work... It seems to connect to the API/webservice but nothing more. I am by no means a linux expert.

Any chance you could post a dummies step by step guide?

Thanks.
autocan
Posts: 2
Joined: Friday 02 September 2016 17:53
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Read British Gas Hive Heating temperature

Post by autocan »

Hello Mike.

Thank you for sharing your scripts! While I can use your 'set' script, I'm having a little difficulty with the 'read' script. I'd be very grateful if you could help me to get it working.

I have an old Hive 1, and am running Domoticz on a Raspberry Pi. I've installed your Python script, replaced the variables with my own values, and uncommented line 49. I've made the same cron task as you.

When I try to run the script manually, I get the following error:

Code: Select all

22.7 1.0
Traceback (most recent call last):
  File "/home/pi/domoticz/scripts/python/hive2domo.py", line 94, in <module>
    print e.code
AttributeError: 'URLError' object has no attribute 'code'
In the Domoticz web interface, both of my virtual thermometers display 0.0C.

I am a complete novice to Linux, so I apologise if I've missed something obvious!
bendy
Posts: 1
Joined: Saturday 15 October 2016 17:20
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Read British Gas Hive Heating temperature

Post by bendy »

Sorry to be a real newbie dummy but. . .

When you say

Create 2 dummy temperature devices (one for inside, and one for target)

Hows this done?
sach
Posts: 111
Joined: Wednesday 12 October 2016 14:33
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Read British Gas Hive Heating temperature

Post by sach »

Mike,

Thanks for the script. I have a Hive v1 and have been using your original scripts for some time now.
I have just ventured into z-wave heating and now rely heavily on the script to adjust the hive setpoint on request for heat from the TRV's.
I see above that you have a v6 api script. Does this also allow setpoint to be set via Domoticz like the script in your second post?
I'm worried that BG might retire the v5 api at some point and break the integration I currently have so would like to move to v6 if possible. I'm not skilled at scripting at all so its a bit of a dark art to me.

Also, Hive is a popular product here in the UK as you already know, and there aren't many HA systems out there that support it out of the box. It would be great if it would be possible to get this added as a plug-in in Domoticz. I'm not sure what is required for this and like I say i'm not a scripter but a willing tester if required. :-)

Thanks again

Sach
MikeF
Posts: 350
Joined: Sunday 19 April 2015 0:36
Target OS: Raspberry Pi / ODroid
Domoticz version: V2022.2
Location: UK
Contact:

Re: Read British Gas Hive Heating temperature

Post by MikeF »

Hi @sach,

Thanks for your query.

I've created 2 bash scripts using the Hive v6 API:

1. hive2domo.sh - this gets the current and target heating temperatures from Hive, and sends these to dummy temperature devices in Domoticz; it also sends the current temperature as the setpoint to a dummy thermostat device. In addition, it sends the heating status (On / Off) to a dummy switch, by reading stateHeatingRelay in the API, so that I can see at a glance when the boiler is actually switched on for heating (I also graph all these variables using emoncms - see below).

To use this, you'll need to set up the following devices in Domoticz:
- dummy temperature device for current temperature
- dummy temperature device for target temperature
- dummy thermostat
- dummy switch for heating status
and find their idX values in the Settings > Devices tab of domoticz, and substitute their values for the <angle brackets> in the sketch below (e.g., replace <CURR TEMP> with 50). You'll also need to insert your Hive URL and password, again substituting the <angle brackets>.

I run this script every 5 minutes via crontab.
Spoiler: show

Code: Select all

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

cd "${0%/*}"

login=$(curl -s -k --cookie-jar cookie.jar -g -H "Content-Type: application/vnd.alertme.zoo-6.1+json" \
	-H "Accept: application/vnd.alertme.zoo-6.2+json" -H "Content-Type: 'application/*+json'" \
	-H "X-AlertMe-Client: Hive Web Dashboard" \
	-d '{"sessions":[{"username":"<HIVE USERNAME>", "password":"<PASSWORD>"}]}' \
	https://api.prod.bgchprod.info:443/omnia/auth/sessions)
	
sessionId=$(echo $login | python -c 'import sys, json; print json.load(sys.stdin)["sessions"][0]["sessionId"]')

nodes=$(curl -s -k --cookie-jar cookie.jar -g -H "Content-Type: application/vnd.alertme.zoo-6.2+json" \
	-H "Accept: application/vnd.alertme.zoo-6.2+json" -H "Content-Type: 'application/*+json'" \
	-H "X-AlertMe-Client: swagger" -H 'X-Omnia-Access-Token: '"$sessionId" \
	https://api.prod.bgchprod.info:443/omnia/nodes)

temp1=$(echo $nodes | python -c 'import sys, json; print json.load(sys.stdin)["nodes"][2]["attributes"]["temperature"]["reportedValue"]')
printf -v temp "%.1f" "$temp1"

targetTemp=$(echo $nodes | python -c 'import sys, json; print json.load(sys.stdin)["nodes"][2]["attributes"]["targetHeatTemperature"]["reportedValue"]')
if [ $targetTemp = "1.0" ]; then
	targetTemp="7.0"
fi
#echo $targetTemp

heating=$(echo $nodes | python -c 'import sys, json; print json.load(sys.stdin)["nodes"][2]["attributes"]["stateHeatingRelay"]["reportedValue"]')
if [ $heating = "ON" ]; then
	heating="On"
elif [ $heating = "OFF" ]; then
	heating="Off"
fi

domoTemp=$(curl -s "http://<DOMO URL>:<PORT>/json.htm?type=command&param=udevice&nvalue=0&idx=<CURR TEMP>&svalue=${temp}")
domoSetPoint=$(curl -s "http://<DOMO URL>:<PORT>/json.htm?type=command&param=udevice&nvalue=0&idx=<SETPOINT>&svalue=${temp}")

sleep 1

read old_target < target.txt
if [ $targetTemp != $old_target ]; then
	domoTargetTemp=$(curl -s "http://<DOMO URL>:<PORT>/json.htm?type=command&param=udevice&nvalue=0&idx=<TARGET>&svalue=${targetTemp}")
	echo $targetTemp > target.txt
fi

sleep 1

read old_heating < heating.txt
#echo $old_heating, $heating
if [ $heating != $old_heating ]; then
	domoHeating=$(curl -s "http://<DOMO URL>:<PORT>/json.htm?type=command&param=switchlight&idx=<HEATING>&switchcmd=${heating}")
	echo $heating > heating.txt
fi

logout=$(curl -s -k -X DELETE --cookie-jar cookie.jar -g -H "Content-Type: application/vnd.alertme.zoo-6.1+json" \
	-H "Accept: application/vnd.alertme.zoo-6.2+json" -H "Content-Type: 'application/*+json'" \
	-H "X-AlertMe-Client: Hive Web Dashboard" -H 'X-Omnia-Access-Token: '"$sessionId" \
	"https://api.prod.bgchprod.info:443/omnia/auth/sessions/${sessionId}")

Emoncms graph example:
Image

2. hive_boost.sh - this is a stand-alone script, which initiates a heating boost for a predetermined temperature (default: 22°C) and time (30 minutes) - these 2 parameters are held as user variables in Domoticz, and so can be changed there. To use, set up 2 user variables with the values you want in the Settings > User variables tab in Domoticz, and note their idX's, then replace <BOOST TEMP> and <BOOST TIME> in the script below.

To run, type ./hive_boost.sh from the directory where the script is stored (or you could store the script in one of the folders in your PATH, e.g., /usr/local/bin).
Spoiler: show

Code: Select all

#!/bin/bash
# Hive Boost function (change duration and target temperature in boost curl)

login=$(curl  -s -k --cookie-jar cookie.jar -g -H "Content-Type: application/vnd.alertme.zoo-6.1+json" \
	-H "Accept: application/vnd.alertme.zoo-6.2+json" -H "Content-Type: 'application/*+json'" \
	-H "X-AlertMe-Client: Hive Web Dashboard" \
	-d '{"sessions":[{"username":"<HIVE URL>", "password":"<PASSWORD>"}]}' \
	https://api.prod.bgchprod.info:443/omnia/auth/sessions)

sessionId=$(echo $login | python -c 'import sys, json; print json.load(sys.stdin)["sessions"][0]["sessionId"]')

nodes=$(curl  -s -k --cookie-jar cookie.jar -g -H "Content-Type: application/vnd.alertme.zoo-6.2+json" \
	-H "Accept: application/vnd.alertme.zoo-6.2+json" -H "Content-Type: 'application/*+json'" \
	-H "X-AlertMe-Client: swagger" -H 'X-Omnia-Access-Token: '"$sessionId" \
	https://api.prod.bgchprod.info:443/omnia/nodes)

nodeId=$(echo $nodes | python -c 'import sys, json; print json.load(sys.stdin)["nodes"][2]["id"]')

boost=$(curl -s -k "http://<DOMO URL>:<PORT>/json.htm?type=command&param=getuservariable&idx=<BOOST TIME>")
boostTemp=$(echo $boost | python -c 'import sys, json; print json.load(sys.stdin)["result"][0]["Value"]')

boost=$(curl -s -k "http://<DOMO URL>:<PORT>/json.htm?type=command&param=getuservariable&idx=<BOOST TEMP>")
boostTime=$(echo $boost | python -c 'import sys, json; print json.load(sys.stdin)["result"][0]["Value"]')

boost=$(curl  -s -k --cookie-jar cookie.jar -X PUT -H "Content-Type: application/vnd.alertme.zoo-6.2+json" \
	-H "Accept: application/vnd.alertme.zoo-6.2+json" -H "Content-Type: 'application/*+json'" \
	-H "X-AlertMe-Client: swagger" -H 'X-Omnia-Access-Token: '"$sessionId" \
	-d '{"nodes":[{"attributes":{"activeHeatCoolMode":{"targetValue":"BOOST"},"scheduleLockDuration":{"targetValue":"'"$boostTime"'"},"targetHeatTemperature":{"targetValue":"'"$boostTemp"'"}}}]}' \
	"https://api.prod.bgchprod.info:443/omnia/nodes/${nodeId}")

logout=$(curl -s -k -X DELETE --cookie-jar cookie.jar -g -H "Content-Type: application/vnd.alertme.zoo-6.1+json" \
	-H "Accept: application/vnd.alertme.zoo-6.2+json" -H "Content-Type: 'application/*+json'" \
	-H "X-AlertMe-Client: Hive Web Dashboard" -H 'X-Omnia-Access-Token: '"$sessionId" \
	"https://api.prod.bgchprod.info:443/omnia/auth/sessions/${sessionId}")
I'm sure there are better ways of writing these scripts, but they work for me! Good luck!
Last edited by MikeF on Tuesday 13 December 2016 15:20, edited 1 time in total.
sach
Posts: 111
Joined: Wednesday 12 October 2016 14:33
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Read British Gas Hive Heating temperature

Post by sach »

Hi Mike,

These are great.....thank you.
Will check them out!

Sach
andy0887
Posts: 3
Joined: Tuesday 03 January 2017 23:40
Target OS: Raspberry Pi / ODroid
Domoticz version: v3.5877
Location: Halifax, UK
Contact:

Re: Read British Gas Hive Heating temperature

Post by andy0887 »

Hi Mike,

I have been trying to setup the scripts in line with the post Tuesday 13 December 2016 16:04 but am getting the following errors:

Traceback (most recent call last):
File "<string>", line 1, in <module>
KeyError: 'temperature'
Traceback (most recent call last):
File "<string>", line 1, in <module>
KeyError: 'reportedValue'
Traceback (most recent call last):
File "<string>", line 1, in <module>
KeyError: 'stateHeatingRelay'

Are you able to help? When I run the script the devices move up the list in domoticz so it's doing something. Also I normally have security enabled on my domoticz but in the script for Hive API v6 I can't see this?
sach
Posts: 111
Joined: Wednesday 12 October 2016 14:33
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Read British Gas Hive Heating temperature

Post by sach »

I have the same issue and I'm using the old Version 5 scripts.
Hopefully its just a blip on Hive's end. Seems like it stopped working around 4pm today for me.
SDISDI
Posts: 17
Joined: Wednesday 09 March 2016 9:18
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.4834
Contact:

Re: Read British Gas Hive Heating temperature

Post by SDISDI »

Hi. I'm wondering is something has changed at the server end. I have just noticed that mine stopped working around 1600 on 4th January. It has been fine since March last year. I can login to my.hivehome.com so it seems that the service is generally up.

If I run the script manually I get

Code: Select all

pi@raspberrypi:~/domoticz/scripts$ python hive2domo.py 
503
503
Traceback (most recent call last):
  File "hive2domo.py", line 76, in <module>
    jsonData = json.loads(body)
  File "/usr/lib/python2.7/json/__init__.py", line 338, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python2.7/json/decoder.py", line 366, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
TypeError: expected string or buffer
Interestingly the hive_boost script still runs for me.
RFXtrx433E
Hive 2 Active Heating
Owl CM180 Energy Monitor
Various HomeEasy Receivers
LightwaveRF Plug-in sockets
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests