'Update the TP-Link Bulb\'s state.'

def update(self):

    from pyHS100 import SmartPlugException
    try:
        self._state = (self.smartbulb.state == self.smartbulb.BULB_STATE_ON)
        self._brightness = brightness_from_percentage(self.smartbulb.brightness)
        if self.smartbulb.is_color:
            if ((self.smartbulb.color_temp is not None) and (self.smartbulb.color_temp != 0)):
                self._color_temp = kelvin_to_mired(self.smartbulb.color_temp)
    except (SmartPlugException, OSError) as ex:
        _LOGGER.warning('Could    not    read    state    for    %s:    %s', self.name, ex)
