View Source TehamaClient (Tehama Elixir Client API v0.4.0)
Documentation for TehamaClient
.
Link to this section Summary
Types
A response which may be {:ok, results} or {:error, error}
Functions
Create an auth for the client or fail.
Create an auth for the client.
Get most recent read data.
Get all read data between two dates.
Create a temporary Site object to be used to get data
Get Site List from API
Gets a list of units for a site.
Link to this section Types
@type response(t) :: {:ok, t} | {:error, any()}
A response which may be {:ok, results} or {:error, error}
Link to this section Functions
@spec client!(String.t(), String.t()) :: TehamaClient.Auth.t()
Create an auth for the client or fail.
examples
Examples
iex> TehamaClient.client!("username", "password")
%TehamaClient.Auth{token: "testtoken"}
@spec client(String.t(), String.t()) :: response(TehamaClient.Auth.t())
Create an auth for the client.
examples
Examples
iex> TehamaClient.client("username", "password")
{:ok, %TehamaClient.Auth{token: "testtoken"}}
@spec report_data( %TehamaClient.Auth{token: String.t()}, %TehamaClient.Site{ access_code: String.t(), address: term(), city: term(), dcap_ip_adrs: term(), get_port_num: term(), knocker_dly: term(), knocker_dly_enbld: term(), name: term(), node_id: term(), node_type: term(), note: term(), parent_node_id: term(), property_id: term(), sql_user_name: term(), state: term(), zipcode: term() } ) :: response([TehamaClient.Device.t()])
Get most recent read data.
examples
Examples
iex> auth = %TehamaClient.Auth{token: "testtoken"}
...> site = %TehamaClient.Site{access_code: "88471391331"}
...> {:ok, data} = TehamaClient.report_data(auth, site)
...> data
[%TehamaClient.Device{
addr: "",
apt: "68 ",
battery_v: "3020",
building: "1",
latest_link_status_data_read_time: "2022-03-02 04:51:12",
link_partner: "e3000a78",
location_note: "Vacant",
node_id: "5532",
radio_dec_id: "2175922659",
radio_hex_id: "81B1F1E3",
readings: [
%TehamaClient.Reading{
alerts: [],
display_type: "Encoded_Meter_1",
factor: "10.000",
initial_meter_read: nil,
initial_meter_time: nil,
mon_pt: nil,
note: nil,
raw: 47190,
read_time: "2022-03-02 04:29:41",
reading: 491900,
sensor_type: "53",
serial_number: "0000203389",
style: "A",
type: "W",
units: nil
}
]
}]
@spec report_data( %TehamaClient.Auth{token: String.t()}, %TehamaClient.Site{ access_code: String.t(), address: term(), city: term(), dcap_ip_adrs: term(), get_port_num: term(), knocker_dly: term(), knocker_dly_enbld: term(), name: term(), node_id: term(), node_type: term(), note: term(), parent_node_id: term(), property_id: term(), sql_user_name: term(), state: term(), zipcode: term() }, Date.t(), Date.t() ) :: response([TehamaClient.Device.t()])
Get all read data between two dates.
examples
Examples
iex> auth = %TehamaClient.Auth{token: "testtoken"}
...> site = %TehamaClient.Site{access_code: "88471391331"}
...> {:ok, data} = TehamaClient.report_data(auth, site, ~D[2022-05-01], ~D[2022-05-02])
...> data
[%TehamaClient.Device{
addr: "",
apt: "68 ",
battery_v: "3020",
building: "1",
latest_link_status_data_read_time: "2022-03-02 04:51:12",
link_partner: "e3000a78",
location_note: "Vacant",
node_id: "5532",
radio_dec_id: "2175922659",
radio_hex_id: "81B1F1E3",
readings: [
%TehamaClient.Reading{
alerts: [],
display_type: "Encoded_Meter_1",
factor: "10.000",
initial_meter_read: nil,
initial_meter_time: nil,
mon_pt: nil,
note: nil,
raw: 47190,
read_time: "2022-03-02 04:29:41",
reading: 491900,
sensor_type: "53",
serial_number: "0000203389",
style: "A",
type: "W",
units: nil
}
]
}]
@spec site(String.t()) :: %TehamaClient.Site{ access_code: String.t(), address: term(), city: term(), dcap_ip_adrs: term(), get_port_num: term(), knocker_dly: term(), knocker_dly_enbld: term(), name: term(), node_id: term(), node_type: term(), note: term(), parent_node_id: term(), property_id: term(), sql_user_name: term(), state: term(), zipcode: term() }
Create a temporary Site object to be used to get data
examples
Examples
iex> TehamaClient.site("88471391331")
%TehamaClient.Site{access_code: "88471391331"}
@spec site_list(%TehamaClient.Auth{token: String.t()}) :: response([TehamaClient.Site.t()])
Get Site List from API
examples
Examples
iex> auth = TehamaClient.client!("username", "password")
...> {:ok, sites} = auth |> TehamaClient.site_list()
...> sites
[%TehamaClient.Site{
access_code: "88471391331",
property_id: "4706362",
name: "Elan Flower Mound #12294 (28667)",
node_type: "DCAP"
}] = sites
@spec units( %TehamaClient.Auth{token: String.t()}, %TehamaClient.Site{ access_code: String.t(), address: term(), city: term(), dcap_ip_adrs: term(), get_port_num: term(), knocker_dly: term(), knocker_dly_enbld: term(), name: term(), node_id: term(), node_type: term(), note: term(), parent_node_id: term(), property_id: term(), sql_user_name: term(), state: term(), zipcode: term() } ) :: response([TehamaClient.Unit.t()])
Gets a list of units for a site.
examples
Examples
iex> auth = %TehamaClient.Auth{token: "testtoken"}
...> site = %TehamaClient.Site{access_code: "88471391331"}
...> data = TehamaClient.units(auth, site)
{:ok, [%TehamaClient.Unit{
id: "5532",
apt: "68",
addr: "",
building: "4706362",
meters: []
}]} = data