HomeGenie Forum

Development => Feature request => Topic started by: saue0 on August 18, 2015, 09:23:36 PM

Title: Firebase support for Nest Thermostat
Post by: saue0 on August 18, 2015, 09:23:36 PM
Hi,
Can someone with more experience with .net add the support for the Firebase component so that we can add the Nest thermostat to the system , the basic rest request is not valid , because google dos not allow pooling of the device every second, the ask to use the firebase framework with the sreaming support...

Thanks
Title: Re: Firebase support for Nest Thermostat
Post by: [email protected] on December 02, 2015, 12:53:02 PM
I'm looking at implementing something for the Nest Thermostat.

I'm knocking something up at the moment to try and deal with the OAuth reqd - prob going to be a little bit of a manual process to set this up though, but the token is valid for ten years :)

At the moment I only require setting home or away functionality but I will see if I can do it using firebasesharp  I suspect I'm going to need to extend homegenie for this, but first things first is get a working console app :)

Title: Re: Firebase support for Nest Thermostat
Post by: [email protected] on December 08, 2015, 05:41:27 PM
I've got code working that will get thermostats, structures and set the home or away status at the moment.

At the moment it doesn't use the streaming API as I haven't managed to get it to work xplatform where as this code does.. at the moment its just a console app, I will look to download the solution for homegenie and convert it to be a plugin next... if you were wanting a fancy widget then your out of luck at the moment :) - unless someone wants to create that side.

Code isn't perfect as I'm not a developer - more used to scripting, so OO programing is foreign to me ;)

Further updates when I get chance.
Title: Re: Firebase support for Nest Thermostat
Post by: sd0wden on January 02, 2016, 07:40:06 AM
Following this thread
Title: Re: Firebase support for Nest Thermostat
Post by: cmptrblder on January 11, 2016, 11:04:44 PM
Following thread as well, HomeGenie is an amazing home automation package but for some reason there is no NEST support.  I've noticed no NEST support in some other open source software's as well with the exception of OpenHAB.  Unfortunately, OpenHab doesn't support X10 directly thru the X10 USB or Serial interfaces, just thru the Insteon PLM.  Is there an issue with NEST that people just don't want to bother with?

Even the gentleman in this thread that's trying to get it to work says its pretty limited as far as what he's working on.  I'm just wondering as NEST is on there third generation thermostat but yet HomeGenie covers TONS of newer hardware and even the good ole X10.

As far as the gentleman in this thread, if your working on one, THANK YOU and please keep us updated.
Title: Re: Firebase support for Nest Thermostat
Post by: saue0 on January 12, 2016, 12:31:05 AM
The problem is that the nest use REST streaming.
Normal rest request is possible but is limited in number of request.
Google wants us to use the firebase connection witch will allow us to get instant feedback on value change from the Nest. but Firebase is not implemented in HG, It is implemented for a web javascript. or Node server.
If sowe one is able to implement it in Node server so that  it can fire API call to HG, it might be a solution
Title: Re: Firebase support for Nest Thermostat
Post by: cmptrblder on January 12, 2016, 06:30:26 AM
Thanks for the input, its starting to look like nest is a pain in the arse.....:(
Title: Re: Firebase support for Nest Thermostat
Post by: [email protected] on January 12, 2016, 03:23:49 PM
I have got the rest API working and able to control my Away Status.

I also have a fire-base test application working at the moment, but i need to do a bit more work on how I deal with the events being returned.

I then need to see if these will port to linux, they should work fine on windows though..
Title: Re: Firebase support for Nest Thermostat
Post by: cmptrblder on January 13, 2016, 12:36:47 AM
Thanks for the work your doing, without the help of folks like yourself, I'm sure alot of opensource stuff including HomeGenie wouldn't be available so thank you.
Title: Re: Firebase support for Nest Thermostat
Post by: saue0 on January 23, 2016, 05:17:45 AM
I am currently creating a node.js module using the firebase.js component.
I am able to get the Nest data.

Question: How can i send the json data to HomeGenie ? I created a c# script, but dont seam to find how to get the body of the http api call i made..
Title: Re: Firebase support for Nest Thermostat
Post by: Gene on January 23, 2016, 05:45:13 AM
Hi saue0,

what is the URL of the API call?
And what the response looks like?
I'll show you the code to use.

Cheers,
g.
Title: Re: Firebase support for Nest Thermostat
Post by: saue0 on January 23, 2016, 06:20:30 AM
The data i need to sent to HomeGenie is a json structure of the Nest data.

This is what the api call look like

http://homegenie.ip/api/HomeAutomation.Nest/Data/ (http://homegenie.ip/api/HomeAutomation.Nest/Data/)

I creaated a Nest script.
I am able to call the api. but do not now how to send json
Title: Re: Firebase support for Nest Thermostat
Post by: Gene on January 23, 2016, 06:24:00 AM
Please give complete details with example json objects used for request and response.

g.
Title: Re: Firebase support for Nest Thermostat
Post by: saue0 on January 23, 2016, 06:52:55 AM
I use a external application to communicate with the Nest thermostat ( Node.js and FireBase.js)
When the Thermostat temperature is change, the FireBase component get a json response from the Nest.
(see attachment for json structure)

I need to pass this json to Homegenie to be able to adjust the thermostat module
I do not want HomeGenie to poll my external application. (witch can be a solution)

at the same time that i am writing these line, I thing i have fond a workaround....
I will write the json to file, then call homegenie api with the file name as a parameter.

Title: Re: Firebase support for Nest Thermostat
Post by: Gene on January 23, 2016, 07:06:53 AM
So what you need is registering an API call in your HG progam.
For example:

Code: [Select]
When.WebServiceCallRecevied("HomeAutomation.NestLink/Update", (jsonData) =>
{
    dynamic data = JsonConvert.DeserializeObject(jsonData);
    // use the data object....
    MigService.Log.Debug(data);
    // just an example, echoes back cameras object as response
    return data.devices.cameras;
});

so then you can call from your external app the url /api/HomeAutomation.NestLink/Update using POST method to post the json response.

g.
Title: Re: Firebase support for Nest Thermostat
Post by: saue0 on January 23, 2016, 08:22:35 AM
Made it work whit this code.
Thanks

When.WebServiceCallReceived("HomeAutomation.NestLink/Update/", (jsonData) =>
{
    dynamic data = JsonConvert.DeserializeObject(((String)jsonData).Substring(31));
    // use the data object....
    MigService.Log.Debug(data.devices.thermostats);

    return "{ \"ResponseValue\" : \"OK\"}"
});


and here is my node.js part to send the data to Home genie


   var http = require('http');

   var options = {
     hostname: 'hg.erxinfo.ca',
     port: 8080,
     path: '/api/HomeAutomation.NestLink/Update/',
     method: 'POST',
     headers: {
              'Content-Type': 'application/json',
          },
     auth: 'xxx:xxx',
   };


   var hreq = http.request(options, (hres) => {
     hres.setEncoding('utf8');
     hres.on('data', (d) => {
            console.log(d);

     });
   });


   hreq.on('error', (e) => {
     console.error(e);
   });

   hreq.write(JSON.stringify(data));
   hreq.end();

Still need some work on the Node.js module....  and to be able to read all the valid data inside Home genie
Title: Re: Firebase support for Nest Thermostat
Post by: cmptrblder on January 25, 2016, 01:18:06 AM
Geez, thanks guys for the work your doing, will be nice to have NEST part of Homegenie.  I went the side of hardware for too many years and got away from scripting and programming, wish I hadn't.  Can't wait for a finished product, thank you for your time.
Title: Re: Firebase support for Nest Thermostat
Post by: saue0 on January 28, 2016, 05:05:19 AM
Here is a screenshot of the widget communicating with the Nest.
Still working on it. but seem to be valid.
The backend communicating with the Nest is a Node.js module. Will try to create a classhelper for firebase in c#.

2 thing to clarify,
  1- I had to create a new widget. How to integrate-it to the mobile application ?
  2 - I had to gesister myself to the Nest Development. This allow me tho have 50 firebase connection for my application. Should we have a real account for Home Genie, with a code review from the nest team. or each user sould register themself to acces the data ???

Anyway , this is a start ....
Title: Re: Firebase support for Nest Thermostat
Post by: cmptrblder on January 28, 2016, 05:12:40 AM
Nice work, I like the fact that homegenie covers stuff back from the x10 days to the current offerings like hue bulbs and such.  Some other programs offer limited support for older stuff or non at all, plus the look and feel of homegenie just works.
Title: Re: Firebase support for Nest Thermostat
Post by: cmptrblder on February 28, 2016, 08:31:53 AM
http://www.homegenie.it/forum/index.php?topic=1447.0 (http://www.homegenie.it/forum/index.php?topic=1447.0)
Title: Re: Firebase support for Nest Thermostat
Post by: saue0 on May 27, 2017, 09:40:13 PM
New Homegenie package available , it support Thermostat,Protect and Camera

View it on Google+
https://plus.google.com/107303129643049077563/posts/ULtk173uzhy (https://plus.google.com/107303129643049077563/posts/ULtk173uzhy)

Still Need some work. It is using the official Nest API.