def decode(packet):
    """
    https://github.com/telldus/telldus/blob/master/telldus-core/service/ProtocolEverflourish.cpp
    """
    data = packet['data']
    house = data & 16776192
    house >>= 10
    unit = data & 768
    unit >>= 8
    unit += 1
    method = data & 15
    if house > 16383 or unit < 1 or unit > 4:
        return
    if method == 0:
        method = 'turnoff'
    elif method == 15:
        method = 'turnon'
    elif method == 10:
        method = 'learn'
    else:
        return
    return dict(packet, _class='command', model='selflearning', house=house,
        unit=unit, method=method)
