Giter Site home page Giter Site logo

neurio-python's Introduction

Neurio Energy Sensor and Appliance Info API Python Library

This is the unofficial Python library for the Neurio sensor real-time energy and appliance automation library.

Use it to collect realtime energy production and consumption information for your home. Create smart home integrations and automations. Run machine learning experiments.

The library currently supports:

  • OAuth 2 authentication (including token request) – /v1/oauth2
  • Consumption and production samples (live and historical) – /v1/samples
  • Energy consumption statistics rollups – /v1/samples/stats
  • Appliance detection and reporting - /v1/appliances

Installation

The easiest way to install the module is via pip:

$ sudo pip install neurio

Or, clone the source repository and install it by hand:

$ git clone https://github.com/jordanh/neurio-python neurio-python
$ cd neurio-python
$ sudo python setup.py install

Getting Started

Module documentation has been added to neurio/__init.__.py and is the canonical source of documentation. There are also a set of simple examples in examples/.

Using the module is simple:

1. Request API Access Key from Neurio, Inc.

You can create your own API Access Key here: https://my.neur.io/#settings/applications/register When creating your app, Homepage URL and Callback URL are optional.

2. Create Private Key File

Create a file named my_keys.py (for example) and populate it with the key and secret information you received from Neurio. For your convenience, populate the sensor_id and location_id fields. Location and sensor ID can be obtained with get_user_information():

key    = "0123456789abcdef012345"
secret = "0123456789abcdef012345"
sensor_id = "0x0000123456789"
location_id = "abcdEFG-hijkLMNOP"

3. Write Your Application

Here's an example application that authenticates using the secret information from my_keys.py and fetches the last real-time energy data received by the Neurio platform:

import neurio
import my_keys

# Setup authentication:
tp = neurio.TokenProvider(key=example_keys.key, secret=example_keys.secret)
# Create client that can authenticate itself:
nc = neurio.Client(token_provider=tp)
# Get user information (including sensor ID and location ID)
user_info = nc.get_user_information()

print "Sensor ID %s, location ID %s" %(user_info["locations"][0]["sensors"][0]["sensorId"],
  user_info["locations"][0]["id"])

# Fetch sample:
sample = nc.get_samples_live_last(sensor_id="0x0013A20040B65FAD")

print "Current power consumption: %d W" % (sample['consumptionPower'])

That's it!

Contributing

Feel free to fork, submit pull requests, or send feedback. I'm excited to see what the world will create with Neurio.

Issues can be submitted here: https://github.com/jordanh/neurio-python/issues

Testing

A series of unit tests have been written for this library. To run them, first create a file tests/test_keys.py containing your credentials (test_keys should contain sensor_id and location_id) and then:

$ python -m unittest discover -s tests -p '*_test.py' -v

License

Copyright 2015, Jordan Husney [email protected]

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at: http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

neurio-python's People

Contributors

cbrandlehner avatar hijakk avatar jordanh avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.