code: def get_state_data(cls, entity):
          
          attrs = get_domain_class_attribute_iterator(type(entity))
          return dict([(attr,
                        get_nested_attribute(entity, attr.entity_attr))
                       for attr in attrs
                       if not attr.entity_attr is None])
docs: Returns the state data for the given entity.
  
          This also works for unmanaged entities.