Create new host usermacro.

    :param macro: name of the host usermacro
    :param value: value of the host usermacro
    :param hostid: hostid or templateid
    :param _connection_user: Optional - zabbix user (can also be set in opts or pillar, see module's docstring)
    :param _connection_password: Optional - zabbix password (can also be set in opts or pillar, see module's docstring)
    :param _connection_url: Optional - url of zabbix frontend (can also be set in opts, pillar, see module's docstring)

    return: ID of the created host usermacro.

    CLI Example:

    .. code-block:: bash

        salt '*' zabbix.usermacro_create '{$SNMP_COMMUNITY}' 'public' 1

def usermacro_create(macro, value, hostid, **kwargs):
    '''
    Create new host usermacro.

    :param macro: name of the host usermacro
    :param value: value of the host usermacro
    :param hostid: hostid or templateid
    :param _connection_user: Optional - zabbix user (can also be set in opts or pillar, see module's docstring)
    :param _connection_password: Optional - zabbix password (can also be set in opts or pillar, see module's docstring)
    :param _connection_url: Optional - url of zabbix frontend (can also be set in opts, pillar, see module's docstring)

    return: ID of the created host usermacro.

    CLI Example:

    .. code-block:: bash

        salt '*' zabbix.usermacro_create '{$SNMP_COMMUNITY}' 'public' 1
    '''
    conn_args = _login(**kwargs)
    ret = {}
    try:
        if conn_args:
            params = {}
            method = 'usermacro.create'
            if macro:
                # Python mistakenly interprets macro names starting and ending with '{' and '}' as a dict
                if isinstance(macro, dict):
                    macro = "{" + six.text_type(macro.keys()[0]) +"}"
                if not macro.startswith('{') and not macro.endswith('}'):
                    macro = "{" + macro + "}"
                params['macro'] = macro
            params['value'] = value
            params['hostid'] = hostid
            params = _params_extend(params, _ignore_name=True, **kwargs)
            ret = _query(method, params, conn_args['url'], conn_args['auth'])
            return ret['result']['hostmacroids'][0]
        else:
            raise KeyError
    except KeyError:
        return ret