EnergieID / smappy

Python client for Smappee
MIT License
21 stars 8 forks source link

Smappy

Wrapper for the Smappee API See https://smappee.atlassian.net/wiki/display/DEVAPI/API+Methods

Local interface to read and control your Smappee over LAN

Installation

Via pip:

Via git: git clone https://github.com/EnergieID/smappy.git

API Client Usage

Create a new client by supplying your Smappee client id and secret

s = smappy.Smappee(client_id, client_secret)

Authenticate using a Smappee username and password

s.authenticate(username, password)

Re-authentication using the refresh token is done automatically when the access token has expired.

API Requests

7 API requests are supported. The methods return the parsed JSON response as a dict.

Get Service Locations

s.get_service_locations()

Get Service Location Info

s.get_service_location_info(service_location_id)

Get Consumption

Start & End accept epoch (in milliseconds), datetime and pandas timestamps

Aggregation: 1 = 5 min values (only available for the last 14 days), 2 = hourly values, 3 = daily values, 4 = monthly values, 5 = quarterly values

Get Events

s.get_events(service_location_id, appliance_id, start, end, max_number)

Actuators

duration = 300,900,1800 or 3600 - specifying the time in seconds the actuator should be turned on or off. Any other value results in turning on or off for an undetermined period of time.

Consumption as Pandas DataFrame

Get consumption values in a Pandas Data Frame

Use the localize flag to get localized timestamps.

Simple Smappee

If you have no client id, client secret, refresh token etc, for instance if everything concerning oAuth is handed off to a different process like a web layer. This object only uses a given access token. It has no means of refreshing it when it expires, in which case the requests will raise errors.

ss = SimpleSmappee(access_token)

It has the same methods as the normal Smappee class, except authorization and re-authorization will not work.

LAN Smappee Client

Create Client

ls = smappy.LocalSmappee(ip='192.168.0.50') # fill in local IP-address of your Smappee

Log on

ls.logon(password='admin') # default password is admin

Other methods