def state_attr(hass, entity_id, name):
    'Get a specific attribute from a state.'
    state_obj = _get_state(hass, entity_id)
    if (state_obj is not None):
        return state_obj.attributes.get(name)
    return None
Get a specific attribute from a state.
def state_attr(hass, entity_id, name):
    
    state_obj = _get_state(hass, entity_id)
    if (state_obj is not None):
        return state_obj.attributes.get(name)
    return None