Adding custom state icons to custom component?

So i have written my own custom component to link into my alarm system,

It all works but i am wondering can i set a custom icon to the states of a binary sensor

is there a def state_icon in a custom component?

    def state(self):
        """Return the state of the sensor."""
        if self.yale_object[self.device_name] == "closed":
            return "closed"
            return "open"

you have the def icon and you can change the icon in your update methog like :

def icon(self):
  return self._icon

def update(self):
  if True:
    self._icon = 'mdi:xxx'
    self._icon = 'mdi:yyy'

perfect thanks