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.
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.1.0"}
]
end
Usage
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.
Documentation
Documentation can be generated with ExDoc and published on HexDocs. Once published, the docs can be found at https://hexdocs.pm/tehama_client_ex.