ambient.agent module

class ambient.agent.Ambient(application_key='', **kwargs)[source]

Bases: volttron.platform.agent.base_weather.BaseWeatherAgent

The Ambient agent requires having an API key to interact with the remote API. The agent offers a performance_mode configuration option which allows users to limit the amount of data returned by the API.

generate_response_error(url, response_code)[source]

Raises a descriptive runtime error based on the response code returned by a service. :param url: actual url used for requesting data from Ambient :param response_code: Http response code returned by a service following a request

get_api_description(service_name)[source]

Provides a human-readable description of the various endpoints provided by the agent :param service_name: requested service endpoint :return: Human-readable description string

get_point_name_defs_file()[source]

Constructs the point name mapping dict from the mapping csv. :return: dictionary containing a mapping of service point names to standard point names with optional

get_update_interval(service_name)[source]

Indicates the interval between remote API updates :param service_name: requested service endpoint :return: datetime timedelta representing the time interval

get_version()[source]

Provides the current version of the agent. :return: current version number in string format.

make_request()[source]

Request data from the Ambient Weather API An example of the return value is as follows

[
{

“macAddress”: “18:93:D7:3B:89:0C”, “lastData”: {

“dateutc”: 1556212140000, “tempinf”: 71.9, “humidityin”: 31, “battout”: “1”, “temp1f”: 68.7, “humidity1”: 36, “batt1”: “1”, “date”: “2019-04-25T17:09:00.000Z”

}, “info”: {

“name”: “Home B WS”, “location”: “Lab Home B”

}

}, {

“macAddress”: “50:F1:4A:F7:3C:C4”, “lastData”: {

“dateutc”: 1556211960000, “tempinf”: 82.5, “humidityin”: 27, “battout”: “1”, “temp1f”: 68.5, “humidity1”: 42, “batt1”: “1”, “date”: “2019-04-25T17:06:00.000Z”

}, “info”: {

“name”: “Home A WS”, “location”: “Lab Home A”

}

}

] :return:

query_current_weather(location)[source]

Retrieve data from the Ambient API, return formatted current data and store forecast data in cache :param location: location dictionary requested by the user :return: Timestamp and data for current data from the Ambient API

query_forecast_service(service, location, quantity, forecast_start)[source]

Unimplemented method stub :param service: forecast service type of weather data to return :param location: location dictionary requested during the RPC call :param quantity: number of records to return, used to generate Time Machine requests after the forecast request :param forecast_start: forecast results that are prior to this timestamp will be filtered by base weather agent :return: Timestamp and data returned by the Ambient weather API response

query_hourly_forecast(location)[source]

Unimplemented method stub :param location: currently accepts lat/long location dictionary format only :return: time of forecast prediction as a timestamp string, and a list of

query_hourly_historical(location, start_date, end_date)[source]

Unimplemented method stub :param location: no format currently determined for history. :param start_date: Starting date for historical weather period. :param end_date: Ending date for historical weather period. :return: NotImplementedError

validate_location(service_name, location)[source]

Indicates whether the location dictionary provided matches the format required by the remote weather API :param service_name: name of the remote API service :param location: location dictionary to provide in the remote API url :return: True if the location matches the required format else False

ambient.agent.ambient(config_path, **kwargs)[source]

Parses the Agent configuration and returns an instance of the agent created using that configuration. :param config_path: Path to a configuration file. :type config_path: str :returns: Ambient :rtype: Ambient

ambient.agent.main()[source]

Main method called to start the agent.