Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Replace Entity.device_state_attributes with Entity.extra_state_attributes#837

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
frenck merged 2 commits intomasterfromfrenck-2021-0851
Mar 9, 2021
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletiondocs/core/entity.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -104,7 +104,7 @@ Properties should always only return information from memory and not do I/O (lik
| assumed_state | boolean | `False` | Return `True` if the state is based on our assumption instead of reading it from the device. |
| available | boolean | `True` | Indicate if Home Assistant is able to read the state and control the underlying device. |
| device_class | string | `None` | Extra classification of what the device is. Each domain specifies their own. Device classes can come with extra requirements for unit of measurement and supported features. |
|device_state_attributes | dict | `None` | Extra information to store in the state machine. It needs to be information that further explains the state, it should not be static information like firmware version. |
|extra_state_attributes | dict | `None` | Extra information to store in the state machine. It needs to be information that further explains the state, it should not be static information like firmware version. |
| entity_picture | URL | `None` | Url of a picture to show for the entity. |
| name | string | `None` | Name of the entity |
| should_poll | boolean | `True` | Should Home Assistant check with the entity for an updated state. If set to `False`, entity will need to notify Home Assistant of new updates by calling one of the [schedule update methods](#methods). |
Expand Down
11 changes: 6 additions & 5 deletionsdocs/dev_101_states.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -114,16 +114,17 @@ After a start or a restart of Home Assistant the component will be visible in th
<img src='/img/en/development/create-component01.png' />
</p>

In order to expose attributes for a platform, you will need to define a property called `device_state_attributes` on the entity class, which will return a dictionary of attributes:
In order to expose attributes for a platform, you will need to define a property called `extra_state_attributes` on the entity class, which will return a dictionary of attributes:

```python
@property
defdevice_state_attributes(self):
"""Returndevice specific state attributes."""
defextra_state_attributes(self):
"""Returnentity specific state attributes."""
return self._attributes
```

:::tip
Entities also have a similar property `state_attributes`, whichnormally doesn't need tobedefined bynew platforms. This property is used by base components to add standard sets of attributes to a state. Example: The light component uses `state_attributes` to add brightness to the state dictionary. If you are designing a newcomponent, you should define `state_attributes` instead.
Entities also have a similar property `state_attributes`, whichshould notbeoverridden byintegrations. This property is used by baseentitycomponents to add standard sets of attributes to a state. Example: The light component uses `state_attributes` to add brightness to the state dictionary. If you are designing a newintegration, you should define `extra_state_attributes` instead.
:::
To get your component included in the Home Assistant releases, follow the steps described in the [Submit your work](development_submitting.md) section. Basically you only need to move your component into the `homeassistant/component/` directory of your fork and create a Pull Request.

To get your integration included in the Home Assistant releases, follow the steps described in the [Submit your work](development_submitting.md) section. Basically you only need to move your integration into the `homeassistant/component/` directory of your fork and create a Pull Request.

[8]ページ先頭

©2009-2025 Movatter.jp