(self)
Run when entity about to be added.
Run when entity about to be added.
Run when entity about to be added .
async def async_added_to_hass(self):
        """Run when entity about to be added."""
        await super().async_added_to_hass()
        if self._restore is True:
            # If variable state have been saved.
            state = await self.async_get_last_state()
            if state:
                # restore state
                self._value = state.state
                # restore value
                self._attributes = state.attributes
async def async_added_to_hass ( self ) : await super ( ) . async_added_to_hass ( ) if self . _restore is True : # If variable state have been saved. state = await self . async_get_last_state ( ) if state : # restore state self . _value = state . state # restore value self . _attributes = state . attributes