It is currently Wed Jul 26, 2017 6:35 pm



Welcome
Welcome to britishgashive

You are currently viewing our boards as a guest, which gives you limited access to view most discussions and access our other features. By joining our free community, you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content, and access many other special features. In addition, registered members also see less advertisements. Registration is fast, simple, and absolutely free, so please, join our community today!





 Page 1 of 1 [ 6 posts ] 
Author Message
 Post subject: Detecting heating on / off
PostPosted: Mon May 09, 2016 2:07 pm 

Joined: Thu Feb 19, 2015 10:52 am
Posts: 20
Has thanked: 1 time
Have thanks: 3 time
Does anyone know if it's possible to detect Hive heating actually switching on / off (i.e., when the green light goes on / off on the receiver) through the API (v6)?

I'm graphing temperatures through Domoticz and emoncms. I've created a sensor which consists of a mains relay connected to the heating control wire in the connection box, with the relay contacts connected to a hacked LightwaveRF door sensor, which then sends an on / off signal to Domoticz whenever the heating switches on / off.

It would be good to be able to do this in the API (i.e., by software rather than hardware).


Offline
 Profile  
 
 Post subject: Re: Detecting heating on / off
PostPosted: Sun Jun 19, 2016 1:47 pm 

Joined: Fri Mar 18, 2016 7:10 pm
Posts: 20
Has thanked: 0 time
Have thanks: 4 time
Hi mjs2708,

Sure, couple of ways through the V6 API.

I have written a few useful API calls like the above on my website here:
http://www.smartofthehome.com/2016/05/hive-rest-api-v6/

You could call the 'nodes' API call to get the state of your thermostat (in particular looks for 'stateHeatingRelay'):

Quote:
https://api.prod.bgchprod.info:443/omnia/nodes/<<Id_of_your_receiver>>


{
  "meta": {},
  "links": {},
  "linked": {},
  "nodes": [
    {
      "id": "81414acc-9404-41fa-9947-c18990e7ed01",
      "href": "https://api.prod.bgchprod.info:8443/omnia/nodes/81414acc-9404-41fa-9947-c18990e7ed01",
      "links": {},
      "name": "Your Receiver",
      "nodeType": "http://alertme.com/schema/json/node.class.thermostat.json#",
      "parentNodeId": "2ba0f1e4-4f51-4aea-adb3-447908448786",
      "lastSeen": 1466343696284,
      "createdOn": 1452412238819,
      "userId": "cf82b9d8-8d0b-43b7-ae28-7a1fe907da52",
      "ownerId": "cf82b9d8-8d0b-43b7-ae28-7a1fe907da52",
      "attributes": {
        "supportsTransitionsPerDay": {
          "reportedValue": 6,
          "reportReceivedTime": 1466340569731
        },
        "holidayMode": {
          "reportedValue": {
            "targetHeatTemperature": 1
          },
          "reportReceivedTime": 1466340569731
        },
        "minHeatTemperature": {
          "reportedValue": 1,
          "reportReceivedTime": 1466340569731
        },
        "maxHeatTemperature": {
          "reportedValue": 32,
          "reportReceivedTime": 1466340569731
        },
        "temperature": {
          "reportedValue": 21.05,
          "reportReceivedTime": 1466343674003
        },
        "supportsHotWater": {
          "reportedValue": false,
          "reportReceivedTime": 1466340569731
        },
        "previousConfiguration": {
          "reportedValue": {
            "targetHeatTemperature": 16,
            "mode": "MANUAL"
          },
          "reportReceivedTime": 1466340569731
        },
        "frostProtectTemperature": {
          "reportedValue": 7,
          "reportReceivedTime": 1466343696284
        },
        "stateHeatingRelay": {
          "reportedValue": "OFF",
          "reportReceivedTime": 1466340569731
        },
        "activeOverrides": {
          "reportedValue": [],
          "reportReceivedTime": 1466340569731
        },
        "activeScheduleLock": {
          "reportedValue": true,
          "reportReceivedTime": 1466340569731
        },
        "activeHeatCoolMode": {
          "reportedValue": "HEAT",
          "reportReceivedTime": 1466340569731
        },
        "nodeType": {
          "reportedValue": "http://alertme.com/schema/json/node.class.thermostat.json#",
          "reportReceivedTime": 1466343696284
        },
        "targetHeatTemperature": {
          "reportedValue": 18.5,
          "targetValue": 18.5,
          "reportReceivedTime": 1466340569731,
          "targetSetTime": 1466098678522,
          "targetExpiryTime": 1466098978522,
          "targetSetTXId": "8c254ec0-ca51-4573-8cbc-bf2674f29e54",
          "propertyStatus": "COMPLETE"
        }
      }
    }
  ]
}


Or you could query the 'channels' API call to get historical heating relay (on/off) stats:

Quote:
https://api.prod.bgchprod.info:443/omnia/channels/controllerState@<<Id_of_your_receiver>>?start=1459357200000&end=1459360868000&rate=5&timeUnit=MINUTES&Operation=DATASET


{
  "meta": {},
  "links": {},
  "linked": {},
  "channels": [
    {
      "id": "[email protected]",
      "href": "https://api.prod.bgchprod.info:[email protected]8448786",
      "links": {
        "node": [
          "2ba0f1e4-4f51-4aea-adb3-447908448786"
        ]
      },
      "start": 1459357200000,
      "end": 1459360868000,
      "timeUnit": "MINUTES",
      "rate": 5,
      "unit": "ENCODED RELAY STATE",
      "values": {
        "1459357200000": 0,
        "1459357500000": 0,
        "1459357800000": 0,
        "1459358100000": 0,
        "1459358400000": 0,
        "1459358700000": 0,
        "1459359000000": 0,
        "1459359300000": 0,
        "1459359600000": 0,
        "1459359900000": 0,
        "1459360200000": 0,
        "1459360500000": 0
      },
      "operation": "DATASET"
    }
  ]
}


Jim


Offline
 Profile  
 
 Post subject: Re: Detecting heating on / off
PostPosted: Sun Jun 19, 2016 9:40 pm 

Joined: Thu Feb 19, 2015 10:52 am
Posts: 20
Has thanked: 1 time
Have thanks: 3 time
Thanks, Jim, I tried the first of your approaches, and that works fine (hopefully, I won't need to monitor heating status at the moment - it is supposed to be summer!).

Thanks also for the link to Postman from your website - I'll be investigating that.

Mike


Offline
 Profile  
 
 Post subject: Re: Detecting heating on / off
PostPosted: Wed Jun 22, 2016 9:11 pm 

Joined: Fri Mar 18, 2016 7:10 pm
Posts: 20
Has thanked: 0 time
Have thanks: 4 time
Postman is a really cool!

Once installed you should then be able to add the following 'Collections' which I have setup for the Hive APIs into your Postman app:

* Hive API v5
https://www.getpostman.com/collections/ ... 3e7640b07e

* Hive API v6.1
https://www.getpostman.com/collections/ ... 59222e8b39

I have configured these to use session variables and it should populate variables such as hubId and sessionId automatically on login, but You may need to configure your own environment variables for:
"v6url" : "https://api.prod.bgchprod.info:443/omnia"
"v5url" : "https://api.bgchlivehome.co.uk/v5"
"username" : "[email protected]"
"password" : "pa$$word"

If you find these useful or have and additions or corrections please do share your ideas - I am happy to add further to these. I may pop them on GitHub to share.


Offline
 Profile  
 
 Post subject: Re: Detecting heating on / off
PostPosted: Sat Nov 26, 2016 1:16 pm 

Joined: Sat Nov 26, 2016 12:45 pm
Posts: 2
Has thanked: 0 time
Have thanks: 0 time
Jim,

Your Postman collections are awesome - thanks for your work! And they work great. But I wondered if you could diagnose what I'm doing wrong in Python/Requests. The identical (I hope) headers and payload never lets me authenticate with v6.

Here's the collection code in Postman:

POST /omnia/auth/sessions HTTP/1.1
Host: api.prod.bgchprod.info:443
Content-Type: application/vnd.alertme.zoo-6.1+json
Accept: application/vnd.alertme.zoo-6.1+json
X-Omnia-Client: Hive Web Dashboard
Cache-Control: no-cache
Postman-Token: f64d9abf-e02d-9353-18df-71c26520bb0f

{
  "sessions": [{
    "username": "x",
    "password": "x",
    "caller": "WEB"
  }]
}


And Python:

import requests,json,sys
url="https://api.prod.bgchprod.info:443/omnia"
username='x'
password='x'

keys={"sessions": [{
    "username": username,
    "password": password,
    "caller": "WEB"
  }]
}

#keys = {'username':username,'password':password,'caller':'web'}
headers={'Content-Type':'application/vnd.alertme.zoo-6.1+json','Accept':'application/vnd.alertme.zoo-6.1+json', 'X-Omnia-Client':'Hive Web Dashboard'}


r = requests.post("https://api.prod.bgchprod.info:443/omnia/auth/sessions",params=keys,headers=headers,verify=False)
print r
print r.json()


I keep getting a 400 response, Json not readable, and so on. Both my headers and params seem correct - have tried everything I can think of! Any thoughts?

Thanks

Will


Offline
 Profile  
 
 Post subject: Re: Detecting heating on / off
PostPosted: Sun Nov 27, 2016 9:11 pm 

Joined: Sat Nov 26, 2016 12:45 pm
Posts: 2
Has thanked: 0 time
Have thanks: 0 time
Sorted it. Put the payload (session/username params) in `json` in the python requests


Offline
 Profile  
 
Display posts from previous:  Sort by  
 Page 1 of 1 [ 6 posts ] 


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  

cron

suspicion-preferred