mirror of
https://github.com/home-assistant/developers.home-assistant.git
synced 2025-07-19 07:16:29 +00:00
Add dev blog about deprecating hass.helpers
(#2130)
* Change add_devices to add_entities * Add dev blog about deprecating `hass.helpers` * Title * Update versions
This commit is contained in:
parent
3a8fd6d731
commit
81069b1868
37
blog/2024-03-30-deprecate-hass-helpers.md
Normal file
37
blog/2024-03-30-deprecate-hass-helpers.md
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
---
|
||||||
|
author: Jan-Philipp Benecke
|
||||||
|
authorURL: https://github.com/jpbede
|
||||||
|
authorImageURL: https://avatars.githubusercontent.com/u/3989428?s=96&v=4
|
||||||
|
title: "Deprecate hass.helpers usage"
|
||||||
|
---
|
||||||
|
|
||||||
|
As of Home Assistant 2024.5, we deprecate the use of `hass.helpers`.
|
||||||
|
Using `hass.helpers` will issue a warning in the logs.
|
||||||
|
Authors of custom integrations are encouraged to update their code
|
||||||
|
to prevent any issues before Home Assistant 2024.11.
|
||||||
|
|
||||||
|
Starting from Home Assistant 2024.11, `hass.helpers` will be removed and will no longer work.
|
||||||
|
|
||||||
|
Integrations that use `hass.helpers` should be updated to import the functions and classes directly
|
||||||
|
from the integration package and pass the `hass` object as first parameter.
|
||||||
|
|
||||||
|
### New example
|
||||||
|
|
||||||
|
```python
|
||||||
|
from homeassistant.core import HomeAssistant
|
||||||
|
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||||
|
|
||||||
|
async def async_setup(hass: HomeAssistant, config):
|
||||||
|
"""Set up the component."""
|
||||||
|
client = async_get_clientsession(hass)
|
||||||
|
```
|
||||||
|
|
||||||
|
### Old example
|
||||||
|
|
||||||
|
```python
|
||||||
|
from homeassistant.core import HomeAssistant
|
||||||
|
|
||||||
|
async def async_setup(hass: HomeAssistant, config):
|
||||||
|
"""Set up the component."""
|
||||||
|
client = hass.helpers.aiohttp_client.async_get_clientsession()
|
||||||
|
```
|
Loading…
x
Reference in New Issue
Block a user