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.
imcfarla
Posts: 47
Joined: Monday 04 December 2017 14:18
Target OS: Linux
Domoticz version:
Contact:

Re: Read British Gas Hive Heating temperature

Post by imcfarla » Monday 19 February 2018 0:55

I'll answer my own question - looks like domoticz does not send the servername so any site using SNI will fail.

imcfarla
Posts: 47
Joined: Monday 04 December 2017 14:18
Target OS: Linux
Domoticz version:
Contact:

Re: Read British Gas Hive Heating temperature

Post by imcfarla » Wednesday 21 February 2018 1:22

I now have a version of the plugin which only uses the internal Connection mechanism. However you need to have a build of domoticz with this patch applied otherwise it doesn't even connect to the hive api site to get a sessionid:
https://github.com/domoticz/domoticz/issues/2156
Once the patch is in beta (hopefully it will go into beta) I will update my git repository with the updated plugin and everyone will be happy (and warm) never mind which version of python/debian they are on!

If anyone wants a copy of the plugin.py to test on their own patched copy of domoticz feel free to message me

roadsnail
Posts: 20
Joined: Wednesday 08 November 2017 21:42
Target OS: Raspberry Pi
Domoticz version: 3.8922
Location: The awesome county of Suffolk, UK
Contact:

Re: Read British Gas Hive Heating temperature

Post by roadsnail » Wednesday 21 February 2018 21:43

imcfarla wrote:
Wednesday 21 February 2018 1:22
I now have a version of the plugin which only uses the internal Connection mechanism ...
What is the advantage of using the internal Connection mechanism? Probably a dumb question, but I am loathe to move away from my current Raspbian Stretch, libpython3.4-dev and Release Channel Beta Domoticz, as all seems quite stable with Domoticz and my development branch of your Hive Plugin.
_______________________________________________________________________________________________
Pi3, Z-Wave: no-name sigma dongle, Danfoss Z-trv's, aeotec hem, d-link siren, heiman door contacts. Hive heating ctrl, esp8266 based sensors, hue hub +Ikea

roadsnail
Posts: 20
Joined: Wednesday 08 November 2017 21:42
Target OS: Raspberry Pi
Domoticz version: 3.8922
Location: The awesome county of Suffolk, UK
Contact:

Re: Read British Gas Hive Heating temperature

Post by roadsnail » Wednesday 21 February 2018 22:08

@imcfarla

Hi, I have made some mods to your plugin based on your 15th Feb commit of plugin.py contained in your github.

The reason for this is because I wanted to be able to switch my hot water relay (I have the CH/HW) version of Hive using the Domoticz switch. I know I can use Hive's built-in Schedule option, but I would like to use my own rules for switching HW based on scripts or whatever in Domoticz.

I found that using the switch created with Devices ID 'Hive_HotWater' did not allow me to switch the Hive HW relay (that powers my boiler's HW Demand). I therefore made some mods so that the Hot Water Relay switch in Domoticz now allows me to set my HW to either Off or On (as shown in Android Hive APP). I guess those without HotWater function will not worry about this?

I have placed my latest commit into my development repository at https://github.com/roadsnail/hive-plugin-dev/ should you (or anyone else) be interested. I guess a git diff between commits of my plugin.py versions will highlight what I have changed.

When time is available I will probably do the same with the CH switch (device id Hive_Heating) so that I can set up my own schedules/rules within Domoticz and not use the Hive schedule facility.

There is also a liberal sprinkling of Debug lines scattered about to help with my learning curve while working on this :)
I'll tidy some of these up further down the line.
_______________________________________________________________________________________________
Pi3, Z-Wave: no-name sigma dongle, Danfoss Z-trv's, aeotec hem, d-link siren, heiman door contacts. Hive heating ctrl, esp8266 based sensors, hue hub +Ikea

imcfarla
Posts: 47
Joined: Monday 04 December 2017 14:18
Target OS: Linux
Domoticz version:
Contact:

Re: Read British Gas Hive Heating temperature

Post by imcfarla » Wednesday 21 February 2018 23:24

The only reason to switch is that it removes the reliance on urlib.request which appears to cause problems with python 3.5 on debian using the builds published on the website.

I'll be happy to take any changes you make. I have significantly refactored the code in the new version but I will add your changes into that as well.

roadsnail
Posts: 20
Joined: Wednesday 08 November 2017 21:42
Target OS: Raspberry Pi
Domoticz version: 3.8922
Location: The awesome county of Suffolk, UK
Contact:

Re: Read British Gas Hive Heating temperature

Post by roadsnail » Wednesday 21 February 2018 23:37

Okay, thanks for that. I'll probably wait until the patch makes it into beta and then make the switch to your refactored code plugin... meanwhile I will carry on with mods to make a CH switch.
_______________________________________________________________________________________________
Pi3, Z-Wave: no-name sigma dongle, Danfoss Z-trv's, aeotec hem, d-link siren, heiman door contacts. Hive heating ctrl, esp8266 based sensors, hue hub +Ikea

imcfarla
Posts: 47
Joined: Monday 04 December 2017 14:18
Target OS: Linux
Domoticz version:
Contact:

Re: Read British Gas Hive Heating temperature

Post by imcfarla » Thursday 22 February 2018 1:08

I have committed your changes to my github repository - can you check them and see if they work?

imcfarla
Posts: 47
Joined: Monday 04 December 2017 14:18
Target OS: Linux
Domoticz version:
Contact:

Re: Read British Gas Hive Heating temperature

Post by imcfarla » Thursday 22 February 2018 1:12

FYI you should be able to set the temperature and timers on the Hive - Thermostat device in the utility section so CH is working just not as a direct switch on/off.

roadsnail
Posts: 20
Joined: Wednesday 08 November 2017 21:42
Target OS: Raspberry Pi
Domoticz version: 3.8922
Location: The awesome county of Suffolk, UK
Contact:

Re: Read British Gas Hive Heating temperature

Post by roadsnail » Thursday 22 February 2018 12:49

imcfarla wrote:
Thursday 22 February 2018 1:08
I have committed your changes to my github repository - can you check them and see if they work?
Will check later and get back. Thanks.
_______________________________________________________________________________________________
Pi3, Z-Wave: no-name sigma dongle, Danfoss Z-trv's, aeotec hem, d-link siren, heiman door contacts. Hive heating ctrl, esp8266 based sensors, hue hub +Ikea

roadsnail
Posts: 20
Joined: Wednesday 08 November 2017 21:42
Target OS: Raspberry Pi
Domoticz version: 3.8922
Location: The awesome county of Suffolk, UK
Contact:

Re: Read British Gas Hive Heating temperature

Post by roadsnail » Thursday 22 February 2018 12:52

imcfarla wrote:
Thursday 22 February 2018 1:12
FYI you should be able to set the temperature and timers on the Hive - Thermostat device in the utility section so CH is working just not as a direct switch on/off.
Yes, thermostat device in utilities works great. How do I set timers (within Domoticz)? Is there some sort of device/s I'm not seeing?
_______________________________________________________________________________________________
Pi3, Z-Wave: no-name sigma dongle, Danfoss Z-trv's, aeotec hem, d-link siren, heiman door contacts. Hive heating ctrl, esp8266 based sensors, hue hub +Ikea

imcfarla
Posts: 47
Joined: Monday 04 December 2017 14:18
Target OS: Linux
Domoticz version:
Contact:

Re: Read British Gas Hive Heating temperature

Post by imcfarla » Thursday 22 February 2018 14:14

There is a "Timers" button on the website on the thermostat device in Utilities

This does not appear to show in the app.

roadsnail
Posts: 20
Joined: Wednesday 08 November 2017 21:42
Target OS: Raspberry Pi
Domoticz version: 3.8922
Location: The awesome county of Suffolk, UK
Contact:

Re: Read British Gas Hive Heating temperature

Post by roadsnail » Thursday 22 February 2018 22:31

roadsnail wrote:
Thursday 22 February 2018 12:49
imcfarla wrote:
Thursday 22 February 2018 1:08
I have committed your changes to my github repository - can you check them and see if they work?
Will check later and get back. Thanks.
Can confirm, it works fine .. Will base my development code on that build now.

BTW. Just a quick heads up for anyone moving to your latest Hive plugin in the Git repository from the previous version. I made a change to the way the HotWater switch is stored in Domoticz. Previously it was stored in Domoticz-Devices as a switch device with ID equal to Hive_HotWater. I modified this so that the switch is NOW stored with an ID equal to the node ID of the Hot Water device as stored in Hive. This allowed me to make the HW relay switchable

This means that anyone with a Hive Central Heating AND Hot Water system will see a new Hot Water device named Hot Water - Relay and a device ID equal to the long hex string. This will be created the first time the latest plugin version is run. Anyone running the previous version may delete the switch device with the ID Hive_HotWater as this is now redundant.
_______________________________________________________________________________________________
Pi3, Z-Wave: no-name sigma dongle, Danfoss Z-trv's, aeotec hem, d-link siren, heiman door contacts. Hive heating ctrl, esp8266 based sensors, hue hub +Ikea

roadsnail
Posts: 20
Joined: Wednesday 08 November 2017 21:42
Target OS: Raspberry Pi
Domoticz version: 3.8922
Location: The awesome county of Suffolk, UK
Contact:

Re: Read British Gas Hive Heating temperature

Post by roadsnail » Friday 23 February 2018 13:46

@imcfarla

Have added modifications to make the CH switch a true switch. It can be set 'Off' or the 'On' state, which is shown as Manual in the Android App. The 'new' switch now adds a new device and shows it as a Hive - Heating switch with a long hex string as its ID. The old Hive - Heating switch may be removed, as it is redundant with this modification.

The Thermostat device (in Utilities) then governs whether the boiler is fired up or not. So when the CH switch is off, the thermostat setting acts as a frost stat, and when CH switch is on, (Manual), then the thermostat is set to desired room temperature.

I have committed this change, (based on your plugin.py committed two days ago), to my github at https://github.com/roadsnail/hive-plugin-dev

As usual, a diff will show the changes made. Feel free to review and add to your repository if you wish.

I have not yet tried your new plugin with the urllib.request change. I will wait a while to see what becomes of your issue raised https://github.com/domoticz/domoticz/issues/2156
_______________________________________________________________________________________________
Pi3, Z-Wave: no-name sigma dongle, Danfoss Z-trv's, aeotec hem, d-link siren, heiman door contacts. Hive heating ctrl, esp8266 based sensors, hue hub +Ikea

imcfarla
Posts: 47
Joined: Monday 04 December 2017 14:18
Target OS: Linux
Domoticz version:
Contact:

Re: Read British Gas Hive Heating temperature

Post by imcfarla » Saturday 24 February 2018 0:25

I think I have applied everything

roadsnail
Posts: 20
Joined: Wednesday 08 November 2017 21:42
Target OS: Raspberry Pi
Domoticz version: 3.8922
Location: The awesome county of Suffolk, UK
Contact:

Re: Read British Gas Hive Heating temperature

Post by roadsnail » Saturday 24 February 2018 18:05

Okay, thanks.
_______________________________________________________________________________________________
Pi3, Z-Wave: no-name sigma dongle, Danfoss Z-trv's, aeotec hem, d-link siren, heiman door contacts. Hive heating ctrl, esp8266 based sensors, hue hub +Ikea

imcfarla
Posts: 47
Joined: Monday 04 December 2017 14:18
Target OS: Linux
Domoticz version:
Contact:

Re: Read British Gas Hive Heating temperature

Post by imcfarla » Wednesday 14 March 2018 1:53

Hello,
been quiet for a little while...but good news
If you are running current beta (>9030) then the new hive plugin will work for you as SNI is now enabled for connections.
The new plugin is currently in git called plugin.new.py just download it, rename it to plugin.py in a plugins/Hive folder (overwriting your existing one if necessary). You probably should restart domoticz at this point.

This version does not use urllib for any requests (which has been not been working when python versions are not the same as the build environment for beta) so should work for all.

Cheers, Iain

peteralm
Posts: 16
Joined: Saturday 08 August 2015 0:12
Target OS: Raspberry Pi
Domoticz version: beta
Location: Oxfordshire, UK
Contact:

Re: Read British Gas Hive Heating temperature

Post by peteralm » Wednesday 14 March 2018 22:38

Iain,
Thank you so much! I have been without my own plugin for ages after BG changed some of the authentication recently and didn't have the time to get stuck back into it.

Being cheeky, is there any chance of a selector switch that would allow "OFF, MANUAL, SCHEDULE, BOOST" I used to use that alot


I think boost is...
'{"nodes":[{"attributes":{"activeHeatCoolMode":{"targetValue":"BOOST"},"scheduleLockDuration":{"targetValue":60},"targetHeatTemperature":{"targetValue":22}}}]}'
Schedule is:
{"nodes":[{"attributes":{"activeHeatCoolMode":{"targetValue":"HEAT"},"activeScheduleLock":{"targetValue":false}}}]}'
Off is:
'{"nodes":[{"attributes":{"activeHeatCoolMode":{"targetValue":"OFF"},"targetHeatTemperature":{"targetValue":1},"activeScheduleLock":{"targetValue":true}}}]}'

This was a bit of trial and error on my behalf

Thanks again

Peter

roadsnail
Posts: 20
Joined: Wednesday 08 November 2017 21:42
Target OS: Raspberry Pi
Domoticz version: 3.8922
Location: The awesome county of Suffolk, UK
Contact:

Re: Read British Gas Hive Heating temperature

Post by roadsnail » Wednesday 14 March 2018 23:15

imcfarla wrote:
Wednesday 14 March 2018 1:53
Hello,
been quiet for a little while...but good news ...
Hi Iain,

Have added some code to my development branch of your beta plugin to enable Hive's external 'weather' feed for my postcode. (I want this so that I can analyse heat loss data). To enable this I added a new Plugin parameter (Mode3) so that if this is set to a postcode, then a call is made to BG server and a new temperature device is added to Domoticz (Hive - Outside). The code is in my repository https://github.com/roadsnail/domoticz-hive

I have only changed plugin.py NOT plugin.new.py.

I have submitted a pull request

Cheers, Chris
_______________________________________________________________________________________________
Pi3, Z-Wave: no-name sigma dongle, Danfoss Z-trv's, aeotec hem, d-link siren, heiman door contacts. Hive heating ctrl, esp8266 based sensors, hue hub +Ikea

peteralm
Posts: 16
Joined: Saturday 08 August 2015 0:12
Target OS: Raspberry Pi
Domoticz version: beta
Location: Oxfordshire, UK
Contact:

Re: Read British Gas Hive Heating temperature

Post by peteralm » Saturday 17 March 2018 14:44

Hi,

Loving being able to link hive again! Thanks!

I notice that I am getting the following in my log and my domoticz crashes after a couple of hours. I have updated the beta in the last day and that might help... But I wonder what is going on here?

2018-03-17 12:39:09.713 Error: (British Gas Hive): Async Read Exception: 335544539, short read

Peter

Jem101
Posts: 72
Joined: Saturday 02 May 2015 21:26
Target OS: Raspberry Pi
Domoticz version: Beta
Location: London, UK
Contact:

Re: Read British Gas Hive Heating temperature

Post by Jem101 » Saturday 17 March 2018 23:21

I've been having a lot of issues with this plugin over the last week or so, including the error message you mention. For me it seems to work for a while and then I'll notice that my scheduled lights on/off timers haven't worked. On checking the logs, I'll see things like

2018-03-17 11:20:09.477 Error: (Hive Devices) 'onHeartbeat' failed 'NameError'.
2018-03-17 11:20:09.477 Error: (Hive Devices) ----> Line 592 in /home/pi/domoticz/plugins/Hive/plugin.py, function onHeartbeat
2018-03-17 11:20:09.477 Error: (Hive Devices) ----> Line 326 in /home/pi/domoticz/plugins/Hive/plugin.py, function onHeartbeat
2018-03-17 16:27:32.125 Error: (Hive Devices) 'onHeartbeat' failed 'NameError'.
2018-03-17 16:27:32.125 Error: (Hive Devices) ----> Line 592 in /home/pi/domoticz/plugins/Hive/plugin.py, function onHeartbeat
2018-03-17 16:27:32.125 Error: (Hive Devices) ----> Line 139 in /home/pi/domoticz/plugins/Hive/plugin.py, function onHeartbeat
2018-03-17 16:27:32.125 Error: (Hive Devices) ----> Line 382 in /home/pi/domoticz/plugins/Hive/plugin.py, function GetDevices
2018-03-17 19:22:50.842 Error: CheckAuthToken(xxxxxxxx) : auth token mismatch
2018-03-17 19:22:50.848 Error: CheckAuthToken(xxxxxxxx) : session id not found

Sometimes it just seems to start working itself after a while but often i'll need to disable and re-enable the plugin, and then it'll work fine for anything between a couple of hours to a day or so and then fail again.

Could BG have changed the API in some way or possibly is it taking exception to being polled so often? I had my setting to poll after 2 heartbeats so every 20 seconds or so.

Right now I am having an issue where one single light can't be controlled by Domoticz, the plugin finds it OK and I can add it but pressing the on or off button in Domoticz does nothing. Oddly enough if I turn the light on directly through the Hive app, then the status does change in Domoticz.

Weird or what?
I firmly believe in having an open mind - although not so open that your brain falls out!

- sometimes attributed to Carl Sagan, but the original quote is much older than that

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest