Tehama Wireless API Elixir Client
tehama_client_ex is an elixir client library for interacting with the Tehama Wireless API.
You can view the API documentation here.
Documentation
HEX docs for this repository.
Installation
If available in Hex, the package can be installed
by adding tehama_client_ex to your list of dependencies in mix.exs:
def deps do
[
{:tehama_client_ex, "~> 0.6.0"}
]
endUsage
Authenticate
Basic usage is to authenticate to get a token...
# on success auth will be %TehamaClient.Auth{token: "usertoken...."}
auth = TehamaClient.auth!("username", "password")Sites
Then you can get a list of Site objects...
# on success sites will be a list of %TehamaClient.Site{}
sites = TehamaClient.site_list(auth)Devices
And finally using a site, you can get a list of Device objects...
# on success sites will be a list of %TehamaClient.Device{}
readings = TehamaClient.report_data(auth, List.first(sites))Readings
Using a device you can get a list of device Reading objects...
# readings will be a list of %TehamaClient.Reading{}
%TehamaClient.Device{readings: readings} = List.first(readings)Examples
This repository comes with some examples. The examples require some environment variables to be set.
To run an example, go to the repository and run these command line commands:
- Site List:
mix run examples/site_list.ex- This will authenticate and print a list of sites. - Basic Data:
mix run examples/data.ex- This will authenticate and print data for a given site.
Change Log
Version 0.6.0
-
Add
link_qualityto Device -
Makes
Device.link_qualityan integer -
Makes
Device.battery_van integer -
Makes
Device.radio_dec_idan integer -
Makes
Reading.readingan integer -
Makes
Reading.factora float -
Makes
Reading.initial_meter_readan integer
Version 0.5.0
-
Trims
nameofTehamaClient.Site -
Trims
aptandaddrofTehamaClient.Device
Version 0.4.0
- Updates return response types
Version 0.3.0
-
Adds handling of
Requested item wasn't found!error from API.
Version 0.2.0
-
Adds
TehamaClient.units/2method. -
Adds
%TehamaClient.Unit{}and%TehamaClient.Meter{}types