aioafero.v1.controllers package

Submodules

aioafero.v1.controllers.base module

Base class for Controllers.

class aioafero.v1.controllers.base.NumbersName(unit: str, display_name: str | None = None)[source]

Bases: NamedTuple

Data used for displaying a Number.

Parameters:
  • unit (str)

  • display_name (str | None)

unit: str

Alias for field number 0

display_name: str | None

Alias for field number 1

class aioafero.v1.controllers.base.BaseResourcesController(bridge: AferoBridgeV1)[source]

Bases: Generic

Base controller for device types registered on AferoBridgeV1.

Subclasses expose typed models and action methods. Use get_device to read state and subscribe for update callbacks.

Parameters:

bridge (AferoBridgeV1)

ITEM_TYPE_ID: ResourceTypes | None = None
ITEM_TYPES: list[ResourceTypes] | None = None
ITEM_CLS = None
ITEM_MAPPING: dict = {}
ITEM_SENSORS: dict[str, str] = {}
ITEM_BINARY_SENSORS: dict[str, str] = {}
ITEM_NUMBERS: dict[tuple[str, str | None], NumbersName] = {}
ITEM_SELECTS: dict[tuple[str, str | None], str] = {}
DEVICE_SPLIT_CALLBACKS: dict[str, callable] = {}
__init__(bridge: AferoBridgeV1) None[source]

Initialize instance.

Parameters:

bridge (AferoBridgeV1)

Return type:

None

__getitem__(device_id: str) AferoResource[source]

Get item by device_id.

Parameters:

device_id (str)

Return type:

AferoResource

__iter__() Iterator[source]

Iterate items.

Return type:

Iterator

__contains__(device_id: str) bool[source]

Return bool if device_id is in items.

Parameters:

device_id (str)

Return type:

bool

property items: list[AferoResource]

Return all items for this resource.

property initialized: bool

Determine if the controller has been initialized.

property subscribers: dict[str, list[tuple[Callable[[EventType, dict | None], None], tuple[EventType] | None]]]

Get all subscribers aligned to this controller.

async emit_to_subscribers(evt_type: EventType, item_id: str, item: AferoResource)[source]

Emit updates to subscribers.

Parameters:
  • evt_type (EventType) – Type of event

  • item_id (str) – ID of the item

  • item (AferoResource) – Item to emit to subscribers

get_filtered_devices(initial_data: list[dict]) list[AferoDevice][source]

Determine devices that align to the controller.

Parameters:

initial_data (list[dict])

Return type:

list[AferoDevice]

async initialize() None[source]

Initialize controller the controller.

Initialization process should only occur once. During this process, it will subscribe to all updates for the given resources and register any device split callbacks for the event controller.

Return type:

None

async initialize_number(func_def: dict, state: AferoState) tuple[tuple[str, str | None], NumbersFeature] | None[source]

Initialize a number from the provided data.

Parameters:
Return type:

tuple[tuple[str, str | None], NumbersFeature] | None

async initialize_select(functions: list[dict], state: AferoState) tuple[tuple[str, str | None], SelectFeature] | None[source]

Initialize a select from the provided data.

Parameters:
Return type:

tuple[tuple[str, str | None], SelectFeature] | None

async initialize_sensor(state: AferoState, child_id: str) AferoSensor | AferoBinarySensor | None[source]

Initialize the sensor.

Parameters:
  • state (AferoState) – State to update

  • child_id (str) – device_id of the parent device

Return type:

AferoSensor | AferoBinarySensor | None

async update_number(state: AferoState, cur_item: AferoResource) str | None[source]

Update the number if its tracked and a change has been detected.

Parameters:
  • state (AferoState) – State to update

  • cur_item (AferoResource) – Current item to update

Returns:

Identifier of the number that was updated or None

Return type:

str | None

async update_select(state: AferoState, cur_item: AferoResource) str | None[source]

Update the select if its tracked and a change has been detected.

Parameters:
  • state (AferoState) – State to update

  • cur_item (AferoResource) – Current item to update

Returns:

Identifier of the select that was updated or None

Return type:

str | None

async update_sensor(state: AferoState, cur_item: AferoResource) str | None[source]

Update the sensor if its tracked and a change has been detected.

Parameters:
  • state (AferoState) – State to update

  • cur_item (AferoResource) – Current item to update

Returns:

Identifier of the sensor that was updated or None

Return type:

str | None

async split_sensor_data(state: AferoState) tuple[Any, str | None][source]

Split the sensor value and return a tuple of the sensor value and key.

Parameters:

state (AferoState)

Return type:

tuple[Any, str | None]

async initialize_elem(element: AferoDevice) None[source]

Initialize the element.

Parameters:
  • afero_device – Afero Device that contains the updated states

  • element (AferoDevice)

Returns:

Newly initialized resource

Return type:

None

async update_elem(element: AferoDevice) None[source]

Update the Portable AC with the latest API data.

Parameters:
  • afero_device – Afero Device that contains the updated states

  • element (AferoDevice)

Returns:

States that have been modified

Return type:

None

subscribe(callback: Callable[[EventType, dict | None], None], id_filter: str | tuple[str] | None = None, event_filter: EventType | tuple[EventType] | None = None) Callable[source]

Subscribe to status changes for this resource type.

Parameters:
  • callback (Callable[[EventType, dict | None], None]) – callback function to call when an event emits.

  • id_filter (str | tuple[str] | None) – Optionally provide resource ID(s) to filter events for.

  • event_filter (EventType | tuple[EventType] | None) – Optionally provide EventType(s) as filter.

Returns:

function to unsubscribe.

Return type:

Callable

async update_afero_api(device_id: str, states: list[dict]) ClientResponse | bool[source]

Update Afero IoT API with the new states.

Parameters:
  • device_id (str) – Afero IoT Device ID

  • states (list[dict]) – States to manually set

Returns:

Response if successful, False otherwise.

Return type:

ClientResponse | bool

async update(device_id: str, obj_in: AferoResource | None = None, states: list[dict] | None = None, send_duplicate_states: bool = False) ClientResponse | None[source]

Update Afero IoT with the new data.

Parameters:
  • device_id (str) – Afero IoT Device ID

  • obj_in (AferoResource | None) – Afero IoT Resource elements to change

  • states (list[dict] | None) – States to manually set

  • send_duplicate_states (bool) – Send all states, regardless if there’s been a change

Return type:

ClientResponse | None

generate_update_dev(device_id: str, states: list[AferoState]) AferoDevice[source]

Generate update data for the event controller.

Parameters:
Return type:

AferoDevice

get_device(device_id: str) AferoResource[source]

Return the current model for a tracked device.

Parameters:

device_id (str) – Device ID on this controller (split or parent metadevice ID).

Returns:

Resource model with parsed feature state.

Raises:

DeviceNotFound – If device_id is not tracked by this controller.

Return type:

AferoResource

aioafero.v1.controllers.base.dataclass_to_afero(elem: AferoResource, cls: dataclass, mapping: dict, send_duplicate_states: bool) list[dict][source]

Convert the current state to be consumed by Afero IoT.

Parameters:
  • elem (AferoResource)

  • cls (dataclass)

  • mapping (dict)

  • send_duplicate_states (bool)

Return type:

list[dict]

aioafero.v1.controllers.base.get_afero_states_from_mapped(element: AferoResource, field_name: str, update_vals: dict, send_duplicate_states: bool) list[dict][source]

Convert an update element to dict to be consumed by Afero API.

Parameters:
  • element (AferoResource)

  • field_name (str)

  • update_vals (dict)

  • send_duplicate_states (bool)

Return type:

list[dict]

aioafero.v1.controllers.base.get_afero_instance_for_state(elem: AferoResource, feature, mapped_afero_key: str | None) str | None[source]

Determine the function instance based on the field data or device.

Parameters:
  • elem (AferoResource)

  • mapped_afero_key (str | None)

Return type:

str | None

aioafero.v1.controllers.base.get_afero_state_from_feature(func_class: str, func_instance: str | None, current_val: Any) dict[source]

Generate a single state from the current data.

Parameters:
  • func_class (str)

  • func_instance (str | None)

  • current_val (Any)

Return type:

dict

aioafero.v1.controllers.base.get_afero_states_from_list(states: list[dict]) list[dict][source]

Add timestamp to the states.

Assume the state already has functionClass, functionInstance, and value

Parameters:

states (list[dict])

Return type:

list[dict]

aioafero.v1.controllers.climate module

Base controller for climate devices.

aioafero.v1.controllers.climate.generate_target_temp(func_def: dict, state: AferoState) TargetTemperatureFeature[source]

Determine the target temp based on the function definition.

Parameters:
Return type:

TargetTemperatureFeature

aioafero.v1.controllers.climate.generate_target_temp_capability(capability: AferoCapability, state: AferoState) TargetTemperatureFeature[source]

Determine the target temp based on the function definition.

Parameters:
Return type:

TargetTemperatureFeature

class aioafero.v1.controllers.climate.ClimateController(bridge: AferoBridgeV1)[source]

Bases: BaseResourcesController[AferoResourceT]

Base controller for climate devices.

Parameters:

bridge (AferoBridgeV1)

async initialize_climate_elem(afero_device: AferoDevice) dict[source]

Initialize the climate elements of a device.

Parameters:

afero_device (AferoDevice)

Return type:

dict

async update_climate_elem(afero_device: AferoDevice) set[source]

Update the climate elements of a device.

Parameters:

afero_device (AferoDevice)

Return type:

set

async set_climate_state(device_id: str, update_obj, **kwargs) None[source]

Set climate state.

Parameters:

device_id (str)

Return type:

None

aioafero.v1.controllers.device module

Controller that holds top-level devices.

class aioafero.v1.controllers.device.DeviceController(*args, **kwargs)[source]

Bases: BaseResourcesController[Device]

Top-level / parent devices on bridge.devices (read-only).

ITEM_TYPE_ID: ResourceTypes | None = 'metadevice.device'
ITEM_TYPES: list[ResourceTypes] | None = []
ITEM_CLS

alias of Device

ITEM_SENSORS: dict[str, str] = {'battery-level': '%', 'wifi-rssi': 'dB'}
ITEM_BINARY_SENSORS: dict[str, str] = {'error': 'alerting'}
__init__(*args, **kwargs)[source]

Initialize instance.

async initialize_elem(afero_device: AferoDevice) Device[source]

Initialize the element.

Parameters:

afero_device (AferoDevice) – Afero Device that contains the updated states

Returns:

Newly initialized resource

Return type:

Device

async initialize() None[source]

Initialize controller by fetching all items for this resource type from bridge.

Return type:

None

get_filtered_devices(devices: list[AferoDevice]) list[AferoDevice][source]

Find parent devices.

Parameters:

devices (list[AferoDevice])

Return type:

list[AferoDevice]

async update_elem(afero_device: AferoDevice) set[source]

Update the Device with the latest API data.

Parameters:

afero_device (AferoDevice) – Afero Device that contains the updated states

Returns:

States that have been modified

Return type:

set

aioafero.v1.controllers.event module

Handle connecting to Afero IoT and distribute events.

exception aioafero.v1.controllers.event.BackoffException[source]

Bases: Exception

Exception raised when a backoff is required.

class aioafero.v1.controllers.event.CallbackResponse(split_devices: list[AferoDevice] = [], remove_original: bool = False)[source]

Bases: NamedTuple

Callback response for DEVICE_SPLIT_CALLBACKS.

Parameters:
  • split_devices (list[AferoDevice]) – New devices that should be added to the overall list

  • remove_original (bool) – Remove the original device from the list of devices

split_devices: list[AferoDevice]

Alias for field number 0

remove_original: bool

Alias for field number 1

class aioafero.v1.controllers.event.EventStreamStatus(*values)[source]

Bases: Enum

Status options of EventStream.

CONNECTING = 0
CONNECTED = 1
DISCONNECTED = 2
class aioafero.v1.controllers.event.AferoEvent[source]

Bases: TypedDict

Afero IoT Event message as emitted by the EventStream.

type: EventType
device_id: NotRequired[str]
device: NotRequired[AferoDevice]
polled_data: NotRequired[Any]
polled_devices: NotRequired[Any]
force_forward: NotRequired[bool]
class aioafero.v1.controllers.event.EventStream(bridge: AferoBridgeV1, polling_interval: int, poll_version: bool, discovery_interval: int = 3600)[source]

Bases: object

Data gatherer and eventer.

Polls Afero IoT API, converts the response into devices, and notifies subscribers of the event.

Parameters:
__init__(bridge: AferoBridgeV1, polling_interval: int, poll_version: bool, discovery_interval: int = 3600) None[source]

Initialize instance.

Parameters:
Return type:

None

property connected: bool

Return bool if we’re connected.

property status: EventStreamStatus

Return connection status.

property registered_multiple_devices: dict[str, Callable]

Get all registered callbacks for splitting devices.

property polling_interval: int

Number of seconds between polling.

property poll_version: bool

Determine if version polling should occur.

async wait_for_first_poll() None[source]

Wait until the first poll has completed.

Return type:

None

async initialize() None[source]

Start the polling processes.

Return type:

None

async initialize_discovery() None[source]

Initialize gathering data from Afero API.

Return type:

None

async initialize_device_polling() None[source]

Initialize gathering device state data from Afero API.

Return type:

None

async initialize_processor() None[source]

Initialize the processor.

Return type:

None

register_multi_device(name: str, generate_devices: callable)[source]

Register a callable to find multi-devices within the payload.

The callable must return a list of tracked AferoDevices

Parameters:
  • name (str)

  • generate_devices (callable)

async stop() None[source]

Stop listening for events.

Return type:

None

subscribe(callback: Callable[[EventType, dict | None], None], event_filter: EventType | tuple[EventType] | None = None, resource_filter: tuple[str] | None = None) Callable[source]

Subscribe to events emitted.

Parameters:
  • callback (Callable[[EventType, dict | None], None]) – callback function to call when an event emits.

  • event_filter (EventType | tuple[EventType] | None) – Optionally provide an EventType as filter.

  • resource_filter (tuple[str] | None) – Optionally provide a ResourceType as filter.

Returns:

function to unsubscribe.

Return type:

Callable

add_job(event: AferoEvent) None[source]

Manually add a job to be processed.

Parameters:

event (AferoEvent)

Return type:

None

async async_block_until_done()[source]

Blocking call until everything has finished.

emit(event_type: EventType, data: AferoEvent = None) None[source]

Emit event to all listeners.

Parameters:
Return type:

None

async process_backoff(attempt: int) None[source]

Handle backoff timer for Afero IoT API.

Parameters:
  • attempt (int) – Number of attempts

  • reason – Reason why the backoff is occurring

Return type:

None

async gather_discovery_data() list[dict[Any, str]][source]

Gather all data from the Afero IoT API.

Return type:

list[dict[Any, str]]

async generate_devices_from_data(data: list[dict[Any, str]]) list[AferoDevice][source]

Generate all devices from a given payload.

Generating devices will attempt to split devices where required and remove devices that are no longer needed, as identified by the callback.

Parameters:

data (list[dict[Any, str]])

Return type:

list[AferoDevice]

async split_devices(devices: list[AferoDevice]) list[AferoDevice][source]

Split Afero devices into multiple devices where required.

Parameters:

devices (list[AferoDevice])

Return type:

list[AferoDevice]

async generate_events_from_update(dev: AferoDevice) None[source]

Generate updates for a single device update.

Parameters:

dev (AferoDevice)

Return type:

None

async generate_events_from_data(data: list[dict[Any, str]]) None[source]

Process the raw Afero IoT data for emitting.

Parameters:

data (list[dict[Any, str]]) – Raw data from Afero IoT

Return type:

None

async perform_discovery_poll() None[source]

Poll Afero IoT and generate the required events.

Return type:

None

async process_event()[source]

Process a single event in the queue.

aioafero.v1.controllers.exhaust_fan module

Controller holding and managing Afero IoT resources of type exhaust-fan.

aioafero.v1.controllers.exhaust_fan.generate_split_name(afero_device: AferoDevice, instance: str) str[source]

Generate the name for an instanced element.

Parameters:
Return type:

str

aioafero.v1.controllers.exhaust_fan.get_split_instances(afero_dev: AferoDevice) list[str][source]

Determine available instances from the states.

Parameters:

afero_dev (AferoDevice)

Return type:

list[str]

aioafero.v1.controllers.exhaust_fan.get_valid_states(afero_dev: AferoDevice, instance: str) list[source]

Find states associated with the specific instance.

Parameters:
Return type:

list

aioafero.v1.controllers.exhaust_fan.exhaust_fan_callback(afero_device: AferoDevice) CallbackResponse[source]

Convert an AferoDevice into multiple devices.

Parameters:

afero_device (AferoDevice)

Return type:

CallbackResponse

class aioafero.v1.controllers.exhaust_fan.ExhaustFanController(bridge: AferoBridgeV1)[source]

Bases: BaseResourcesController[ExhaustFan]

Exhaust fans on bridge.exhaust_fans.

Tracks sensors, numbers, and selects. Toggles, fan speed, and light on the same unit are on bridge.switches, bridge.fans, and bridge.lights.

Parameters:

bridge (AferoBridgeV1)

ITEM_TYPE_ID: ResourceTypes | None = 'metadevice.device'
ITEM_TYPES: list[ResourceTypes] | None = [ResourceTypes.EXHAUST_FAN]
ITEM_CLS

alias of ExhaustFan

ITEM_MAPPING: dict = {}
ITEM_SENSORS: dict[str, str] = {}
ITEM_BINARY_SENSORS: dict[str, str] = {'humidity-threshold-met': 'above-threshold', 'motion-detection': 'motion-detected'}
ITEM_NUMBERS: dict[tuple[str, str | None], NumbersName] = {('auto-off-timer', 'auto-off'): ('seconds', None)}
ITEM_SELECTS: dict[tuple[str, str | None], str] = {('motion-action', 'exhaust-fan'): 'Motion Action', ('sensitivity', 'humidity-sensitivity'): 'Humidity Sensitivity'}
DEVICE_SPLIT_CALLBACKS: dict[str, callable] = {'exhaust-fan': <function exhaust_fan_callback>}
async initialize_elem(afero_device: AferoDevice) ExhaustFan[source]

Initialize the element.

Parameters:

afero_device (AferoDevice) – Afero Device that contains the updated states

Returns:

Newly initialized resource

Return type:

ExhaustFan

async update_elem(afero_device: AferoDevice) set[source]

Update the Exhaust Fan with the latest API data.

Parameters:

afero_device (AferoDevice) – Afero Device that contains the updated states

Returns:

States that have been modified

Return type:

set

async set_state(device_id: str, numbers: dict[tuple[str, str], float] | None = None, selects: dict[tuple[str, str], str] | None = None) None[source]

Update exhaust fan numbers and selects in the cloud.

Parameters:
  • device_id (str) – Device ID from this controller.

  • numbers (dict[tuple[str, str], float] | None) – Number features keyed by (functionClass, functionInstance).

  • selects (dict[tuple[str, str], str] | None) – Select features keyed by (functionClass, functionInstance).

Return type:

None

aioafero.v1.controllers.fan module

Controller holding and managing Afero IoT resources of type fan.

class aioafero.v1.controllers.fan.FanController(bridge: AferoBridgeV1)[source]

Bases: BaseResourcesController[Fan]

Fan devices on bridge.fans.

Parameters:

bridge (AferoBridgeV1)

ITEM_TYPE_ID: ResourceTypes | None = 'metadevice.device'
ITEM_TYPES: list[ResourceTypes] | None = [ResourceTypes.FAN]
ITEM_CLS

alias of Fan

ITEM_MAPPING: dict = {'direction': 'fan-reverse', 'on': 'power', 'speed': 'fan-speed'}
async turn_on(device_id: str) None[source]

Turn on the fan.

Parameters:

device_id (str) – Device ID from this controller.

Return type:

None

async turn_off(device_id: str) None[source]

Turn off the fan.

Parameters:

device_id (str) – Device ID from this controller.

Return type:

None

async set_speed(device_id: str, speed: int) None[source]

Set fan speed as a percentage.

Parameters:
  • device_id (str) – Device ID from this controller.

  • speed (int) – Speed percentage (0 turns the fan off).

Return type:

None

async set_direction(device_id: str, forward: bool) None[source]

Set fan rotation direction.

Parameters:
  • device_id (str) – Device ID from this controller.

  • forward (bool) – True for forward, False for reverse. Ignored if the fan is off (Hubspace API quirk).

Return type:

None

async set_preset(device_id: str, preset: bool) None[source]

Enable or disable the comfort-breeze preset.

Parameters:
  • device_id (str) – Device ID from this controller.

  • preset (bool) – True to enable the preset, False to disable.

Return type:

None

async initialize_elem(afero_device: AferoDevice) Fan[source]

Initialize the element.

Parameters:

afero_device (AferoDevice) – Afero Device that contains the updated states

Returns:

Newly initialized resource

Return type:

Fan

async update_elem(afero_device: AferoDevice) set[source]

Update the Fan with the latest API data.

Parameters:

afero_device (AferoDevice) – Afero Device that contains the updated states

Returns:

States that have been modified

Return type:

set

async set_state(device_id: str, on: bool | None = None, speed: int | None = None, forward: bool | None = None, preset: bool | None = None) None[source]

Update fan state in the cloud.

Parameters:
  • device_id (str) – Device ID from this controller.

  • on (bool | None) – Power state.

  • speed (int | None) – Fan speed percentage (0 turns off).

  • forward (bool | None) – True for forward rotation, False for reverse.

  • preset (bool | None) – Comfort-breeze preset enabled state.

Return type:

None

aioafero.v1.controllers.light module

Controller holding and managing Hubspace resources of type light.

aioafero.v1.controllers.light.process_names(values: list[dict]) set[str][source]

Extract unique names from the elements.

Parameters:

values (list[dict])

Return type:

set[str]

aioafero.v1.controllers.light.generate_split_name(afero_device: AferoDevice, instance: str) str[source]

Generate the name for an instanced element.

Parameters:
Return type:

str

aioafero.v1.controllers.light.get_split_instances(afero_dev: AferoDevice) list[tuple[str, ResourceTypes]][source]

Determine available instances from the states.

Parameters:

afero_dev (AferoDevice)

Return type:

list[tuple[str, ResourceTypes]]

aioafero.v1.controllers.light.state_belongs_to_light_instance(afero_dev: AferoDevice, state: AferoState, instance: str) bool[source]

Return whether a state belongs to a light zone instance.

Parameters:
Return type:

bool

aioafero.v1.controllers.light.state_matches_instance(afero_device: AferoDevice, state: AferoState) bool[source]

Return whether a state belongs to a split light instance.

Parameters:
Return type:

bool

aioafero.v1.controllers.light.resolve_function_instance(afero_device: AferoDevice) str | None[source]

Return the functionInstance key for this light resource (split zone or single).

Parameters:

afero_device (AferoDevice)

Return type:

str | None

aioafero.v1.controllers.light.get_color_modes_for_device(afero_device: AferoDevice) list[str][source]

Return supported color-mode names for this zone’s color-mode function.

Parameters:

afero_device (AferoDevice)

Return type:

list[str]

aioafero.v1.controllers.light.get_valid_states(afero_dev: AferoDevice, instance: str) list[source]

Find states associated with the specific instance.

Parameters:
Return type:

list

aioafero.v1.controllers.light.light_callback(afero_device: AferoDevice) CallbackResponse[source]

Convert an AferoDevice into multiple devices.

Parameters:

afero_device (AferoDevice)

Return type:

CallbackResponse

class aioafero.v1.controllers.light.LightController(bridge: AferoBridgeV1)[source]

Bases: BaseResourcesController[Light]

Light devices on bridge.lights (including split zones).

Parameters:

bridge (AferoBridgeV1)

ITEM_TYPE_ID: ResourceTypes | None = 'metadevice.device'
ITEM_TYPES: list[ResourceTypes] | None = [ResourceTypes.LIGHT]
ITEM_CLS

alias of Light

ITEM_MAPPING: dict = {'color': 'color-rgb', 'color_mode': 'color-mode', 'color_temperature': 'color-temperature', 'dimming': 'brightness', 'effect': 'color-sequence'}
ITEM_NUMBERS: dict[tuple[str, str | None], NumbersName] = {('speed', 'color-sequence'): ('speed', None)}
DEVICE_SPLIT_CALLBACKS: dict[str, callable] = {'light': <function light_callback>}
async turn_on(device_id: str) None[source]

Turn on the light.

Parameters:

device_id (str) – Device ID from this controller.

Return type:

None

async turn_off(device_id: str) None[source]

Turn off the light.

Parameters:

device_id (str) – Device ID from this controller.

Return type:

None

async set_color_temperature(device_id: str, temperature: int) None[source]

Set color temperature or white mode when CCT is unavailable.

Parameters:
  • device_id (str) – Device ID from this controller.

  • temperature (int) – Color temperature in kelvin.

Return type:

None

async set_white(device_id: str, *, on: bool | None = True, brightness: int | None = None) None[source]

Set white mode without a color-temperature function.

Parameters:
  • device_id (str) – Device ID from this controller.

  • on (bool | None) – Power state (defaults to True).

  • brightness (int | None) – Brightness percentage when on is True.

Return type:

None

async set_brightness(device_id: str, brightness: int) None[source]

Set brightness, turning the light on if needed.

Parameters:
  • device_id (str) – Device ID from this controller.

  • brightness (int) – Brightness percentage.

Return type:

None

async set_rgb(device_id: str, red: int, green: int, blue: int) None[source]

Set RGB color, turning the light on if needed.

Parameters:
  • device_id (str) – Device ID from this controller.

  • red (int) – Red channel 0255.

  • green (int) – Green channel 0255.

  • blue (int) – Blue channel 0255.

Return type:

None

async set_effect(device_id: str, effect: str) None[source]

Set a color sequence effect, turning the light on if needed.

Parameters:
  • device_id (str) – Device ID from this controller.

  • effect (str) – Effect name from the model’s effect.effects list.

Return type:

None

async initialize_elem(afero_device: AferoDevice) Light[source]

Initialize the element.

Parameters:

afero_device (AferoDevice) – Afero Device that contains the updated states

Returns:

Newly initialized resource

Return type:

Light

async update_elem(afero_device: AferoDevice) set[source]

Update the Light with the latest API data.

Parameters:

afero_device (AferoDevice) – Afero Device that contains the updated states

Returns:

States that have been modified

Return type:

set

async update_elem_color(cur_item: Light, color_seq_states: dict) set[source]

Perform the update for effects.

Parameters:
Return type:

set

async set_state(device_id: str, on: bool | None = None, temperature: int | None = None, brightness: int | None = None, color_mode: str | None = None, color: tuple[int, int, int] | None = None, effect: str | None = None, force_white_mode: int | None = None, numbers: dict[tuple[str, str], float] | None = None) None[source]

Update light state in the cloud.

Parameters:
  • device_id (str) – Device ID from this controller.

  • on (bool | None) – Power state.

  • temperature (int | None) – Color temperature in kelvin.

  • brightness (int | None) – Brightness percentage.

  • color_mode (str | None) – API color mode (white, color, sequence, etc.).

  • color (tuple[int, int, int] | None) – RGB tuple (red, green, blue).

  • effect (str | None) – Named color sequence effect.

  • force_white_mode (int | None) – Brightness to apply after forcing white mode.

  • numbers (dict[tuple[str, str], float] | None) – Number features keyed by (functionClass, functionInstance).

Return type:

None

aioafero.v1.controllers.light.process_color_temps(color_temps: dict) list[int][source]

Determine the supported color temps.

Parameters:

color_temps (dict) – Result from functions[“values”]

Return type:

list[int]

aioafero.v1.controllers.light.process_effects(functions: list[dict]) dict[str, set][source]

Determine the supported effects.

Parameters:

functions (list[dict])

Return type:

dict[str, set]

aioafero.v1.controllers.lock module

Controller holding and managing Afero IoT resources of type lock.

class aioafero.v1.controllers.lock.LockController(bridge: AferoBridgeV1)[source]

Bases: BaseResourcesController[Lock]

Lock devices on bridge.locks.

Parameters:

bridge (AferoBridgeV1)

ITEM_TYPE_ID: ResourceTypes | None = 'metadevice.device'
ITEM_TYPES: list[ResourceTypes] | None = [ResourceTypes.LOCK]
ITEM_CLS

alias of Lock

ITEM_MAPPING: dict = {'position': 'lock-control'}
async lock(device_id: str) None[source]

Engage the lock.

Parameters:

device_id (str) – Device ID from this controller.

Return type:

None

async unlock(device_id: str) None[source]

Disengage the lock.

Parameters:

device_id (str) – Device ID from this controller.

Return type:

None

async initialize_elem(afero_device: AferoDevice) Lock[source]

Initialize the element.

Parameters:

afero_device (AferoDevice) – Afero Device that contains the updated states

Returns:

Newly initialized resource

Return type:

Lock

async update_elem(afero_device: AferoDevice) set[source]

Update the Lock with the latest API data.

Parameters:

afero_device (AferoDevice) – Afero Device that contains the updated states

Returns:

States that have been modified

Return type:

set

async set_state(device_id: str, lock_position: CurrentPositionEnum | None = None) None[source]

Update lock state in the cloud.

Parameters:
  • device_id (str) – Device ID from this controller.

  • lock_position (CurrentPositionEnum | None) – Target lock position (LOCKING / UNLOCKING).

Return type:

None

aioafero.v1.controllers.portable_ac module

Controller holding and managing Afero IoT resources of type portable-air-conditioner.

aioafero.v1.controllers.portable_ac.generate_split_name(afero_device: AferoDevice, instance: str) str[source]

Generate the name for an instanced element.

Parameters:
Return type:

str

aioafero.v1.controllers.portable_ac.get_valid_states(afero_dev: AferoDevice) list[source]

Find states associated with the element.

Parameters:

afero_dev (AferoDevice)

Return type:

list

aioafero.v1.controllers.portable_ac.portable_ac_callback(afero_device: AferoDevice) CallbackResponse[source]

Convert an AferoDevice into multiple devices.

Parameters:

afero_device (AferoDevice)

Return type:

CallbackResponse

class aioafero.v1.controllers.portable_ac.PortableACController(bridge: AferoBridgeV1)[source]

Bases: ClimateController[PortableAC]

Portable air conditioners on bridge.portable_acs.

The power toggle is split onto bridge.switches.

Parameters:

bridge (AferoBridgeV1)

ITEM_TYPE_ID: ResourceTypes | None = 'metadevice.device'
ITEM_TYPES: list[ResourceTypes] | None = [ResourceTypes.PORTABLE_AC]
ITEM_CLS

alias of PortableAC

ITEM_MAPPING: dict = {'hvac_mode': 'mode'}
ITEM_SELECTS: dict[tuple[str, str | None], str] = {('air-swing', None): 'Swing', ('fan-speed', 'ac-fan-speed'): 'Fan Speed', ('sleep', None): 'Sleep Mode'}
DEVICE_SPLIT_CALLBACKS: dict[str, callable] = {'portable-air-conditioner': <function portable_ac_callback>}
async initialize_elem(afero_device: AferoDevice) PortableAC[source]

Initialize the element.

Parameters:

afero_device (AferoDevice) – Afero Device that contains the updated states

Returns:

Newly initialized resource

Return type:

PortableAC

async update_elem(afero_device: AferoDevice) set[source]

Update the Portable AC with the latest API data.

Parameters:

afero_device (AferoDevice) – Afero Device that contains the updated states

Returns:

States that have been modified

Return type:

set

async set_state(device_id: str, **kwargs) None[source]

Update portable AC climate state in the cloud.

Parameters:
  • device_id (str) – Device ID from this controller.

  • hvac_mode – HVAC mode name from hvac_mode.supported_modes.

  • target_temperature – Cooling setpoint shorthand.

  • target_temperature_cooling – Cooling setpoint.

  • target_temperature_heating – Heating setpoint (when supported).

  • selects – Select features keyed by (functionClass, functionInstance).

  • **kwargs – Remaining climate fields forwarded to set_climate_state.

Return type:

None

aioafero.v1.controllers.security_system module

Controller holding and managing Afero IoT resources of type security-system.

aioafero.v1.controllers.security_system.get_sensor_ids(device) set[int][source]

Determine available sensors from the states.

Return type:

set[int]

aioafero.v1.controllers.security_system.generate_sensor_name(afero_device, sensor_id: int) str[source]

Generate the name for an instanced element.

Parameters:

sensor_id (int)

Return type:

str

aioafero.v1.controllers.security_system.get_valid_states(afero_states: list, sensor_id: int) list[source]

Find states associated with the specific sensor.

Parameters:
  • afero_states (list)

  • sensor_id (int)

Return type:

list

aioafero.v1.controllers.security_system.get_model_type(states: list[AferoState], sensor_id: int) str[source]

Get the model type from the state list.

Parameters:
Return type:

str

aioafero.v1.controllers.security_system.get_valid_functions(afero_functions: list, sensor_id: int) list[source]

Find functions associated with the specific sensor.

Parameters:
  • afero_functions (list)

  • sensor_id (int)

Return type:

list

aioafero.v1.controllers.security_system.get_sensor_name(afero_capabilities: list[AferoCapability], sensor_id: int) str[source]

Get the Afero name for a specific sensor.

Parameters:
Return type:

str

aioafero.v1.controllers.security_system.security_system_callback(afero_device: AferoDevice) CallbackResponse[source]

Convert an AferoDevice into multiple devices.

Parameters:

afero_device (AferoDevice)

Return type:

CallbackResponse

class aioafero.v1.controllers.security_system.SecuritySystemController(bridge: AferoBridgeV1)[source]

Bases: BaseResourcesController[SecuritySystem]

Security systems on bridge.security_systems.

Parameters:

bridge (AferoBridgeV1)

ITEM_TYPE_ID: ResourceTypes | None = 'metadevice.device'
ITEM_TYPES: list[ResourceTypes] | None = [ResourceTypes.SECURITY_SYSTEM]
ITEM_CLS

alias of SecuritySystem

ITEM_MAPPING: dict = {'alarm_state': 'alarm-state'}
ITEM_SENSORS: dict[str, str] = {'alarm-state': None, 'disarmed-by': None, 'history-event': None}
ITEM_BINARY_SENSORS: dict[str, str] = {'battery-powered': 'battery-powered'}
ITEM_NUMBERS: dict[tuple[str, str | None], NumbersName] = {('arm-exit-delay', 'away'): ('seconds', 'Arm Exit Delay Away'), ('arm-exit-delay', 'stay'): ('seconds', 'Arm Exit Delay Home'), ('disarm-entry-delay', None): ('seconds', 'Disarm Entry Delay'), ('siren-alarm-timeout', None): ('seconds', 'Siren Timeout'), ('temporary-bypass-time', None): ('seconds', 'Bypass Time')}
ITEM_SELECTS: dict[tuple[str, str | None], str] = {('bypass-allowed', None): 'Enable Temporary Bypass', ('song-id', 'alarm'): 'Alarm Noise', ('song-id', 'chime'): 'Chime Noise', ('volume', 'chime'): 'Chime Volume', ('volume', 'entry-delay'): 'Entry Delay Volume', ('volume', 'exit-delay-away'): 'Exit Delay Volume Away', ('volume', 'exit-delay-stay'): 'Exit Delay Volume Home', ('volume', 'siren'): 'Alarm Volume'}
DEVICE_SPLIT_CALLBACKS: dict[str, callable] = {'security-system-sensor': <function security_system_callback>}
async disarm(device_id: str, disarm_pin: int) None[source]

Disarm the security system.

Parameters:
  • device_id (str) – Device ID from this controller.

  • disarm_pin (int) – Numeric PIN configured on the panel.

Return type:

None

async arm_home(device_id: str) None[source]

Arm the system in home mode.

Parameters:

device_id (str) – Device ID from this controller.

Return type:

None

async arm_away(device_id: str) None[source]

Arm the system in away mode.

Parameters:

device_id (str) – Device ID from this controller.

Return type:

None

async alarm_trigger(device_id: str) None[source]

Manually trigger the alarm siren.

Parameters:

device_id (str) – Device ID from this controller.

Return type:

None

async initialize_elem(afero_device: AferoDevice) SecuritySystem[source]

Initialize the element.

Parameters:

afero_device (AferoDevice) – Afero Device that contains the updated states

Returns:

Newly initialized resource

Return type:

SecuritySystem

async update_elem(afero_device: AferoDevice) set[source]

Update the Security System with the latest API data.

Parameters:

afero_device (AferoDevice) – Afero Device that contains the updated states

Returns:

States that have been modified

Return type:

set

async set_state(device_id: str, disarm_pin: int | None = None, command: int | None = None, numbers: dict[tuple[str, str | None], float] | None = None, selects: dict[tuple[str, str | None], str] | None = None) None[source]

Update security system state in the cloud.

Parameters:
  • device_id (str) – Device ID from this controller.

  • disarm_pin (int | None) – PIN for disarm commands.

  • command (int | None) – Panel command code (2 away, 4 home, 5 alarm trigger).

  • numbers (dict[tuple[str, str | None], float] | None) – Number features keyed by (functionClass, functionInstance).

  • selects (dict[tuple[str, str | None], str] | None) – Select features keyed by (functionClass, functionInstance).

Return type:

None

async refresh_alarm_state(device_id: str) None[source]

Refresh the alarm state after alarm state change command.

Parameters:

device_id (str)

Return type:

None

async validate_disarm_pin(device_id: str) None[source]

Ensure the system has switched to disarmed.

Parameters:

device_id (str)

Return type:

None

async validate_arm_state(device_id: str, arm_type: int) bool[source]

Ensure the system can arm.

Parameters:
  • device_id (str)

  • arm_type (int)

Return type:

bool

aioafero.v1.controllers.security_system_keypad module

Controller holding and managing Afero IoT resources of type security-system-keypad.

class aioafero.v1.controllers.security_system_keypad.SecuritySystemKeypadController(bridge: AferoBridgeV1)[source]

Bases: BaseResourcesController[SecuritySystemKeypad]

Security keypads on bridge.security_systems_keypads.

Parameters:

bridge (AferoBridgeV1)

ITEM_TYPE_ID: ResourceTypes | None = 'metadevice.device'
ITEM_TYPES: list[ResourceTypes] | None = [ResourceTypes.SECURITY_SYSTEM_KEYPAD]
ITEM_CLS

alias of SecuritySystemKeypad

ITEM_BINARY_SENSORS: dict[str, str] = {'tamper-detection': 'tampered'}
ITEM_SELECTS: dict[tuple[str, str | None], str] = {('volume', 'buzzer-volume'): 'Buzzer Volume'}
async initialize_elem(afero_device: AferoDevice) SecuritySystemKeypad[source]

Initialize the element.

Parameters:

afero_device (AferoDevice) – Afero Device that contains the updated states

Returns:

Newly initialized resource

Return type:

SecuritySystemKeypad

async update_elem(afero_device: AferoDevice) set[source]

Update the Security System with the latest API data.

Parameters:

afero_device (AferoDevice) – Afero Device that contains the updated states

Returns:

States that have been modified

Return type:

set

async set_state(device_id: str, selects: dict[tuple[str, str | None], str] | None = None) None[source]

Update security keypad selects in the cloud.

Parameters:
  • device_id (str) – Device ID from this controller.

  • selects (dict[tuple[str, str | None], str] | None) – Select features keyed by (functionClass, functionInstance).

Return type:

None

aioafero.v1.controllers.security_system_sensor module

Controller holding and managing Afero IoT resources of type security-system.

class aioafero.v1.controllers.security_system_sensor.SecuritySystemSensorController(bridge: AferoBridgeV1)[source]

Bases: BaseResourcesController[SecuritySystemSensor]

Security sensors split from a system on bridge.security_systems_sensors.

Parameters:

bridge (AferoBridgeV1)

ITEM_TYPE_ID: ResourceTypes | None = 'metadevice.device'
ITEM_TYPES: list[ResourceTypes] | None = [ResourceTypes.SECURITY_SYSTEM_SENSOR]
ITEM_CLS

alias of SecuritySystemSensor

ITEM_MAPPING: dict = {}
SENSOR_TYPES = {1: 'Motion Sensor', 2: 'Door/Window Sensor'}
ITEM_BINARY_SENSORS: dict[str, str] = {'tampered': 'On', 'triggered': 'On'}
ITEM_SELECTS: dict[tuple[str, str | None], str] = {('bypassType', None): 'Bypass', ('chirpMode', None): 'Chime', ('triggerType', None): 'Alarming State'}
async initialize_elem(device: AferoDevice)[source]

Initialize the element.

Parameters:
  • afero_device – Afero Device that contains the updated states

  • device (AferoDevice)

Returns:

Newly initialized resource

async update_elem(afero_device: AferoDevice) set[str][source]

Update the Security System Sensor with the latest API data.

Parameters:

afero_device (AferoDevice) – Afero Device that contains the updated states

Returns:

States that have been modified

Return type:

set[str]

async set_state(device_id: str, selects: dict[tuple[str, int | None], str] | None = None) None[source]

Update security sensor selects in the cloud.

Parameters:
  • device_id (str) – Device ID from this controller.

  • selects (dict[tuple[str, int | None], str] | None) – Select values keyed by (functionClass, functionInstance). Supported keys include chirpMode, triggerType, and bypassType.

Return type:

None

aioafero.v1.controllers.switch module

Controller holding and managing Afero IoT resources of type switch.

class aioafero.v1.controllers.switch.SwitchController(bridge: AferoBridgeV1)[source]

Bases: BaseResourcesController[Switch]

Switch devices on bridge.switches.

A switch can have one or more toggleable elements controlled by instance.

Parameters:

bridge (AferoBridgeV1)

ITEM_TYPE_ID: ResourceTypes | None = 'metadevice.device'
ITEM_TYPES: list[ResourceTypes] | None = [ResourceTypes.SWITCH, ResourceTypes.POWER_OUTLET, ResourceTypes.LANDSCAPE_TRANSFORMER]
ITEM_CLS

alias of Switch

ITEM_MAPPING: dict = {}
ITEM_SENSORS: dict[str, str] = {'output-voltage-switch': 'V', 'watts': 'W'}
ITEM_BINARY_SENSORS: dict[str, str] = {}
async turn_on(device_id: str, instance: str | None = None) None[source]

Turn on the switch.

Parameters:
  • device_id (str) – Device ID from this controller.

  • instance (str | None) – functionInstance when the device has multiple toggles.

Return type:

None

async turn_off(device_id: str, instance: str | None = None) None[source]

Turn off the switch.

Parameters:
  • device_id (str) – Device ID from this controller.

  • instance (str | None) – functionInstance when the device has multiple toggles.

Return type:

None

async initialize_elem(afero_device: AferoDevice) Switch[source]

Initialize the element.

Parameters:

afero_device (AferoDevice) – Afero Device that contains the updated states

Returns:

Newly initialized resource

Return type:

Switch

async update_elem(afero_device: AferoDevice) set[source]

Update the Switch with the latest API data.

Parameters:

afero_device (AferoDevice) – Afero Device that contains the updated states

Returns:

States that have been modified

Return type:

set

async set_state(device_id: str, on: bool | None = None, instance: str | None = None) None[source]

Update switch state in the cloud.

Parameters:
  • device_id (str) – Device ID from this controller.

  • on (bool | None) – Power state for the selected instance.

  • instance (str | None) – functionInstance when the device has multiple toggles.

Return type:

None

aioafero.v1.controllers.thermostat module

Controller holding and managing Afero IoT resources of type thermostat.

class aioafero.v1.controllers.thermostat.ThermostatController(bridge: AferoBridgeV1)[source]

Bases: ClimateController[Thermostat]

Thermostat devices on bridge.thermostats.

Parameters:

bridge (AferoBridgeV1)

ITEM_TYPE_ID: ResourceTypes | None = 'metadevice.device'
ITEM_TYPES: list[ResourceTypes] | None = [ResourceTypes.THERMOSTAT]
ITEM_CLS

alias of Thermostat

ITEM_MAPPING: dict = {'fan_mode': 'fan-mode', 'hvac_mode': 'mode'}
ITEM_BINARY_SENSORS: dict[str, str] = {'filter-replacement': 'replacement-needed', 'max-temp-exceeded': 'alerting', 'min-temp-exceeded': 'alerting'}
async initialize_elem(afero_device: AferoDevice) Thermostat[source]

Initialize the element.

Parameters:

afero_device (AferoDevice) – Afero Device that contains the updated states

Returns:

Newly initialized resource

Return type:

Thermostat

async update_elem(afero_device: AferoDevice) set[source]

Update the Thermostat with the latest API data.

Parameters:

afero_device (AferoDevice) – Afero Device that contains the updated states

Returns:

States that have been modified

Return type:

set

async set_fan_mode(device_id: str, fan_mode: str) None[source]

Set thermostat fan mode.

Parameters:
  • device_id (str) – Device ID from this controller.

  • fan_mode (str) – Fan mode name from the device model’s fan_mode.modes.

Return type:

None

async set_hvac_mode(device_id: str, hvac_mode: str) None[source]

Set HVAC mode.

Parameters:
  • device_id (str) – Device ID from this controller.

  • hvac_mode (str) – Mode name from hvac_mode.supported_modes on the model.

Return type:

None

async set_target_temperature(device_id: str, target_temperature: float) None[source]

Set target temperature for the active heat/cool mode.

Parameters:
  • device_id (str) – Device ID from this controller.

  • target_temperature (float) – Target temperature in the bridge’s configured unit.

Return type:

None

async set_temperature_range(device_id: str, temp_low: float, temp_high: float) None[source]

Set auto-mode heating/cooling setpoints.

Parameters:
  • device_id (str) – Device ID from this controller.

  • temp_low (float) – Auto-mode heating setpoint.

  • temp_high (float) – Auto-mode cooling setpoint.

Return type:

None

async set_state(device_id: str, fan_mode: str | None = None, hvac_mode: str | None = None, safety_max_temp: float | None = None, safety_min_temp: float | None = None, target_temperature_auto_heating: float | None = None, target_temperature_auto_cooling: float | None = None, target_temperature_heating: float | None = None, target_temperature_cooling: float | None = None, **kwargs) None[source]

Update thermostat state in the cloud.

Parameters:
  • device_id (str) – Device ID from this controller.

  • fan_mode (str | None) – Fan mode name.

  • hvac_mode (str | None) – HVAC mode name.

  • safety_max_temp (float | None) – Maximum safety cutoff temperature.

  • safety_min_temp (float | None) – Minimum safety cutoff temperature.

  • target_temperature_auto_heating (float | None) – Auto-mode heating setpoint.

  • target_temperature_auto_cooling (float | None) – Auto-mode cooling setpoint.

  • target_temperature_heating (float | None) – Heating setpoint.

  • target_temperature_cooling (float | None) – Cooling setpoint.

  • target_temperature – Shorthand applied to the active heat/cool setpoint.

  • **kwargs – Remaining climate fields forwarded to set_climate_state.

Return type:

None

aioafero.v1.controllers.thermostat.get_supported_modes(system_type: str, all_modes: set[str]) set[source]

Determine the supported modes based on the system_type.

Parameters:
Return type:

set

aioafero.v1.controllers.valve module

Controller holding and managing Afero IoT resources of type valve.

class aioafero.v1.controllers.valve.ValveController(bridge: AferoBridgeV1)[source]

Bases: BaseResourcesController[Valve]

Valve / water-timer devices on bridge.valves.

Valves can have multiple toggleable elements controlled by instance.

Parameters:

bridge (AferoBridgeV1)

ITEM_TYPE_ID: ResourceTypes | None = 'metadevice.device'
ITEM_TYPES: list[ResourceTypes] | None = [ResourceTypes.WATER_TIMER]
ITEM_CLS

alias of Valve

ITEM_MAPPING: dict = {}
async turn_on(device_id: str, instance: str | None = None) None[source]

Open the valve.

Parameters:
  • device_id (str) – Device ID from this controller.

  • instance (str | None) – functionInstance for multi-zone valves.

Return type:

None

async turn_off(device_id: str, instance: str | None = None) None[source]

Close the valve.

Parameters:
  • device_id (str) – Device ID from this controller.

  • instance (str | None) – functionInstance for multi-zone valves.

Return type:

None

async initialize_elem(afero_device: AferoDevice) Valve[source]

Initialize the element.

Parameters:

afero_device (AferoDevice) – Afero Device that contains the updated states

Returns:

Newly initialized resource

Return type:

Valve

async update_elem(afero_device: AferoDevice) set[source]

Update the Valve with the latest API data.

Parameters:

afero_device (AferoDevice) – Afero Device that contains the updated states

Returns:

States that have been modified

Return type:

set

async set_state(device_id: str, valve_open: bool | None = None, instance: str | None = None) None[source]

Update valve state in the cloud.

Parameters:
  • device_id (str) – Device ID from this controller.

  • valve_open (bool | None) – True to open, False to close.

  • instance (str | None) – functionInstance for multi-zone valves.

Return type:

None

Module contents

Sub-package that holds controllers for creating and updating devices from Afero API.