Home Assistant Unofficial Reference 2024.12.1
homeassistant.components.group.util Namespace Reference

Functions

bool _values_equal (Iterator[Any] values)
 
bool attribute_equal (list[State] states, str key)
 
Iterator[Any] find_state (list[State] states)
 
Iterator[Any] find_state_attributes (list[State] states, str key)
 
int mean_int (*Any args)
 
tuple[float|Any,...] mean_tuple (*Any args)
 
Any|None most_frequent_attribute (list[State] states, str key)
 
Any reduce_attribute (list[State] states, str key, Any|None default=None, Callable[..., Any] reduce=mean_int)
 
bool states_equal (list[State] states)
 

Detailed Description

Utility functions to combine state attributes from multiple entities.

Function Documentation

◆ _values_equal()

bool homeassistant.components.group.util._values_equal ( Iterator[Any]  values)
private
Return True if all values are equal.

Note: Returns True if no matching attribute is found.

Definition at line 58 of file util.py.

◆ attribute_equal()

bool homeassistant.components.group.util.attribute_equal ( list[State states,
str  key 
)
Return True if all attributes found matching key from states are equal.

Note: Returns True if no matching attribute is found.

Definition at line 35 of file util.py.

◆ find_state()

Iterator[Any] homeassistant.components.group.util.find_state ( list[State states)
Find state from states.

Definition at line 19 of file util.py.

◆ find_state_attributes()

Iterator[Any] homeassistant.components.group.util.find_state_attributes ( list[State states,
str  key 
)
Find attributes with matching key from states.

Definition at line 12 of file util.py.

◆ mean_int()

int homeassistant.components.group.util.mean_int ( *Any  args)
Return the mean of the supplied values.

Definition at line 25 of file util.py.

◆ mean_tuple()

tuple[float | Any, ...] homeassistant.components.group.util.mean_tuple ( *Any  args)
Return the mean values along the columns of the supplied values.

Definition at line 30 of file util.py.

◆ most_frequent_attribute()

Any | None homeassistant.components.group.util.most_frequent_attribute ( list[State states,
str  key 
)
Find attributes with matching key from states.

Definition at line 43 of file util.py.

◆ reduce_attribute()

Any homeassistant.components.group.util.reduce_attribute ( list[State states,
str  key,
Any | None   default = None,
Callable[..., Any]   reduce = mean_int 
)
Find the first attribute matching key from states.

If none are found, return default.

Definition at line 67 of file util.py.

◆ states_equal()

bool homeassistant.components.group.util.states_equal ( list[State states)
Return True if all states are equal.

Note: Returns True if no matching attribute is found.

Definition at line 50 of file util.py.