Title: | Interact with the 'Octopus Energy' API |
---|---|
Description: | A simple wrapper for the 'Octopus Energy' REST API <https://developer.octopus.energy/rest/>. It handles authentication, by storing a provided API key and meter details. Implemented endpoints include 'products' for viewing tariff details and 'consumption' for viewing meter consumption data. |
Authors: | James McMahon [aut, cre] |
Maintainer: | James McMahon <[email protected]> |
License: | MIT + file LICENSE |
Version: | 1.0.1.9000 |
Built: | 2024-11-18 09:25:27 UTC |
Source: | https://github.com/moohan/octopusr |
Return a list of consumption values for half-hour periods for a given meter-point and meter.
Unit of measurement:
Electricity meters: kWh
SMETS1 Secure gas meters: kWh
SMETS2 gas meters: m^3
To return dates properly parsed lubridate is
required. Use the tz
parameter to specify a time zone e.g. tz = "UTC"
,
the default (tz = NULL
) will return the dates unparsed, as characters.
get_consumption( meter_type = c("electricity", "gas"), mpan_mprn = get_meter_details(meter_type)[["mpan_mprn"]], serial_number = get_meter_details(meter_type)[["serial_number"]], api_key = get_api_key(), period_from = NULL, period_to = NULL, tz = NULL, order_by = c("-period", "period"), group_by = c("hour", "day", "week", "month", "quarter") )
get_consumption( meter_type = c("electricity", "gas"), mpan_mprn = get_meter_details(meter_type)[["mpan_mprn"]], serial_number = get_meter_details(meter_type)[["serial_number"]], api_key = get_api_key(), period_from = NULL, period_to = NULL, tz = NULL, order_by = c("-period", "period"), group_by = c("hour", "day", "week", "month", "quarter") )
meter_type |
Type of meter-point, electricity or gas |
mpan_mprn |
The electricity meter-point's MPAN or gas meter-point’s MPRN. |
serial_number |
The meter's serial number. |
api_key |
Your API key. If you are an Octopus Energy customer, you can generate an API key on the developer dashboard. |
period_from |
Show consumption from the given datetime (inclusive). This parameter can be provided on its own. |
period_to |
Show consumption to the given datetime (exclusive).
This parameter also requires providing the |
tz |
a character string that specifies which time zone to parse the date with. The string must be a time zone that is recognized by the user's OS. |
order_by |
Ordering of results returned. Default is that results are returned in reverse order from latest available figure. Valid values:
|
group_by |
Aggregates consumption over a specified time period. A day is considered to start and end at midnight in the server's time zone. The default is that consumption is returned in half-hour periods. Accepted values are:
|
a tibble of the requested consumption data.
This endpoint can be used to get the GSP of a given meter-point.
get_meter_gsp(mpan = get_meter_details("electricity")[["mpan_mprn"]])
get_meter_gsp(mpan = get_meter_details("electricity")[["mpan_mprn"]])
mpan |
The electricity meter-point's MPAN |
a character of the meter-points GSP.
By default, results will be public energy products but if authenticated organisations will also see products available to their organisation.
get_products( is_variable = NULL, is_green = NULL, is_tracker = NULL, is_prepay = NULL, is_business = FALSE, available_at = Sys.Date(), authenticate = FALSE, api_key = NULL )
get_products( is_variable = NULL, is_green = NULL, is_tracker = NULL, is_prepay = NULL, is_business = FALSE, available_at = Sys.Date(), authenticate = FALSE, api_key = NULL )
is_variable |
(boolean, optional) Show only variable products. |
is_green |
(boolean, optional) Show only green products. |
is_tracker |
(boolean, optional) Show only tracker products. |
is_prepay |
(boolean, optional) Show only pre-pay products. |
is_business |
(boolean, default: FALSE) Show only business products. |
available_at |
Show products available for new agreements on the given datetime. Defaults to current datetime, effectively showing products that are currently available. |
authenticate |
(boolean, default: FALSE) Use an |
api_key |
Your API key. If you are an Octopus Energy customer, you can generate an API key on the developer dashboard. |
a tibble
get_products(is_green = TRUE)
get_products(is_green = TRUE)
Set the Octopus API key to use. This will be stored as an
environment variable. You should add OCTOPUSR_API_KEY = <api_key>
to your
.Renviron
otherwise you will have to call this function every session.
set_api_key(api_key = NULL)
set_api_key(api_key = NULL)
api_key |
Your API key. If you are an Octopus Energy customer, you can generate an API key on the developer dashboard. |
No return value, called for side effects.
Set the details for your gas/electricity meter. These will be stored as environment variables. You should add:
OCTOPUSR_MPAN = <electric MPAN>
OCTOPUSR_MPRN = <gas MPRN>
OCTOPUSR_ELEC_SERIAL_NUM = <electric serial number>
OCTOPUSR_GAS_SERIAL_NUM = <gas serial number>
to your .Renviron
otherwise you will have to call this function every
session. You can find your meter details (MPAN/MPRN and serial number(s)) on
the developer dashboard.
set_meter_details( meter_type = c("electricity", "gas"), mpan_mprn = NULL, serial_number = NULL )
set_meter_details( meter_type = c("electricity", "gas"), mpan_mprn = NULL, serial_number = NULL )
meter_type |
Type of meter-point, electricity or gas |
mpan_mprn |
The electricity meter-point's MPAN or gas meter-point’s MPRN. |
serial_number |
The meter's serial number. |
No return value, called for side effects.