[DEPRECATED] - Hive (Connect) V2.6 (British Gas Hive)

Hi @Alyc100.

Great work on the Connect SmartApp and it’s devices.

I’ve spent some time today looking at the sensors Hive have. I’ve started out with contact sensors, though I also have motion sensors to try.

Discovery seems simple enough. You can either look for the nodeType of node.class.contact.sensor.json# or you can look for the attribute state as that only seems to appear on contact sensors.

They have 2 useful sensors in them:

"temperature": {
          "reportedValue": 19.5,
          "displayValue": 19.5,
          "reportReceivedTime": 1472992016760,
          "reportChangedTime": 1472992016760
 },

and:

"state": {
      "reportedValue": "CLOSED",
      "displayValue": "CLOSED",
      "reportReceivedTime": 1472991608798,
      "reportChangedTime": 1472983039007
 },

As you can probaaly guess, the state changes to OPEN when they are open.

I’ve created a devicetype for the contact sensor and I’ve had a go at integrating the detection and that devicetype with your connect SmartApp: https://github.com/simonjgreen/SmartThingsPublic

I’m not sure where I’m going wrong, but I can’t get it to enumerate the contact sensors. I noticed part way through you’ve done a new version of your smartapp as well and I’ve commited with a rush merge in to that so forgive the messiness there :wink:

Thoughts appreciated!

Simon

Oh here is the full json from one of the contact sensor nodes in case you don’t have one to test against:

{
  "meta": {},
  "links": {},
  "linked": {},
  "nodes": [
    {
      "id": "58f16688-f034-4db9-81fa-1717525e9944",
      "href": "https://api.prod.bgchprod.info:8443/omnia/nodes/58f16688-f034-4db9-81fa-1717525e9944",
      "links": {},
      "name": "Conservatory",
      "nodeType": "http://alertme.com/schema/json/node.class.contact.sensor.json#",
      "parentNodeId": "8ad3072f-684c-433b-8e16-906c9a5c7495",
      "lastSeen": 1473009068329,
      "createdOn": 1468525987173,
      "userId": "563aab21-92d0-494a-a7eb-413708ce7074",
      "ownerId": "563aab21-92d0-494a-a7eb-413708ce7074",
      "relationships": {
        "boundNodes": []
      },
      "attributes": {
        "nativeIdentifier": {
          "reportedValue": "BFCA",
          "displayValue": "BFCA",
          "reportReceivedTime": 1473006092624,
          "reportChangedTime": 1472004221611
        },
        "LQI": {
          "reportedValue": 100,
          "displayValue": 100,
          "reportReceivedTime": 1473009068329,
          "reportChangedTime": 1473003893278
        },
        "batteryVoltage": {
          "reportedValue": 3,
          "displayValue": 3,
          "reportReceivedTime": 1473009053300,
          "reportChangedTime": 1472002449089
        },
        "nodeType": {
          "reportedValue": "http://alertme.com/schema/json/node.class.contact.sensor.json#",
          "displayValue": "http://alertme.com/schema/json/node.class.contact.sensor.json#",
          "reportReceivedTime": 1473009068329,
          "reportChangedTime": 1472002448049
        },
        "powerSupply": {
          "reportedValue": "BATTERY",
          "displayValue": "BATTERY",
          "reportReceivedTime": 1473006092624,
          "reportChangedTime": 1472004221611
        },
        "manufacturer": {
          "reportedValue": "AlertMe.com",
          "displayValue": "AlertMe.com",
          "reportReceivedTime": 1473006092624,
          "reportChangedTime": 1472004221611
        },
        "RSSI": {
          "reportedValue": -68,
          "displayValue": -68,
          "reportReceivedTime": 1473009068329,
          "reportChangedTime": 1473009053300
        },
        "zigBeeBindingTable": {
          "reportedValue": [
            {
              "sourceAddress": "::20d:6f00:5a5:4e5f",
              "sourceEndpoint": 2,
              "cluster": 32,
              "destinationAddress": "::21c:2bff:fe0b:90dc",
              "destinationEndpoint": 1
            },
            {
              "sourceAddress": "::20d:6f00:5a5:4e5f",
              "sourceEndpoint": 2,
              "cluster": 1,
              "destinationAddress": "::21c:2bff:fe0b:90dc",
              "destinationEndpoint": 1
            },
            {
              "sourceAddress": "::20d:6f00:5a5:4e5f",
              "sourceEndpoint": 2,
              "cluster": 1026,
              "destinationAddress": "::21c:2bff:fe0b:90dc",
              "destinationEndpoint": 1
            }
          ],
          "displayValue": [
            {
              "sourceAddress": "::20d:6f00:5a5:4e5f",
              "sourceEndpoint": 2,
              "cluster": 32,
              "destinationAddress": "::21c:2bff:fe0b:90dc",
              "destinationEndpoint": 1
            },
            {
              "sourceAddress": "::20d:6f00:5a5:4e5f",
              "sourceEndpoint": 2,
              "cluster": 1,
              "destinationAddress": "::21c:2bff:fe0b:90dc",
              "destinationEndpoint": 1
            },
            {
              "sourceAddress": "::20d:6f00:5a5:4e5f",
              "sourceEndpoint": 2,
              "cluster": 1026,
              "destinationAddress": "::21c:2bff:fe0b:90dc",
              "destinationEndpoint": 1
            }
          ],
          "reportReceivedTime": 1472131782312,
          "reportChangedTime": 1472131486685
        },
        "macAddress": {
          "reportedValue": "000D6F0005A54E5F",
          "displayValue": "000D6F0005A54E5F",
          "reportReceivedTime": 1473006092624,
          "reportChangedTime": 1472131191552
        },
        "protocol": {
          "reportedValue": "ZIGBEE",
          "displayValue": "ZIGBEE",
          "reportReceivedTime": 1473006092624,
          "reportChangedTime": 1472004221611
        },
        "lastSeen": {
          "reportedValue": "2016-09-04T16:21:08.631+0000",
          "displayValue": "2016-09-04T16:21:08.631+0000",
          "reportReceivedTime": 1473006092624,
          "reportChangedTime": 1473006092624
        },
        "batteryState": {
          "reportedValue": "FULL",
          "displayValue": "FULL",
          "reportReceivedTime": 1473009053300,
          "reportChangedTime": 1472002449089
        },
        "temperature": {
          "reportedValue": 21.5,
          "displayValue": 21.5,
          "reportReceivedTime": 1473006092624,
          "reportChangedTime": 1472993111903
        },
        "hardwareVersion": {
          "reportedValue": "01",
          "displayValue": "01",
          "reportReceivedTime": 1473006092624,
          "reportChangedTime": 1472004221611
        },
        "model": {
          "reportedValue": "WDS00140002",
          "displayValue": "WDS00140002",
          "reportReceivedTime": 1473006092624,
          "reportChangedTime": 1472004221611
        },
        "state": {
          "reportedValue": "CLOSED",
          "displayValue": "CLOSED",
          "reportReceivedTime": 1473006092624,
          "reportChangedTime": 1473006047032
        },
        "presence": {
          "reportedValue": "PRESENT",
          "displayValue": "PRESENT",
          "reportReceivedTime": 1473009068329,
          "reportChangedTime": 1472131189983
        },
        "softwareVersion": {
          "reportedValue": "30585010",
          "displayValue": "30585010",
          "reportReceivedTime": 1473006092624,
          "reportChangedTime": 1472004221611
        },
        "batteryLevel": {
          "reportedValue": 100,
          "displayValue": 100,
          "reportReceivedTime": 1473009053300,
          "reportChangedTime": 1472002449089
        }
      }
    }
  ]
}

Solved!
I hadn’t spotted your first tier of filtering: if (device.attributes.activeHeatCoolMode != null) {

Done and working. I have submitted a pull request:

Hi thanks for your work Simon. Now that there is more than one of us potentially working on the code base I might need to tidy it up a bit on the next update :slight_smile:.

Will look into merging your code now.

A couple of questions…

  • Do the Hive plugs also have an attribute value ‘state’ in the API. If so, could these incorrectly be identified as a contact sensor?
  • Are the contact sensors limited to the default Connect app poll of 10 minutes? If so, does it matter?

hi, I have been looking through this with some interest as I have just got the hive system, I have the hive controller and hub, if I want to integrate this with smart things will I need to run a hive hub and a smart things hub all connecting to my home hub? or can I get the hive to go straight to the smart things hub so I do not need the hive hub, trying to remove a level of hardware if possible…?

I don’t have a plug to test. If that is the case then an alternative (and arguably the right thing to do for all devices) would be to use the nodeType:
"nodeType": "http://alertme.com/schema/json/node.class.contact.sensor.json#",
That’s going to be definitive.

Regarding the polling interval, I haven’t hammered it to see how fast it will work but I was able to get a correct response back pretty quickly when refreshing every time. However given it goes via the web to the british gas API endpoint rather than locally I can’t imagine they would be happy if hundreds of people were hitting it twice a second :slight_smile:

In regards to using nodeType as the definitive identifier, that might work for the contact sensor, but for the heating and hot water devices there are at least three nodes all with the node type “http://alertme.com/schema/json/node.class.thermostat.json:”. So using nodeType doesn’t seem possible on the heating side of things.

For the contact sensor polling interval, if the default 10 minute status refresh is fine then I think it’s sensible to keep the number of Hive API calls at the same level.

Unfortunately the Hive SmartThings integration does rely on having the Hive hub as well as the SmartThings hub connected to your router.

Hive (Connect) v2.3.1 - Improve device detection

@Simon_Green - Could you test this with your contact sensor?

Yep, confirmed works fine.

The motion sensor device seems a little more complicated. It looks like you have to derive whether or not it sees motion using the motionEnded and motionStarted branches. Here’s the JSON from one of my motion sensors:

{
  "meta": {},
  "links": {},
  "linked": {},
  "nodes": [
    {
      "id": "64059699-9a05-4f15-bcda-b4efa695985d",
      "href": "https://api.prod.bgchprod.info:8443/omnia/nodes/64059699-9a05-4f15-bcda-b4efa695985d",
      "links": {},
      "name": "Old Shed",
      "nodeType": "http://alertme.com/schema/json/node.class.motion.sensor.json#",
      "parentNodeId": "8ad3072f-684c-433b-8e16-906c9a5c7495",
      "lastSeen": 1473275339692,
      "createdOn": 1468525694135,
      "userId": "563aab21-92d0-494a-a7eb-413708ce7074",
      "ownerId": "563aab21-92d0-494a-a7eb-413708ce7074",
      "relationships": {
        "boundNodes": []
      },
      "attributes": {
        "nativeIdentifier": {
          "reportedValue": "B133",
          "displayValue": "B133",
          "reportReceivedTime": 1473272425826,
          "reportChangedTime": 1473207627033,
          "readOnly": false
        },
        "LQI": {
          "reportedValue": 100,
          "displayValue": 100,
          "reportReceivedTime": 1473275339692,
          "reportChangedTime": 1473205094508,
          "readOnly": false
        },
        "batteryVoltage": {
          "reportedValue": 2.9,
          "displayValue": 2.9,
          "reportReceivedTime": 1473272425826,
          "reportChangedTime": 1473271129372,
          "readOnly": false
        },
        "motionStarted": {
          "reportedValue": "2016-09-07T19:04:21.760+0000",
          "displayValue": "2016-09-07T19:04:21.760+0000",
          "reportReceivedTime": 1473275062773,
          "reportChangedTime": 1473275062773,
          "readOnly": false
        },
        "nodeType": {
          "reportedValue": "http://alertme.com/schema/json/node.class.motion.sensor.json#",
          "displayValue": "http://alertme.com/schema/json/node.class.motion.sensor.json#",
          "reportReceivedTime": 1473275339692,
          "reportChangedTime": 1473205094508,
          "readOnly": false
        },
        "powerSupply": {
          "reportedValue": "BATTERY",
          "displayValue": "BATTERY",
          "reportReceivedTime": 1473272425826,
          "reportChangedTime": 1473207627033,
          "readOnly": false
        },
        "manufacturer": {
          "reportedValue": "AlertMe.com",
          "displayValue": "AlertMe.com",
          "reportReceivedTime": 1473272425826,
          "reportChangedTime": 1473207627033,
          "readOnly": false
        },
        "RSSI": {
          "reportedValue": -56,
          "displayValue": -56,
          "reportReceivedTime": 1473275339692,
          "reportChangedTime": 1473275339692,
          "readOnly": false
        },
        "macAddress": {
          "reportedValue": "000D6F0005A54431",
          "displayValue": "000D6F0005A54431",
          "reportReceivedTime": 1473272425826,
          "reportChangedTime": 1473207627033,
          "readOnly": false
        },
        "protocol": {
          "reportedValue": "ZIGBEE",
          "displayValue": "ZIGBEE",
          "reportReceivedTime": 1473272425826,
          "reportChangedTime": 1473207627033,
          "readOnly": false
        },
        "lastSeen": {
          "reportedValue": "2016-09-07T18:18:47.954+0000",
          "displayValue": "2016-09-07T18:18:47.954+0000",
          "reportReceivedTime": 1473272425826,
          "reportChangedTime": 1473272425826,
          "readOnly": false
        },
        "batteryState": {
          "reportedValue": "NORMAL",
          "displayValue": "NORMAL",
          "reportReceivedTime": 1473272425826,
          "reportChangedTime": 1473271129372,
          "readOnly": false
        },
        "temperature": {
          "reportedValue": 25.5,
          "displayValue": 25.5,
          "reportReceivedTime": 1473272425826,
          "reportChangedTime": 1473264524144,
          "readOnly": false
        },
        "hardwareVersion": {
          "reportedValue": "02",
          "displayValue": "02",
          "reportReceivedTime": 1473272425826,
          "reportChangedTime": 1473207627033,
          "readOnly": false
        },
        "model": {
          "reportedValue": "PIR00140005",
          "displayValue": "PIR00140005",
          "reportReceivedTime": 1473272425826,
          "reportChangedTime": 1473207627033,
          "readOnly": false
        },
        "motionEnded": {
          "reportedValue": "2016-09-07T18:57:23.406+0000",
          "displayValue": "2016-09-07T18:57:23.406+0000",
          "reportReceivedTime": 1473274944388,
          "reportChangedTime": 1473274944388,
          "readOnly": false
        },
        "inMotion": {
          "reportedValue": true,
          "displayValue": true,
          "reportReceivedTime": 1473275062773,
          "reportChangedTime": 1473275062773,
          "readOnly": false
        },
        "presence": {
          "reportedValue": "PRESENT",
          "displayValue": "PRESENT",
          "reportReceivedTime": 1473275339692,
          "reportChangedTime": 1473205094508,
          "readOnly": false
        },
        "softwareVersion": {
          "reportedValue": "30585010",
          "displayValue": "30585010",
          "reportReceivedTime": 1473272425826,
          "reportChangedTime": 1473207627033,
          "readOnly": false
        },
        "batteryLevel": {
          "reportedValue": 100,
          "displayValue": 100,
          "reportReceivedTime": 1473272425826,
          "reportChangedTime": 1473207627033,
          "readOnly": false
        }
      }
    }
  ]
}

You’ll see it has an inMotion branch however I believe that is a red herring.

Glad to see this is being developed at a rate of knots.

Has anybody had any luck attaching this to a Logitech Harmony and using the Companion remote (or even the app) to adjust temperature up/down.

While Harmony seems to be able to read the temperature from Smarthings it doesn’t seem to be able to set them itself.

Minor pull request. https://github.com/alyc100/SmartThingsPublic/pull/2
The HTTPS URL has changed for the API

Are you sure? My hive devices are still updating their status.

@Alyc100, @Simon_Green, great job! I’ve currently got Hive (heating & door sensor) in a holiday let, and am just getting ST for a smart door lock. My big frustration with Hive is that it is not possible to lock a max temperature, so guests just turn the stat up to 30 degrees (presumably thinking that ‘it will get hot quicker’!). This is a problem many landlords have been pushing Hive to solve for literally years!

At the moment I use IFTTT to set the stat back to the scheduled temperature if the house gets too hot (as triggered by Hive’s high temperature warning email, since they only have a THEN channel, not an IF channel… bonkers…). This is not very elegant and doesn’t prevent the temperature getting too high in the first place!

I would love to be able to use your app to limit the set temperature regardless of the actual temperature (i.e. when polling, “if heatingSetpoint>myMax then heatingSetpoint=myMax”, without changing the heating mode). As far as I can see from your code, you can trigger on mode changes but not on the heatingSetpoint. Unfortunately I’m competent enough to understand what you’ve done but not get involved, however I would be really grateful for a heatingSetpoint trigger!

This could be a nice little project for me today. I could add another option in the Hive heating device setting UI to set a max limit for the set temperature. Let me look into this.

Hmm. So to determine the motion status flag, you have to work out whether motionEnded time is less than motionStarted time?

OK. Try the new Hive Heating v2.1.6 device. It now allows a maximum temperature threshold setting on the device setting UI. Click the cog icon on the Hive Heating device screen then click ‘Edit Device’.

edit: I wrote the following before you posted your update, fast work! I’ll give it a go as soon as I have ST set up at the house.

Great, thanks Alex. There are three test cases I think.

  1. the guests have left the mode as scheduled but turned the temperature up too high;
  2. the guests have instigated a boost at too high a temperature;
  3. the guests have changed the mode to manual and set too high a temperature.

In each case the mode can stay the same but the set temperature should reduce.

I don’t have ST actually at the house yet so no rush, but thanks again.

The way it works is that as soon as the set temperature value of Hive goes above the max temperature threshold value, it changes the temperature in Hive to the max temperature threshold value. It does not alter the mode of Hive heating.

Edit: Also updated Hive (Connect) app so that notification can be generated if maximum threshold value is breached.