def to_sensor_db_model(sensor_api_model=None):
    """
    Converts a SensorTypeAPI model to DB model.
    Also, creates trigger type objects provided in SensorTypeAPI.

    :param sensor_api_model: SensorTypeAPI object.
    :type sensor_api_model: :class:`SensorTypeAPI`

    :rtype: :class:`SensorTypeDB`
    """
    class_name = getattr(sensor_api_model, "class_name", None)
    pack = getattr(sensor_api_model, "pack", None)
    entry_point = get_sensor_entry_point(sensor_api_model)
    artifact_uri = getattr(sensor_api_model, "artifact_uri", None)
    description = getattr(sensor_api_model, "description", None)
    trigger_types = getattr(sensor_api_model, "trigger_types", [])
    poll_interval = getattr(sensor_api_model, "poll_interval", None)
    enabled = getattr(sensor_api_model, "enabled", True)
    metadata_file = getattr(sensor_api_model, "metadata_file", None)

    poll_interval = getattr(sensor_api_model, "poll_interval", None)
    if poll_interval and (poll_interval < MINIMUM_POLL_INTERVAL):
        raise ValueError(
            "Minimum possible poll_interval is %s seconds" % (MINIMUM_POLL_INTERVAL)
        )

    # Add pack and metadata fileto each trigger type item
    for trigger_type in trigger_types:
        trigger_type["pack"] = pack
        trigger_type["metadata_file"] = metadata_file

    trigger_type_refs = create_trigger_types(trigger_types)

    return _create_sensor_type(
        pack=pack,
        name=class_name,
        description=description,
        artifact_uri=artifact_uri,
        entry_point=entry_point,
        trigger_types=trigger_type_refs,
        poll_interval=poll_interval,
        enabled=enabled,
        metadata_file=metadata_file,
    )

    Converts a SensorTypeAPI model to DB model.
    Also, creates trigger type objects provided in SensorTypeAPI.

    :param sensor_api_model: SensorTypeAPI object.
    :type sensor_api_model: :class:`SensorTypeAPI`

    :rtype: :class:`SensorTypeDB`
    
st2common/st2common/models/utils/sensor_type_utils.py