Home Assistant Unofficial Reference 2024.12.1
homeassistant.components.bayesian.binary_sensor.BayesianBinarySensor Class Reference
Inheritance diagram for homeassistant.components.bayesian.binary_sensor.BayesianBinarySensor:
[legend]
Collaboration diagram for homeassistant.components.bayesian.binary_sensor.BayesianBinarySensor:
[legend]

Public Member Functions

None __init__ (self, str name, str|None unique_id, float prior, list[ConfigType] observations, float probability_threshold, BinarySensorDeviceClass|None device_class)
 
None async_added_to_hass (self)
 
None async_update (self)
 
dict[str, Any] extra_state_attributes (self)
 
- Public Member Functions inherited from homeassistant.components.binary_sensor.BinarySensorEntity
None async_internal_added_to_hass (self)
 
- Public Member Functions inherited from homeassistant.helpers.entity.Entity
None __init_subclass__ (cls, **Any kwargs)
 
str __repr__ (self)
 
None add_to_platform_abort (self)
 
None add_to_platform_finish (self)
 
None add_to_platform_start (self, HomeAssistant hass, EntityPlatform platform, asyncio.Semaphore|None parallel_updates)
 
bool assumed_state (self)
 
None async_device_update (self, bool warning=True)
 
None async_internal_will_remove_from_hass (self)
 
None async_on_remove (self, CALLBACK_TYPE func)
 
None async_registry_entry_updated (self)
 
None async_remove (self, *bool force_remove=False)
 
None async_removed_from_registry (self)
 
None async_schedule_update_ha_state (self, bool force_refresh=False)
 
None async_set_context (self, Context context)
 
None async_update_ha_state (self, bool force_refresh=False)
 
None async_will_remove_from_hass (self)
 
None async_write_ha_state (self)
 
str|None attribution (self)
 
bool available (self)
 
dict[str, Any]|None capability_attributes (self)
 
str|None device_class (self)
 
DeviceInfo|None device_info (self)
 
bool enabled (self)
 
EntityCategory|None entity_category (self)
 
str|None entity_picture (self)
 
bool entity_registry_enabled_default (self)
 
bool entity_registry_visible_default (self)
 
bool force_update (self)
 
HassJobType get_hassjob_type (self, str function_name)
 
er.EntityOptionsType|None get_initial_entity_options (self)
 
bool has_entity_name (self)
 
str|None icon (self)
 
str|UndefinedType|None name (self)
 
None schedule_update_ha_state (self, bool force_refresh=False)
 
bool should_poll (self)
 
StateType state (self)
 
dict[str, Any]|None state_attributes (self)
 
str|None suggested_object_id (self)
 
int|None supported_features (self)
 
str|None translation_key (self)
 
Mapping[str, strtranslation_placeholders (self)
 
str|None unique_id (self)
 
str|None unit_of_measurement (self)
 
bool use_device_name (self)
 
- Public Member Functions inherited from homeassistant.helpers.entity.CachedProperties
None __init__ (cls, str name, tuple[type,...] bases, dict[Any, Any] namespace, **Any kwargs)
 
Any __new__ (mcs, str name, tuple[type,...] bases, dict[Any, Any] namespace, set[str]|None cached_properties=None, **Any kwargs)
 

Public Attributes

 observations_by_entity
 
 observations_by_template
 
 prior
 
 probability
 
- Public Attributes inherited from homeassistant.components.binary_sensor.BinarySensorEntity
 entity_category
 
- Public Attributes inherited from homeassistant.helpers.entity.Entity
 device_entry
 
 entity_id
 
 hass
 
 parallel_updates
 
 platform
 
 registry_entry
 

Private Member Functions

dict[str, list[Observation]] _build_observations_by_entity (self)
 
dict[Template, list[Observation]] _build_observations_by_template (self)
 
float _calculate_new_probability (self)
 
OrderedDict[UUID, Observation_initialize_current_observations (self)
 
bool|None _process_numeric_state (self, Observation entity_observation, bool multi=False)
 
bool|None _process_state (self, Observation entity_observation, bool multi=False)
 
None _recalculate_and_write_state (self)
 
OrderedDict[UUID, Observation_record_entity_observations (self, str entity)
 

Private Attributes

 _attr_device_class
 
 _attr_is_on
 
 _attr_name
 
 _attr_unique_id
 
 _observations
 
 _probability_threshold
 

Static Private Attributes

bool _attr_should_poll = False
 

Additional Inherited Members

- Static Public Attributes inherited from homeassistant.components.binary_sensor.BinarySensorEntity
 None
 
- Static Public Attributes inherited from homeassistant.helpers.entity.Entity
 bool
 
 EntityPlatform
 
 HomeAssistant
 
 None
 
 StateInfo
 
 StateType
 
 str
 

Detailed Description

Representation of a Bayesian sensor.

Definition at line 229 of file binary_sensor.py.

Constructor & Destructor Documentation

◆ __init__()

None homeassistant.components.bayesian.binary_sensor.BayesianBinarySensor.__init__ (   self,
str  name,
str | None  unique_id,
float  prior,
list[ConfigType]  observations,
float  probability_threshold,
BinarySensorDeviceClass | None  device_class 
)
Initialize the Bayesian sensor.

Definition at line 234 of file binary_sensor.py.

Member Function Documentation

◆ _build_observations_by_entity()

dict[str, list[Observation]] homeassistant.components.bayesian.binary_sensor.BayesianBinarySensor._build_observations_by_entity (   self)
private
Build and return data structure of the form below.

{
    "sensor.sensor1": [Observation, Observation],
    "sensor.sensor2": [Observation],
    ...
}

Each "observation" must be recognized uniquely, and it should be possible
for all relevant observations to be looked up via their `entity_id`.

Definition at line 449 of file binary_sensor.py.

◆ _build_observations_by_template()

dict[Template, list[Observation]] homeassistant.components.bayesian.binary_sensor.BayesianBinarySensor._build_observations_by_template (   self)
private
Build and return data structure of the form below.

{
    "template": [Observation, Observation],
    "template2": [Observation],
    ...
}

Each "observation" must be recognized uniquely, and it should be possible
for all relevant observations to be looked up via their `template`.

Definition at line 476 of file binary_sensor.py.

◆ _calculate_new_probability()

float homeassistant.components.bayesian.binary_sensor.BayesianBinarySensor._calculate_new_probability (   self)
private

Definition at line 412 of file binary_sensor.py.

◆ _initialize_current_observations()

OrderedDict[UUID, Observation] homeassistant.components.bayesian.binary_sensor.BayesianBinarySensor._initialize_current_observations (   self)
private

Definition at line 391 of file binary_sensor.py.

◆ _process_numeric_state()

bool | None homeassistant.components.bayesian.binary_sensor.BayesianBinarySensor._process_numeric_state (   self,
Observation  entity_observation,
bool   multi = False 
)
private
Return True if numeric condition is met, return False if not, return None otherwise.

Definition at line 499 of file binary_sensor.py.

◆ _process_state()

bool | None homeassistant.components.bayesian.binary_sensor.BayesianBinarySensor._process_state (   self,
Observation  entity_observation,
bool   multi = False 
)
private
Return True if state conditions are met, return False if they are not.

Returns None if the state is unavailable.

Definition at line 538 of file binary_sensor.py.

◆ _recalculate_and_write_state()

None homeassistant.components.bayesian.binary_sensor.BayesianBinarySensor._recalculate_and_write_state (   self)
private

Definition at line 386 of file binary_sensor.py.

◆ _record_entity_observations()

OrderedDict[UUID, Observation] homeassistant.components.bayesian.binary_sensor.BayesianBinarySensor._record_entity_observations (   self,
str   entity 
)
private

Definition at line 397 of file binary_sensor.py.

◆ async_added_to_hass()

None homeassistant.components.bayesian.binary_sensor.BayesianBinarySensor.async_added_to_hass (   self)
Call when entity about to be added.

All relevant update logic for instance attributes occurs within this closure.
Other methods in this class are designed to avoid directly modifying instance
attributes, by instead focusing on returning relevant data back to this method.

The goal of this method is to ensure that `self.current_observations` and `self.probability`
are set on a best-effort basis when this entity is register with hass.

In addition, this method must register the state listener defined within, which
will be called any time a relevant entity changes its state.

Reimplemented from homeassistant.helpers.entity.Entity.

Definition at line 280 of file binary_sensor.py.

◆ async_update()

None homeassistant.components.bayesian.binary_sensor.BayesianBinarySensor.async_update (   self)
Get the latest data and update the states.

Definition at line 584 of file binary_sensor.py.

◆ extra_state_attributes()

dict[str, Any] homeassistant.components.bayesian.binary_sensor.BayesianBinarySensor.extra_state_attributes (   self)
Return the state attributes of the sensor.

Reimplemented from homeassistant.helpers.entity.Entity.

Definition at line 561 of file binary_sensor.py.

Member Data Documentation

◆ _attr_device_class

homeassistant.components.bayesian.binary_sensor.BayesianBinarySensor._attr_device_class
private

Definition at line 261 of file binary_sensor.py.

◆ _attr_is_on

homeassistant.components.bayesian.binary_sensor.BayesianBinarySensor._attr_is_on
private

Definition at line 262 of file binary_sensor.py.

◆ _attr_name

homeassistant.components.bayesian.binary_sensor.BayesianBinarySensor._attr_name
private

Definition at line 244 of file binary_sensor.py.

◆ _attr_should_poll

bool homeassistant.components.bayesian.binary_sensor.BayesianBinarySensor._attr_should_poll = False
staticprivate

Definition at line 232 of file binary_sensor.py.

◆ _attr_unique_id

homeassistant.components.bayesian.binary_sensor.BayesianBinarySensor._attr_unique_id
private

Definition at line 245 of file binary_sensor.py.

◆ _observations

homeassistant.components.bayesian.binary_sensor.BayesianBinarySensor._observations
private

Definition at line 246 of file binary_sensor.py.

◆ _probability_threshold

homeassistant.components.bayesian.binary_sensor.BayesianBinarySensor._probability_threshold
private

Definition at line 260 of file binary_sensor.py.

◆ observations_by_entity

homeassistant.components.bayesian.binary_sensor.BayesianBinarySensor.observations_by_entity

Definition at line 270 of file binary_sensor.py.

◆ observations_by_template

homeassistant.components.bayesian.binary_sensor.BayesianBinarySensor.observations_by_template

Definition at line 271 of file binary_sensor.py.

◆ prior

homeassistant.components.bayesian.binary_sensor.BayesianBinarySensor.prior

Definition at line 265 of file binary_sensor.py.

◆ probability

homeassistant.components.bayesian.binary_sensor.BayesianBinarySensor.probability

Definition at line 266 of file binary_sensor.py.


The documentation for this class was generated from the following file: