I can talk to firebaseio using python-firebase but I am not finding any tutorials on how to actually communicate with a NEST device using firebaseio.
None of the examples on firebaseio have anything to do with NEST and likewise it seems none of the NEST examples have anything to do with firebaseio.
Is the firebaseio account supposed to somehow import the data from home.nest.com? How do I link the two?
Why would I want to authenticate with firebaseio unless it has the NEST's data?
Authentication
Authentication in Firebase is nothing but to simply creating a token that conforms to the JWT standarts and, putting it into the querystring with the name auth. The library creates that token for you so you never end up struggling with constructing a valid token on your own. If the data has been protected against write/read operations with some security rules, the backend sends an appropriate error message back to the client with the status code 403 Forbidden.
from firebase import firebase
firebase = firebase.FirebaseApplication('https://your_storage.firebaseio.com', authentication=None)
result = firebase.get('/users', None, {'print': 'pretty'})
print result
{'error': 'Permission denied.'}
authentication = firebase.Authentication('THIS_IS_MY_SECRET', '[email protected]', extra={'id': 123})
firebase.authentication = authentication
print authentication.extra
{'admin': False, 'debug': False, 'email': '[email protected]', 'id': 123, 'provider': 'password'}
user = authentication.get_user()
print user.firebase_auth_token
"eyJhbGciOiAiSFMyNTYiLCAidHlwIjogIkpXVCJ9.eyJhZG1pbiI6IGZhbHNlLCAiZGVidWciOiBmYWxzZSwgIml
hdCI6IDEzNjE5NTAxNzQsICJkIjogeyJkZWJ1ZyI6IGZhbHNlLCAiYWRtaW4iOiBmYWxzZSwgInByb3ZpZGVyIjog
InBhc3N3b3JkIiwgImlkIjogNSwgImVtYWlsIjogIm96Z3VydnRAZ21haWwuY29tIn0sICJ2IjogMH0.lq4IRVfvE
GQklslOlS4uIBLSSJj88YNrloWXvisRgfQ"
result = firebase.get('/users', None, {'print': 'pretty'})
print result
{'1': 'John Doe', '2': 'Jane Doe'}
Nest operates its own servers that are protocol-compatible with the Firebase hosted service. That said, there are some minor differences. While you can still use the Firebase client libraries (and REST wrappers, like python-firebase), you need to follow specific instructions (Nest Intro here).
The major change has to deal with how you create a new Firebase instance: instead of using https://<your-firebase>.firebaseio.com
, you use wss://developer-api.nest.com
. You then use your Nest auth token to authenticate. The Nest-ified JS would look like:
var dataRef = new Firebase('wss://developer-api.nest.com');
dataRef.auth(nestToken);
The Python should look similar:
from firebase import firebase
authentication = firebase.Authentication('YOUR_NEST_TOKEN', 'YOUR_EMAIL', extra={})
firebase = firebase.FirebaseApplication('wss://developer-api.nest.com', authentication)
Typically for Nest, you only need the token, rather than the email or the extra, which means you may have to use the other python-firebase library, or modify the source to allow a provider other than wrapping Simple Login. Looks like the original library never uses the email field (see this comment). Another change that would have to be made is to change the asserts that all Firebase URL's start with https
and instead allow them to start with https
or wss
.
Also, instead of using the regular Firebase tools (Like the Firebase Dashboard at <your-firebase>.firebaseio.com
, or our Chrome extension Vulcan), you use the Nest Chrome Extension to manage your Nest devices.
Hopefully this helps!