From d34540edd163cb5acd523ed654dbc9a1926e78a3 Mon Sep 17 00:00:00 2001 From: Adrian Popa Date: Sun, 2 Jul 2017 23:09:52 +0300 Subject: [PATCH] Expose attributes in a custom component (#2901) * Expose attributes in a custom component Added an example on how to expose attributes in a custom component. * Update indent --- source/developers/development_states.markdown | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/source/developers/development_states.markdown b/source/developers/development_states.markdown index a560d784860..acecbf79eba 100644 --- a/source/developers/development_states.markdown +++ b/source/developers/development_states.markdown @@ -124,4 +124,13 @@ After a start or a restart of Home Assistant the component will be visible in th

+In order to expose attributes of your component, you will need to define a method called `state_attributes` which will return a dictionary of attributes: + +``` +@property +def state_attributes(self): + """Return the attributes of the entity.""" + return self._attributes +``` + To get your component included in the Home Assistant releases, follow the steps described in the [Submitting improvements](https://home-assistant.io/developers/#submitting-improvements) section. Basically you only need to move your component in the `homeassistant/component/` directory of your fork and create a Pull Request.