Thermostats

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

Bases: ClimateController[Thermostat]

Thermostat devices on bridge.thermostats.

Parameters:

bridge (AferoBridgeV1)

ITEM_CLS

alias of Thermostat

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

__contains__(device_id: str) bool

Return bool if device_id is in items.

Parameters:

device_id (str)

Return type:

bool

__getitem__(device_id: str) AferoResource

Get item by device_id.

Parameters:

device_id (str)

Return type:

AferoResource

__init__(bridge: AferoBridgeV1) None

Initialize instance.

Parameters:

bridge (AferoBridgeV1)

Return type:

None

__iter__() Iterator

Iterate items.

Return type:

Iterator

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

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

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

Generate update data for the event controller.

Parameters:
Return type:

AferoDevice

get_device(device_id: str) AferoResource

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

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

Determine devices that align to the controller.

Parameters:

initial_data (list[dict])

Return type:

list[AferoDevice]

async initialize() None

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_climate_elem(afero_device: AferoDevice) dict

Initialize the climate elements of a device.

Parameters:

afero_device (AferoDevice)

Return type:

dict

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

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

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

Initialize the sensor.

Parameters:
  • state (AferoState) – State to update

  • child_id (str) – device_id of the parent device

Return type:

AferoSensor | AferoBinarySensor | None

property initialized: bool

Determine if the controller has been initialized.

property items: list[AferoResource]

Return all items for this resource.

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

Set climate state.

Parameters:

device_id (str)

Return type:

None

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

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

Parameters:

state (AferoState)

Return type:

tuple[Any, str | None]

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

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

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

Get all subscribers aligned to this controller.

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

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

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

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_climate_elem(afero_device: AferoDevice) set

Update the climate elements of a device.

Parameters:

afero_device (AferoDevice)

Return type:

set

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

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

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

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