Home Assistant Unofficial Reference 2024.12.1
homeassistant.components.prometheus.PrometheusMetrics Class Reference

Public Member Functions

None __init__ (self, entityfilter.EntityFilter entity_filter, str namespace, UnitOfTemperature climate_units, EntityValues component_config, str|None override_metric, str|None default_metric)
 
None handle_entity_registry_updated (self, Event[EventEntityRegistryUpdatedData] event)
 
None handle_state (self, State state)
 
None handle_state_changed_event (self, Event[EventStateChangedData] event)
 

Static Public Member Functions

float|None state_as_number (State state)
 

Public Attributes

 metrics_prefix
 

Static Public Attributes

 full_metric_name
 
 labels
 
 registry = prometheus_client.REGISTRY,
 

Private Member Functions

None _battery (self, State state)
 
None _handle_alarm_control_panel (self, State state)
 
None _handle_attributes (self, State state)
 
None _handle_automation (self, State state)
 
None _handle_binary_sensor (self, State state)
 
None _handle_climate (self, State state)
 
None _handle_climate_temp (self, State state, str attr, str metric_name, str metric_description)
 
None _handle_counter (self, State state)
 
None _handle_cover (self, State state)
 
None _handle_device_tracker (self, State state)
 
None _handle_fan (self, State state)
 
None _handle_humidifier (self, State state)
 
None _handle_input_boolean (self, State state)
 
None _handle_input_number (self, State state)
 
None _handle_light (self, State state)
 
None _handle_lock (self, State state)
 
None _handle_number (self, State state)
 
None _handle_person (self, State state)
 
None _handle_sensor (self, State state)
 
None _handle_switch (self, State state)
 
None _handle_update (self, State state)
 
None _handle_zwave (self, State state)
 
def _MetricBaseT
 
None _numeric_handler (self, State state, str domain, str title)
 
None _remove_labelsets (self, str entity_id, str|None friendly_name=None, set[MetricWrapperBase]|None ignored_metrics=None)
 
str|None _sensor_default_metric (self, State state, str|None unit)
 
str|None _sensor_override_component_metric (self, State state, str|None unit)
 
str|None _sensor_override_metric (self, State state, str|None unit)
 

Static Private Member Functions

dict[str, Any] _labels (State state)
 
str _sanitize_metric_name (str metric)
 
str|None _sensor_attribute_metric (State state, str|None unit)
 
str|None _sensor_fallback_metric (State state, str|None unit)
 
str|None _sensor_timestamp_metric (State state, str|None unit)
 
str|None _unit_string (str|None unit)
 

Private Attributes

 _climate_units
 
 _component_config
 
 _default_metric
 
 _filter
 
 _override_metric
 

Detailed Description

Model all of the metrics which should be exposed to Prometheus.

Definition at line 161 of file __init__.py.

Constructor & Destructor Documentation

◆ __init__()

None homeassistant.components.prometheus.PrometheusMetrics.__init__ (   self,
entityfilter.EntityFilter  entity_filter,
str  namespace,
UnitOfTemperature  climate_units,
EntityValues  component_config,
str | None  override_metric,
str | None  default_metric 
)
Initialize Prometheus Metrics.

Definition at line 164 of file __init__.py.

Member Function Documentation

◆ _battery()

None homeassistant.components.prometheus.PrometheusMetrics._battery (   self,
State  state 
)
private

Definition at line 366 of file __init__.py.

◆ _handle_alarm_control_panel()

None homeassistant.components.prometheus.PrometheusMetrics._handle_alarm_control_panel (   self,
State  state 
)
private

Definition at line 798 of file __init__.py.

◆ _handle_attributes()

None homeassistant.components.prometheus.PrometheusMetrics._handle_attributes (   self,
State  state 
)
private

Definition at line 300 of file __init__.py.

◆ _handle_automation()

None homeassistant.components.prometheus.PrometheusMetrics._handle_automation (   self,
State  state 
)
private

Definition at line 771 of file __init__.py.

◆ _handle_binary_sensor()

None homeassistant.components.prometheus.PrometheusMetrics._handle_binary_sensor (   self,
State  state 
)
private

Definition at line 379 of file __init__.py.

◆ _handle_climate()

None homeassistant.components.prometheus.PrometheusMetrics._handle_climate (   self,
State  state 
)
private

Definition at line 511 of file __init__.py.

◆ _handle_climate_temp()

None homeassistant.components.prometheus.PrometheusMetrics._handle_climate_temp (   self,
State  state,
str  attr,
str  metric_name,
str   metric_description 
)
private

Definition at line 496 of file __init__.py.

◆ _handle_counter()

None homeassistant.components.prometheus.PrometheusMetrics._handle_counter (   self,
State  state 
)
private

Definition at line 780 of file __init__.py.

◆ _handle_cover()

None homeassistant.components.prometheus.PrometheusMetrics._handle_cover (   self,
State  state 
)
private

Definition at line 443 of file __init__.py.

◆ _handle_device_tracker()

None homeassistant.components.prometheus.PrometheusMetrics._handle_device_tracker (   self,
State  state 
)
private

Definition at line 427 of file __init__.py.

◆ _handle_fan()

None homeassistant.components.prometheus.PrometheusMetrics._handle_fan (   self,
State  state 
)
private

Definition at line 714 of file __init__.py.

◆ _handle_humidifier()

None homeassistant.components.prometheus.PrometheusMetrics._handle_humidifier (   self,
State  state 
)
private

Definition at line 591 of file __init__.py.

◆ _handle_input_boolean()

None homeassistant.components.prometheus.PrometheusMetrics._handle_input_boolean (   self,
State  state 
)
private

Definition at line 388 of file __init__.py.

◆ _handle_input_number()

None homeassistant.components.prometheus.PrometheusMetrics._handle_input_number (   self,
State  state 
)
private

Definition at line 421 of file __init__.py.

◆ _handle_light()

None homeassistant.components.prometheus.PrometheusMetrics._handle_light (   self,
State  state 
)
private

Definition at line 475 of file __init__.py.

◆ _handle_lock()

None homeassistant.components.prometheus.PrometheusMetrics._handle_lock (   self,
State  state 
)
private

Definition at line 489 of file __init__.py.

◆ _handle_number()

None homeassistant.components.prometheus.PrometheusMetrics._handle_number (   self,
State  state 
)
private

Definition at line 424 of file __init__.py.

◆ _handle_person()

None homeassistant.components.prometheus.PrometheusMetrics._handle_person (   self,
State  state 
)
private

Definition at line 436 of file __init__.py.

◆ _handle_sensor()

None homeassistant.components.prometheus.PrometheusMetrics._handle_sensor (   self,
State  state 
)
private

Definition at line 623 of file __init__.py.

◆ _handle_switch()

None homeassistant.components.prometheus.PrometheusMetrics._handle_switch (   self,
State  state 
)
private

Definition at line 704 of file __init__.py.

◆ _handle_update()

None homeassistant.components.prometheus.PrometheusMetrics._handle_update (   self,
State  state 
)
private

Definition at line 789 of file __init__.py.

◆ _handle_zwave()

None homeassistant.components.prometheus.PrometheusMetrics._handle_zwave (   self,
State  state 
)
private

Definition at line 768 of file __init__.py.

◆ _labels()

dict[str, Any] homeassistant.components.prometheus.PrometheusMetrics._labels ( State  state)
staticprivate

Definition at line 359 of file __init__.py.

◆ _MetricBaseT()

def homeassistant.components.prometheus.PrometheusMetrics._MetricBaseT
private

Definition at line 314 of file __init__.py.

◆ _numeric_handler()

None homeassistant.components.prometheus.PrometheusMetrics._numeric_handler (   self,
State  state,
str  domain,
str  title 
)
private

Definition at line 397 of file __init__.py.

◆ _remove_labelsets()

None homeassistant.components.prometheus.PrometheusMetrics._remove_labelsets (   self,
str  entity_id,
str | None   friendly_name = None,
set[MetricWrapperBase] | None   ignored_metrics = None 
)
private
Remove labelsets matching the given entity id from all non-ignored metrics.

Definition at line 274 of file __init__.py.

◆ _sanitize_metric_name()

str homeassistant.components.prometheus.PrometheusMetrics._sanitize_metric_name ( str  metric)
staticprivate

Definition at line 340 of file __init__.py.

◆ _sensor_attribute_metric()

str | None homeassistant.components.prometheus.PrometheusMetrics._sensor_attribute_metric ( State  state,
str | None  unit 
)
staticprivate
Get metric based on device class attribute.

Definition at line 655 of file __init__.py.

◆ _sensor_default_metric()

str | None homeassistant.components.prometheus.PrometheusMetrics._sensor_default_metric (   self,
State  state,
str | None  unit 
)
private
Get default metric.

Definition at line 650 of file __init__.py.

◆ _sensor_fallback_metric()

str | None homeassistant.components.prometheus.PrometheusMetrics._sensor_fallback_metric ( State  state,
str | None  unit 
)
staticprivate
Get metric from fallback logic for compatibility.

Definition at line 683 of file __init__.py.

◆ _sensor_override_component_metric()

str | None homeassistant.components.prometheus.PrometheusMetrics._sensor_override_component_metric (   self,
State  state,
str | None   unit 
)
private
Get metric from override in component configuration.

Definition at line 676 of file __init__.py.

◆ _sensor_override_metric()

str | None homeassistant.components.prometheus.PrometheusMetrics._sensor_override_metric (   self,
State  state,
str | None  unit 
)
private
Get metric from override in configuration.

Definition at line 670 of file __init__.py.

◆ _sensor_timestamp_metric()

str | None homeassistant.components.prometheus.PrometheusMetrics._sensor_timestamp_metric ( State  state,
str | None  unit 
)
staticprivate
Get metric for timestamp sensors, which have no unit of measurement attribute.

Definition at line 663 of file __init__.py.

◆ _unit_string()

str | None homeassistant.components.prometheus.PrometheusMetrics._unit_string ( str | None  unit)
staticprivate
Get a formatted string of the unit.

Definition at line 690 of file __init__.py.

◆ handle_entity_registry_updated()

None homeassistant.components.prometheus.PrometheusMetrics.handle_entity_registry_updated (   self,
Event[EventEntityRegistryUpdatedData]   event 
)
Listen for deleted, disabled or renamed entities and remove them from the Prometheus Registry.

Definition at line 249 of file __init__.py.

◆ handle_state()

None homeassistant.components.prometheus.PrometheusMetrics.handle_state (   self,
State  state 
)
Add/update a state in Prometheus.

Definition at line 212 of file __init__.py.

◆ handle_state_changed_event()

None homeassistant.components.prometheus.PrometheusMetrics.handle_state_changed_event (   self,
Event[EventStateChangedData event 
)
Handle new messages from the bus.

Definition at line 196 of file __init__.py.

◆ state_as_number()

float | None homeassistant.components.prometheus.PrometheusMetrics.state_as_number ( State  state)
static
Return state as a float, or None if state cannot be converted.

Definition at line 346 of file __init__.py.

Member Data Documentation

◆ _climate_units

homeassistant.components.prometheus.PrometheusMetrics._climate_units
private

Definition at line 194 of file __init__.py.

◆ _component_config

homeassistant.components.prometheus.PrometheusMetrics._component_config
private

Definition at line 174 of file __init__.py.

◆ _default_metric

homeassistant.components.prometheus.PrometheusMetrics._default_metric
private

Definition at line 176 of file __init__.py.

◆ _filter

homeassistant.components.prometheus.PrometheusMetrics._filter
private

Definition at line 177 of file __init__.py.

◆ _override_metric

homeassistant.components.prometheus.PrometheusMetrics._override_metric
private

Definition at line 175 of file __init__.py.

◆ full_metric_name

homeassistant.components.prometheus.PrometheusMetrics.full_metric_name
static

Definition at line 328 of file __init__.py.

◆ labels

homeassistant.components.prometheus.PrometheusMetrics.labels
static

Definition at line 321 of file __init__.py.

◆ metrics_prefix

homeassistant.components.prometheus.PrometheusMetrics.metrics_prefix

Definition at line 190 of file __init__.py.

◆ registry

homeassistant.components.prometheus.PrometheusMetrics.registry = prometheus_client.REGISTRY,
static

Definition at line 335 of file __init__.py.


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