Home Assistant Unofficial Reference 2024.12.1
homeassistant.components.recorder.websocket_api Namespace Reference

Functions

bytes _ws_get_list_statistic_ids (HomeAssistant hass, int msg_id, Literal["mean", "sum"]|None statistic_type=None)
 
bytes _ws_get_statistic_during_period (HomeAssistant hass, int msg_id, dt|None start_time, dt|None end_time, str statistic_id, set[Literal["max", "mean", "min", "change"]]|None types, dict[str, str] units)
 
bytes _ws_get_statistics_during_period (HomeAssistant hass, int msg_id, dt start_time, dt|None end_time, set[str]|None statistic_ids, Literal["5minute", "day", "hour", "week", "month"] period, dict[str, str] units, set[Literal["change", "last_reset", "max", "mean", "min", "state", "sum"]] types)
 
None async_setup (HomeAssistant hass)
 
None ws_adjust_sum_statistics (HomeAssistant hass, websocket_api.ActiveConnection connection, dict[str, Any] msg)
 
None ws_change_statistics_unit (HomeAssistant hass, websocket_api.ActiveConnection connection, dict[str, Any] msg)
 
None ws_clear_statistics (HomeAssistant hass, websocket_api.ActiveConnection connection, dict[str, Any] msg)
 
None ws_get_statistic_during_period (HomeAssistant hass, websocket_api.ActiveConnection connection, dict[str, Any] msg)
 
None ws_get_statistics_during_period (HomeAssistant hass, websocket_api.ActiveConnection connection, dict[str, Any] msg)
 
None ws_get_statistics_metadata (HomeAssistant hass, websocket_api.ActiveConnection connection, dict[str, Any] msg)
 
None ws_handle_get_statistics_during_period (HomeAssistant hass, websocket_api.ActiveConnection connection, dict msg)
 
None ws_handle_list_statistic_ids (HomeAssistant hass, websocket_api.ActiveConnection connection, dict msg)
 
None ws_import_statistics (HomeAssistant hass, websocket_api.ActiveConnection connection, dict[str, Any] msg)
 
None ws_list_statistic_ids (HomeAssistant hass, websocket_api.ActiveConnection connection, dict[str, Any] msg)
 
None ws_update_statistics_issues (HomeAssistant hass, websocket_api.ActiveConnection connection, dict[str, Any] msg)
 
None ws_update_statistics_metadata (HomeAssistant hass, websocket_api.ActiveConnection connection, dict[str, Any] msg)
 
None ws_validate_statistics (HomeAssistant hass, websocket_api.ActiveConnection connection, dict[str, Any] msg)
 

Variables

int CLEAR_STATISTICS_TIME_OUT = 10
 
 UNIT_SCHEMA
 
int UPDATE_STATISTICS_METADATA_TIME_OUT = 10
 

Detailed Description

The Recorder websocket API.

Function Documentation

◆ _ws_get_list_statistic_ids()

bytes homeassistant.components.recorder.websocket_api._ws_get_list_statistic_ids ( HomeAssistant  hass,
int  msg_id,
Literal["mean", "sum"] | None   statistic_type = None 
)
private
Fetch a list of available statistic_id and convert them to JSON.

Runs in the executor.

Definition at line 247 of file websocket_api.py.

◆ _ws_get_statistic_during_period()

bytes homeassistant.components.recorder.websocket_api._ws_get_statistic_during_period ( HomeAssistant  hass,
int  msg_id,
dt | None  start_time,
dt | None  end_time,
str  statistic_id,
set[Literal["max", "mean", "min", "change"]] | None  types,
dict[str, str]  units 
)
private
Fetch statistics and convert them to json in the executor.

Definition at line 99 of file websocket_api.py.

◆ _ws_get_statistics_during_period()

bytes homeassistant.components.recorder.websocket_api._ws_get_statistics_during_period ( HomeAssistant  hass,
int  msg_id,
dt  start_time,
dt | None  end_time,
set[str] | None  statistic_ids,
Literal["5minute", "day", "hour", "week", "month"]  period,
dict[str, str]  units,
set[Literal["change", "last_reset", "max", "mean", "min", "state", "sum"]]  types 
)
private
Fetch statistics and convert them to json in the executor.

Definition at line 156 of file websocket_api.py.

◆ async_setup()

None homeassistant.components.recorder.websocket_api.async_setup ( HomeAssistant  hass)
Set up the recorder websocket API.

Definition at line 84 of file websocket_api.py.

◆ ws_adjust_sum_statistics()

None homeassistant.components.recorder.websocket_api.ws_adjust_sum_statistics ( HomeAssistant  hass,
websocket_api.ActiveConnection  connection,
dict[str, Any]   msg 
)
Adjust sum statistics.

If the statistics is stored as NORMALIZED_UNIT,
it's allowed to make an adjustment in VALID_UNIT

Definition at line 453 of file websocket_api.py.

◆ ws_change_statistics_unit()

None homeassistant.components.recorder.websocket_api.ws_change_statistics_unit ( HomeAssistant  hass,
websocket_api.ActiveConnection  connection,
dict[str, Any]   msg 
)
Change the unit_of_measurement for a statistic_id.

All existing statistics will be converted to the new unit.

Definition at line 426 of file websocket_api.py.

◆ ws_clear_statistics()

None homeassistant.components.recorder.websocket_api.ws_clear_statistics ( HomeAssistant  hass,
websocket_api.ActiveConnection  connection,
dict[str, Any]   msg 
)
Clear statistics for a list of statistic_ids.

Note: The WS call posts a job to the recorder's queue and then returns, it doesn't
wait until the job is completed.

Definition at line 333 of file websocket_api.py.

◆ ws_get_statistic_during_period()

None homeassistant.components.recorder.websocket_api.ws_get_statistic_during_period ( HomeAssistant  hass,
websocket_api.ActiveConnection  connection,
dict[str, Any]   msg 
)
Handle statistics websocket command.

Definition at line 131 of file websocket_api.py.

◆ ws_get_statistics_during_period()

None homeassistant.components.recorder.websocket_api.ws_get_statistics_during_period ( HomeAssistant  hass,
websocket_api.ActiveConnection  connection,
dict[str, Any]   msg 
)
Handle statistics websocket command.

Definition at line 240 of file websocket_api.py.

◆ ws_get_statistics_metadata()

None homeassistant.components.recorder.websocket_api.ws_get_statistics_metadata ( HomeAssistant  hass,
websocket_api.ActiveConnection  connection,
dict[str, Any]   msg 
)
Get metadata for a list of statistic_ids.

Definition at line 368 of file websocket_api.py.

◆ ws_handle_get_statistics_during_period()

None homeassistant.components.recorder.websocket_api.ws_handle_get_statistics_during_period ( HomeAssistant  hass,
websocket_api.ActiveConnection  connection,
dict   msg 
)
Handle statistics websocket command.

Definition at line 186 of file websocket_api.py.

◆ ws_handle_list_statistic_ids()

None homeassistant.components.recorder.websocket_api.ws_handle_list_statistic_ids ( HomeAssistant  hass,
websocket_api.ActiveConnection  connection,
dict   msg 
)
Fetch a list of available statistic_id.

Definition at line 261 of file websocket_api.py.

◆ ws_import_statistics()

None homeassistant.components.recorder.websocket_api.ws_import_statistics ( HomeAssistant  hass,
websocket_api.ActiveConnection  connection,
dict[str, Any]   msg 
)
Import statistics.

Definition at line 528 of file websocket_api.py.

◆ ws_list_statistic_ids()

None homeassistant.components.recorder.websocket_api.ws_list_statistic_ids ( HomeAssistant  hass,
websocket_api.ActiveConnection  connection,
dict[str, Any]   msg 
)
Fetch a list of available statistic_id.

Definition at line 282 of file websocket_api.py.

◆ ws_update_statistics_issues()

None homeassistant.components.recorder.websocket_api.ws_update_statistics_issues ( HomeAssistant  hass,
websocket_api.ActiveConnection  connection,
dict[str, Any]   msg 
)
Update statistics issues.

Definition at line 313 of file websocket_api.py.

◆ ws_update_statistics_metadata()

None homeassistant.components.recorder.websocket_api.ws_update_statistics_metadata ( HomeAssistant  hass,
websocket_api.ActiveConnection  connection,
dict[str, Any]   msg 
)
Update statistics metadata for a statistic_id.

Only the normalized unit of measurement can be updated.

Definition at line 387 of file websocket_api.py.

◆ ws_validate_statistics()

None homeassistant.components.recorder.websocket_api.ws_validate_statistics ( HomeAssistant  hass,
websocket_api.ActiveConnection  connection,
dict[str, Any]   msg 
)
Fetch a list of available statistic_id.

Definition at line 295 of file websocket_api.py.

Variable Documentation

◆ CLEAR_STATISTICS_TIME_OUT

int homeassistant.components.recorder.websocket_api.CLEAR_STATISTICS_TIME_OUT = 10

Definition at line 54 of file websocket_api.py.

◆ UNIT_SCHEMA

homeassistant.components.recorder.websocket_api.UNIT_SCHEMA
Initial value:
1 = vol.Schema(
2  {
3  vol.Optional("area"): vol.In(AreaConverter.VALID_UNITS),
4  vol.Optional("blood_glucose_concentration"): vol.In(
5  BloodGlucoseConcentrationConverter.VALID_UNITS
6  ),
7  vol.Optional("conductivity"): vol.In(ConductivityConverter.VALID_UNITS),
8  vol.Optional("data_rate"): vol.In(DataRateConverter.VALID_UNITS),
9  vol.Optional("distance"): vol.In(DistanceConverter.VALID_UNITS),
10  vol.Optional("duration"): vol.In(DurationConverter.VALID_UNITS),
11  vol.Optional("electric_current"): vol.In(ElectricCurrentConverter.VALID_UNITS),
12  vol.Optional("voltage"): vol.In(ElectricPotentialConverter.VALID_UNITS),
13  vol.Optional("energy"): vol.In(EnergyConverter.VALID_UNITS),
14  vol.Optional("information"): vol.In(InformationConverter.VALID_UNITS),
15  vol.Optional("mass"): vol.In(MassConverter.VALID_UNITS),
16  vol.Optional("power"): vol.In(PowerConverter.VALID_UNITS),
17  vol.Optional("pressure"): vol.In(PressureConverter.VALID_UNITS),
18  vol.Optional("speed"): vol.In(SpeedConverter.VALID_UNITS),
19  vol.Optional("temperature"): vol.In(TemperatureConverter.VALID_UNITS),
20  vol.Optional("unitless"): vol.In(UnitlessRatioConverter.VALID_UNITS),
21  vol.Optional("volume"): vol.In(VolumeConverter.VALID_UNITS),
22  vol.Optional("volume_flow_rate"): vol.In(VolumeFlowRateConverter.VALID_UNITS),
23  }
24 )

Definition at line 57 of file websocket_api.py.

◆ UPDATE_STATISTICS_METADATA_TIME_OUT

int homeassistant.components.recorder.websocket_api.UPDATE_STATISTICS_METADATA_TIME_OUT = 10

Definition at line 55 of file websocket_api.py.