'Parse data sent by gateway.'

def parse_data(self, data):

    if (DENSITY in data):
        self._density = int(data.get(DENSITY))
    value = data.get(self._data_key)
    if (value is None):
        return False
    if (value == '1'):
        if self._state:
            return False
        self._state = True
        return True
    elif (value == '0'):
        if self._state:
            self._state = False
            return True
        return False
